Skip to content

Commit dcfa8ef

Browse files
committed
I dont quite comprehend why this works in debug mode, but not in normal execution
1 parent d78f95a commit dcfa8ef

File tree

3 files changed

+6
-79
lines changed

3 files changed

+6
-79
lines changed

E2eTestWebApp/E2eTestWebApp.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,4 @@
1616
<_ContentIncludedByDefault Remove="Pages\Home.razor" />
1717
</ItemGroup>
1818

19-
<ItemGroup>
20-
<Folder Include="Data\" />
21-
</ItemGroup>
22-
2319
</Project>

TestBase/Models/Person.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ public List<IMagicCompoundIndex> GetCompoundIndexes() =>
1919
};
2020

2121
// When using this, the e2e fails, but the Testserver succeeds
22-
public IMagicCompoundKey GetKeys() =>
23-
CreateCompoundKey(x => x.TestIntStable2, x => x.TestIntStable);
24-
25-
// When using this, the e2e succeeds, but the Testserver fails
2622
/*public IMagicCompoundKey GetKeys() =>
27-
CreatePrimaryKey(x => x._Id, true);*/
23+
CreateCompoundKey(x => x.TestIntStable2, x => x.TestIntStable);*/
24+
25+
// When using this, the e2e succeeds, but the Testserver fails when not in debug mode 🤯
26+
public IMagicCompoundKey GetKeys() =>
27+
CreatePrimaryKey(x => x._Id, true);
2828

2929
public string GetTableName() => "Person";
3030
public IndexedDbSet GetDefaultDatabase() => IndexDbContext.Client;

TestServer/TestServer/Components/Pages/Home.razor

Lines changed: 1 addition & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
// Display the storage size on the front-end
4242
<p>Storage Used: @storageUsageText</p>
4343
<p>Storage Quota: @storageQuotaText</p>
44-
4544
}
4645

