public async Task TestGetAllCodesGoodData() { ACMDbContext context = ACMDbContextInMemoryFactory.InitializeContext(); CodeService codeService = new CodeService(context); Apartment apartment1 = new Apartment { Number = 1 }; Apartment apartment2 = new Apartment { Number = 2 }; await context.Apartments.AddAsync(apartment1); await context.Apartments.AddAsync(apartment2); RegistrationCode code1 = new RegistrationCode { Code = "code1", Apartment = apartment1 }; RegistrationCode code2 = new RegistrationCode { Code = "code2", Apartment = apartment2 }; await context.RegistrationCodes.AddAsync(code1); await context.RegistrationCodes.AddAsync(code2); await context.SaveChangesAsync(); var list = codeService.GetAllCodes(); Assert.Equal(2, list.Count); Assert.Equal(1, list[0].ApartmentNumber); Assert.Equal("code1", list[0].Code); Assert.Equal(2, list[1].ApartmentNumber); Assert.Equal("code2", list[1].Code); }
public void TestGetAllCodesEmptyTable() { ACMDbContext context = ACMDbContextInMemoryFactory.InitializeContext(); CodeService codeService = new CodeService(context); List <Models.CodeDTO> list = codeService.GetAllCodes(); Assert.Empty(list); }