public void TestAnmeldungWithMatchCount()
        {
            using (var scope = provider.CreateScope()) {
                var ar      = scope.ServiceProvider.GetRequiredService <AnmeldungRepository>();
                var context = scope.ServiceProvider.GetRequiredService <ApplicationDbContext>();
                // save current datetime so it isn't affected by programm execution and can be checked later
                DateTime now = DateTime.Now;
                Utils.CreateTestData(context, now);
                // test with one match
                IEnumerable <AnmeldungRepository.AnmeldungWithMatchCount> results = ar.SearchAnmeldungenWithMatchCount("Vor", "Nach", "irrelevant", "");
                Assert.NotNull(results);
                Assert.Single(results);
                AnmeldungRepository.AnmeldungWithMatchCount awmc = results.First();
                Assert.Equal(2, awmc.matchCount);

                // test with phone number, more matches with different match count
                results = ar.SearchAnmeldungenWithMatchCount("test", "", "", "123");
                Assert.NotNull(results);
                Assert.Equal(3, results.Count());
                Assert.Equal(1, results.ElementAt(0).matchCount);
                Assert.Equal(1, results.ElementAt(1).matchCount);
                Assert.Equal(2, results.ElementAt(2).matchCount);

                // test match all, case insensitive
                results = ar.SearchAnmeldungenWithMatchCount("Vor", "ASDF", "*****@*****.**", "123");
                Assert.NotNull(results);
                Assert.Equal(4, results.Count());
                Assert.Equal(3, results.ElementAt(0).matchCount);
                Assert.Equal(3, results.ElementAt(1).matchCount);
                Assert.Equal(3, results.ElementAt(2).matchCount);
                Assert.Equal(1, results.ElementAt(3).matchCount);
            }
        }
Beispiel #2
0
 public static AnmeldungWithMatchCountDTO toDTO(AnmeldungRepository.AnmeldungWithMatchCount awmc)
 {
     return(new AnmeldungWithMatchCountDTO {
         AnmeldungID = awmc.anmeldungId,
         EMail = awmc.Email,
         Handynummer = awmc.Nummer,
         MatchCount = awmc.matchCount,
         Nachname = awmc.Nachname,
         SchulungGUID = awmc.SchulungGuid,
         Status = awmc.Status,
         Vorname = awmc.Vorname,
         Schulung = InternalSchulungDTO.toDTO(awmc.Schulung),
     });
 }