4746
<PageTitle>Example</PageTitle>
@@ -169,59 +168,7 @@
169168
// // // DO NOT DO THIS! I only am allowing this for maximum flexibility but this is very dangerous.
170169
// IMagicQuery<Person> unassignedDbQuery = await _MagicDb.QueryOverride<Person>("DbName", "SchemaName");
171170
172-
173-
174-
175-
Person[] persons = new Person[] {
176-
new Person { Name = "Zack", DateOfBirth = null, TestInt = 9, _Age = 45, GUIY = Guid.NewGuid(), DoNotMapTest = "I buried treasure behind my house", Access=Person.Permissions.CanRead},
177-
new Person { Name = "Luna", TestInt = 9, DateOfBirth = GetDateWithSameMonthDay(GetRandomYear()), _Age = 35, GUIY = Guid.NewGuid(), DoNotMapTest = "Jerry is my husband and I had an affair with Bob.", Access = Person.Permissions.CanRead|Person.Permissions.CanWrite},
178-
new Person { Name = "Jerry", TestInt = 9, DateOfBirth = GetDateWithSameMonthDay(GetRandomYear()), _Age = 35, GUIY = Guid.NewGuid(), DoNotMapTest = "My wife is amazing", Access = Person.Permissions.CanRead|Person.Permissions.CanWrite|Person.Permissions.CanCreate},
179-
new Person { Name = "Jamie", TestInt = 9, DateOfBirth = GetDateWithSameMonthDay(GetRandomYear()), _Age = 35, GUIY = Guid.NewGuid(), DoNotMapTest = "My wife is amazing", Access = Person.Permissions.CanRead|Person.Permissions.CanWrite|Person.Permissions.CanCreate},
180-
new Person { Name = "James", TestInt = 9, DateOfBirth = GetDateWithSameMonthDay(GetRandomYear()), _Age = 35, GUIY = Guid.NewGuid(), DoNotMapTest = "My wife is amazing", Access = Person.Permissions.CanRead|Person.Permissions.CanWrite|Person.Permissions.CanCreate},
181-
new Person { Name = "Jack", TestInt = 9, DateOfBirth = GetDateWithSameMonthDay(GetRandomYear()), _Age = 35, GUIY = Guid.NewGuid(), DoNotMapTest = "My wife is amazing", Access = Person.Permissions.CanRead|Person.Permissions.CanWrite|Person.Permissions.CanCreate},
182-
new Person { Name = "Jon", TestInt = 9, DateOfBirth = GetDateWithSameMonthDay(GetRandomYear()), _Age = 37, GUIY = Guid.NewGuid(), DoNotMapTest = "I black mail Luna for money because I know her secret", Access = Person.Permissions.CanRead},
183-
new Person { Name = "Jack", TestInt = 9, DateOfBirth = GetDateWithSameMonthDay(GetRandomYear()), _Age = 37, GUIY = Guid.NewGuid(), DoNotMapTest = "I have a drug problem", Access = Person.Permissions.CanRead|Person.Permissions.CanWrite},
184-
new Person { Name = "Cathy", TestInt = 9, DateOfBirth = GetDateWithSameMonthDay(GetRandomYear()), _Age = 22, GUIY = Guid.NewGuid(), DoNotMapTest = "I got away with reading Bobs diary.", Access = Person.Permissions.CanRead | Person.Permissions.CanWrite},
185-
new Person { Name = "Bob", TestInt = 3 , DateOfBirth = GetDateWithSameMonthDay(GetRandomYear()), _Age = 69, GUIY = Guid.NewGuid(), DoNotMapTest = "I caught Cathy reading my diary, but I'm too shy to confront her.", Access = Person.Permissions.CanRead },
186-
new Person { Name = "Alex", TestInt = 3 , DateOfBirth = null, _Age = 80, GUIY = Guid.NewGuid(), DoNotMapTest = "I'm naked! But nobody can know!" },
187-
new Person { Name = "Zapoo", DateOfBirth = null, TestInt = 9, _Age = 45, GUIY = Guid.NewGuid(), DoNotMapTest = "I buried treasure behind my house", Access=Person.Permissions.CanRead},
188-
189-
new Person { Name = "Sarah", TestInt = -1, _Age = 30, GUIY = Guid.NewGuid(), DoNotMapTest = "I hate my job", Access=Person.Permissions.CanRead},
190-
new Person { Name = "Michael", TestInt = 15, _Age = 50, GUIY = Guid.NewGuid(), DoNotMapTest = "I'm hiding a big secret", Access=Person.Permissions.CanRead | Person.Permissions.CanWrite},
191-
new Person { Name = "Tommy", TestInt = 7, _Age = 12, GUIY = Guid.NewGuid(), DoNotMapTest = "I am just a kid" },
192-
new Person { Name = "Grace", TestInt = 3, _Age = 90, GUIY = Guid.NewGuid(), DoNotMapTest = "I have seen the world" },
193-
new Person { Name = "Xylophone", TestInt = 9, _Age = 27, GUIY = Guid.NewGuid(), DoNotMapTest = "I have the weirdest name" },
194-
new Person { Name = "Yasmine", TestInt = 9, _Age = 40, GUIY = Guid.NewGuid(), DoNotMapTest = null },
195-
196-
// Additional test case persons to stress-test LINQ validation
197-
new Person { Name = "Alicia", TestInt = 42, _Age = 16, GUIY = Guid.NewGuid(), DoNotMapTest = "I just got my driver's license" },
198-
new Person { Name = "Ben", TestInt = 0, _Age = 25, GUIY = Guid.NewGuid(), DoNotMapTest = "I have no TestInt value" },
199-
new Person { Name = "Clara", TestInt = 100, _Age = 65, GUIY = Guid.NewGuid(), DoNotMapTest = "I retired last week", Access = Person.Permissions.CanRead | Person.Permissions.CanWrite },
200-
new Person { Name = "Danny", TestInt = 9, _Age = 40, GUIY = Guid.NewGuid(), DoNotMapTest = null }, // Null handling
201-
new Person { Name = "Elliot", TestInt = -20, _Age = 55, GUIY = Guid.NewGuid(), DoNotMapTest = "My test int is negative" },
202-
new Person { Name = "Fiona", TestInt = 11, _Age = 33, GUIY = Guid.NewGuid(), DoNotMapTest = "I like puzzles" },
203-
new Person { Name = "George", TestInt = 8, _Age = 72, GUIY = Guid.NewGuid(), DoNotMapTest = "I fought in a war", Access = Person.Permissions.CanRead | Person.Permissions.CanWrite | Person.Permissions.CanCreate },
204-
new Person { Name = "Henry", TestInt = 99, _Age = 29, GUIY = Guid.NewGuid(), DoNotMapTest = "I almost made it to 100 TestInt" },
205-
new Person { Name = "Isla", TestInt = 2, _Age = 18, GUIY = Guid.NewGuid(), DoNotMapTest = "I just turned into an adult" },
206-
new Person { Name = "Jackie", TestInt = 75, _Age = 60, GUIY = Guid.NewGuid(), DoNotMapTest = "I love cooking" },
207-
new Person { Name = "Kevin", TestInt = 5, _Age = 48, GUIY = Guid.NewGuid(), DoNotMapTest = "I own a small business" },
208-
new Person { Name = "Liam", TestInt = 9, _Age = 55, GUIY = Guid.NewGuid(), DoNotMapTest = "I just became a grandfather" },
209-
new Person { Name = "Mona", TestInt = 88, _Age = 35, GUIY = Guid.NewGuid(), DoNotMapTest = "I am a detective", Access = Person.Permissions.CanRead | Person.Permissions.CanWrite },
210-
new Person { Name = "Nathan", TestInt = 7, _Age = 27, GUIY = Guid.NewGuid(), DoNotMapTest = "I play guitar" },
211-
new Person { Name = "Olivia", TestInt = 13, _Age = 45, GUIY = Guid.NewGuid(), DoNotMapTest = "I run marathons" },
212-
new Person { Name = "Patrick", TestInt = 3, _Age = 52, GUIY = Guid.NewGuid(), DoNotMapTest = "I work in IT" },
213-
new Person { Name = "Quinn", TestInt = 22, _Age = 42, GUIY = Guid.NewGuid(), DoNotMapTest = "I design board games" },
214-
new Person { Name = "Rachel", TestInt = 77, _Age = 36, GUIY = Guid.NewGuid(), DoNotMapTest = "I am a pilot" },
215-
new Person { Name = "Steve", TestInt = 9, _Age = 38, GUIY = Guid.NewGuid(), DoNotMapTest = "I am an engineer" },
216-
new Person { Name = "Tina", TestInt = 3, _Age = 68, GUIY = Guid.NewGuid(), DoNotMapTest = "I just got my pension" },
217-
new Person { Name = "Uma", TestInt = 14, _Age = 39, GUIY = Guid.NewGuid(), DoNotMapTest = "I teach yoga" },
218-
new Person { Name = "Victor", TestInt = 6, _Age = 31, GUIY = Guid.NewGuid(), DoNotMapTest = "I am an artist" },
219-
new Person { Name = "Wendy", TestInt = 50, _Age = 50, GUIY = Guid.NewGuid(), DoNotMapTest = "My age matches my test int" },
220-
new Person { Name = "Xander", TestInt = 19, _Age = 21, GUIY = Guid.NewGuid(), DoNotMapTest = "I am a college student" },
221-
new Person { Name = "Yara", TestInt = 90, _Age = 32, GUIY = Guid.NewGuid(), DoNotMapTest = "I work in finance" },
222-
new Person { Name = "Zane", TestInt = 101, _Age = 47, DateOfBirth = new DateTime(2020, 2, 10), GUIY = Guid.NewGuid(), DoNotMapTest = "I love motorcycles" },
223-
};
224-
171+
Person[] persons = TestBase.Data.PersonData.persons;
225172

