示例#1
0
        public void GetDryAgreements_NullService()
        {
            var mockService = new Mock <IAgreementService>();

            mockService.Setup(w => w.GetDryAgreementList(string.Empty, string.Empty)).Returns(new DryAgreement[0]);

            var service = mockService.Object;

            var repo = new AgreementRepository(service, null);
            var list = repo.GetFarmingAgreementsByYears(string.Empty);

            Assert.AreEqual(0, list.Count());
        }
示例#2
0
        public void GetFarmingAgreementsByYears_LiveService()
        {
            var mockService           = new Mock <IAgreementService>();
            var listExpectedAgreement = ListAgreementsInYears;

            mockService.Setup(w => w.GetFarmingAgreementList(supplier, ticket)).Returns(listExpectedAgreement.ToArray);

            var service = mockService.Object;

            var repo               = new AgreementRepository(service, null);
            var resultAsList       = repo.GetFarmingAgreementsByYears(supplier);
            var resultAsEnumerable = resultAsList as IGrouping <int, Agreement>[] ?? resultAsList.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());
        }