public void GetSeedAgreementsByYears_LiveService() { var mockService = new Mock <IAgreementService>(); var listSeedAssuranceInYear = new List <SeedAssurance>() { new SeedAssurance { HarvestYear = 2015 }, new SeedAssurance { HarvestYear = 2015, }, new SeedAssurance { HarvestYear = 2016 } }; mockService.Setup(x => x.GetSeedAgreementList(supplier, ticket)).Returns(listSeedAssuranceInYear.ToArray()); var service = mockService.Object; var repo = new AgreementRepository(service, null); var result = repo.GetSeedAgreementsByYears(supplier); var resultAsEnumerable = result as IGrouping <int, SeedAssurance>[] ?? result.ToArray(); Assert.AreEqual(2, resultAsEnumerable.Count()); Assert.AreEqual(null, resultAsEnumerable.SingleOrDefault(x => x.Key == 2014)); Assert.AreEqual(2, resultAsEnumerable.Single(x => x.Key == 2015).Count()); Assert.AreEqual(1, resultAsEnumerable.Single(x => x.Key == 2016).Count()); }
public void GetSeedAgreementsByYears_NullService() { var mockService = new Mock <IAgreementService>(); mockService.Setup(x => x.GetSeedAgreementList(supplier, ticket)).Returns(new SeedAssurance[0]); var service = mockService.Object; var repo = new AgreementRepository(service, null); var result = repo.GetSeedAgreementsByYears(supplier); Assert.AreEqual(0, result.Count()); }