226173
var count = 0;
227174
foreach (var p in persons)
@@ -232,15 +179,10 @@
232179
p.TestIntStable2 = 10;
233180
}
234181

235-
236-
237182
//var storageInfo = await _MagicDb.GetStorageEstimateAsync();
238183
//storageQuota = storageInfo.QuotaInMegabytes;
239184
//storageUsage = storageInfo.UsageInMegabytes;
240185
241-
242-
243-
244186
// WhereExample = await (manager.Where<Person>(x => x.Name.StartsWith("c", StringComparison.OrdinalIgnoreCase)
245187
// || x.Name.StartsWith("l", StringComparison.OrdinalIgnoreCase)
246188
// || x.Name.StartsWith("j", StringComparison.OrdinalIgnoreCase) && x._Age > 35
@@ -253,8 +195,6 @@
253195

254196
allPeople = await personQuery.ToListAsync();
255197

256-
257-
258198
List<Person> people = await personQuery.ToListAsync();
259199
StateHasChanged();
260200

@@ -271,12 +211,9 @@
271211
var asdf = d.DayOfWeek;
272212
var asdf2 = d.DayOfYear;
273213

274-
275214
// I know the validation of "allPeople" targets differently but I know this is the right result.
276215
// This is a weird .NET memory grab weirdess.
277216
278-
279-
280217
RunTest("Date Equal",
281218
await personQuery.Where(x => x.DateOfBirth.Value.Date == new DateTime(2020, 2, 10)).ToListAsync(),
282219
allPeople.Where(x => x.DateOfBirth.HasValue && x.DateOfBirth.Value.Date == new DateTime(2020, 2, 10)));
@@ -357,7 +294,6 @@
357294
await personQuery.Where(x => x.DateOfBirth.Value.DayOfYear <= 41).ToListAsync(),
358295
allPeople.Where(x => x.DateOfBirth.HasValue && x.DateOfBirth.Value.DayOfYear <= 41));
359296

