public async void GetGpsByPatient() { string surname = "Smith"; Repository <GP> gp = new Repository <GP>(DbContext); IGPRepository gPRepository = new GPRepository(DbContext); IReadOnlyList <GP> actual = gp.GetWithRawSql("SELECT distinct doctors.* FROM " + " dbo.GPs AS doctors, dbo.Regions AS regions, dbo.GPRegions AS gpregions, dbo.Patients AS patients WHERE " + $" doctors.Id = gpregions.GPId AND regions.Id = gpregions.RegionId AND gpregions.RegionId = patients.RegionId AND patients.Surname = '{surname}'; ").ToList(); IReadOnlyList <GP> expected = await gPRepository.GetGPsByPatientSurnameAsync(surname); Assert.AreEqual(expected.Count, actual.Count, "Wrond number of rows "); }
public async void GetGPsByRegion() { string region = "Surrey"; Repository <GP> gp = new Repository <GP>(DbContext); IGPRepository gPRepository = new GPRepository(DbContext); IReadOnlyList <GP> expected = gp.GetWithRawSql( "SELECT " + "gp.* " + "FROM [dbo].GPs AS gp " + "WHERE EXISTS (SELECT " + "1 AS [C1] " + "FROM [dbo].GPRegions AS gprg " + $"WHERE (gp.[Id] = gprg.GPId) AND(gprg.RegionId = (Select dbo.Regions.Id from dbo.Regions where dbo.Regions.Name = '{region}')));" ).ToList(); IReadOnlyList <GP> actual = await gPRepository.GetGpsByRegionAsync(region); Assert.AreEqual(expected.Count, actual.Count, "The number of rows is wrong"); }