public void TestListEntity() { // Prepare ITestRepository testRepository = fixture.IoC.Resolve <ITestRepository>(); TestEntity tester1 = testRepository.NewEntity(); tester1.Name = "Henry Roeland"; tester1.Number = 21061977; TestEntity tester1Saved = testRepository.SaveEntity(tester1); TestEntity tester2 = testRepository.NewEntity(); tester2.Name = "Klaas Baarssen"; tester2.Number = 0; TestEntity tester2Saved = testRepository.SaveEntity(tester2); TestEntity tester3 = testRepository.NewEntity(); tester3.Name = "Gerjan Konterman"; tester3.Number = 0; TestEntity tester3Saved = testRepository.SaveEntity(tester3); // Test IList <TestEntity> tests = testRepository.ListEntity(); Assert.True(3 <= tests.Count); Assert.Equal(tester1Saved.Id, tests.Where(x => x.Name.Equals(tester1.Name)).FirstOrDefault().Id); Assert.Equal(tester2Saved.Id, tests.Where(x => x.Name.Equals(tester2.Name)).FirstOrDefault().Id); Assert.Equal(tester3Saved.Id, tests.Where(x => x.Name.Equals(tester3.Name)).FirstOrDefault().Id); // Cleanup Assert.True(testRepository.DeleteEntity(tester1Saved.Id)); Assert.True(testRepository.DeleteEntity(tester2Saved.Id)); Assert.True(testRepository.DeleteEntity(tester3Saved.Id)); }
public void TestNewEntityAndSave() { // Prepare ITestRepository testRepository = fixture.IoC.Resolve <ITestRepository>(); TestEntity tester = testRepository.NewEntity(); tester.Name = "Henry Roeland"; tester.Number = 1977; TestEntity testerSaved = testRepository.SaveEntity(tester); // Test Assert.True(testerSaved.Id > 0); Assert.False(testerSaved.Deleted); Assert.Equal(tester.Name, testerSaved.Name); Assert.Equal(tester.Number, testerSaved.Number); // Cleanup Assert.True(testRepository.DeleteEntity(testerSaved.Id)); }