360-
361297
RunTest("Date Day Of Week Equal",
362298
await personQuery.Where(x => x.DateOfBirth.Value.DayOfWeek == DayOfWeek.Monday).ToListAsync(),
363299
allPeople.Where(x => x.DateOfBirth.HasValue && x.DateOfBirth.Value.DayOfWeek == DayOfWeek.Monday));
@@ -422,7 +358,6 @@
422358
RunTest("Contains Test", await personQuery.Where(x => x.Name.Contains("zac", StringComparison.OrdinalIgnoreCase)).ToListAsync(),
423359
allPeople.Where(x => x.Name.Contains("zac", StringComparison.OrdinalIgnoreCase)));
424360

425-
426361
RunTest("Not Contains Test", await personQuery.Where(x => !x.Name.Contains("zac", StringComparison.OrdinalIgnoreCase)).ToListAsync(),
427362
allPeople.Where(x => !x.Name.Contains("zac", StringComparison.OrdinalIgnoreCase)));
428363

@@ -494,7 +429,6 @@
494429
*/
495430
allPeople.OrderBy(x => x.Name).ThenBy(x => x._Id).TakeLast(2));
496431

497-
498432
var totalPersons = await personQuery.CountAsync();
499433
var test1 = await personQuery.FirstOrDefaultAsync();
500434
var test2 = await personQuery.FirstOrDefaultAsync(x => x.Name == "Victor");
@@ -518,7 +452,6 @@
518452
RunTest("Cursor Last Or Default Where Test", new List<Person>() { await personQuery.Cursor(x => x.Name == "Victor").OrderBy(x => x._Age).LastOrDefaultAsync() },
519453
new List<Person>() { allPeople.Where(x => x.Name == "Victor").OrderBy(x => x._Age).ThenBy(x => x._Id).LastOrDefault() });
520454

521-
522455
RunTest("Index First Or Default Test", new List<Person>() { await personQuery.OrderBy(x => x._Id).FirstOrDefaultAsync() },
523456
new List<Person>() { allPeople.OrderBy(x => x._Id).ThenBy(x => x._Id).FirstOrDefault() });
524457

@@ -595,7 +528,6 @@
595528
.ToListAsync(),
596529
allPeople.Where(x => x._Age < 60).OrderByDescending(x => x._Age).ThenByDescending(x => x._Id).TakeLast(2));
597530

598-
599531
//await Task.Delay(10000);
600532
// 🧩 Complex Nested Conditions
601533
RunTest("Nested OR within AND",
@@ -673,7 +605,6 @@
673605
.ToListAsync(),
674606
allPeople.OrderByDescending(x => x._Age).ThenByDescending(x => x._Id).TakeLast(5));
675607

676-
677608
// Return ToListAsync
678609
RunTest("Return ToListAsync",
679610
await personQuery.ToListAsync(),

0 commit comments

Comments
 (0)