public void Should_Be_Right_Accelerations_When_Find_By_Company_Id(int companyId) { var fakeContext = new FakeContext("AccelerationByCompany"); fakeContext.FillWithAll(); using (var context = new CodenationContext(fakeContext.FakeOptions)) { var expected = fakeContext.GetFakeData <Company>(). Where(company => company.Id == companyId). Join(fakeContext.GetFakeData <Candidate>(), company => company.Id, candidate => candidate.CompanyId, (company, candidate) => candidate). Join(fakeContext.GetFakeData <Acceleration>(), candidate => candidate.AccelerationId, acceleration => acceleration.Id, (candidate, acceleration) => acceleration). Distinct(). ToList(); var service = new AccelerationService(context); var actual = service.FindByCompanyId(companyId); Assert.Equal(expected, actual, new AccelerationIdComparer()); } }
public void FindByCompanyIdTest_Return_Right(int companyId, params int[] idAccelerationExpected) { var fakeContext = new FakeContext("AccelerationFindByCompanyId"); fakeContext.FillWith <Candidate>(); fakeContext.FillWith <Acceleration>(); using (var context = new CodenationContext(fakeContext.FakeOptions)) { List <Acceleration> expected = new List <Acceleration>(); foreach (var id in idAccelerationExpected) { var expectedData = fakeContext.GetFakeData <Acceleration>().Find(x => x.Id == id); if (!(expectedData is null)) { expected.Add(fakeContext.GetFakeData <Acceleration>().Find(x => x.Id == id)); } } var service = new AccelerationService(context); var actual = service.FindByCompanyId(companyId); Assert.Equal(expected, actual, new AccelerationIdComparer()); } }