public void SetUp()
 {
     _repoMock = new Mock <IMunicipalityTaxScheduleRepository>();
     _repoMock.Setup(_ => _.GetByDay(It.IsAny <string>(), It.IsAny <DateTime>())).Returns(async() =>
     {
         return(await Task.Factory.StartNew(() =>
                                            MunicipalityTaxSchedulesMockData.Get().FirstOrDefault(_ => _.Id == 1)
                                            ));
     });
     _repoMock.Setup(_ => _.GetByWeek(It.IsAny <string>(), It.IsAny <DateTime>())).Returns(async() =>
     {
         return(await Task.Factory.StartNew(() =>
                                            MunicipalityTaxSchedulesMockData.Get().FirstOrDefault(_ => _.Id == 2)
                                            ));
     });
     _repoMock.Setup(_ => _.GetByMonth(It.IsAny <string>(), It.IsAny <DateTime>())).Returns(async() =>
     {
         return(await Task.Factory.StartNew(() =>
                                            MunicipalityTaxSchedulesMockData.Get().FirstOrDefault(_ => _.Id == 3)
                                            ));
     });
     _repoMock.Setup(_ => _.GetByYear(It.IsAny <string>(), It.IsAny <DateTime>())).Returns(async() =>
     {
         return(await Task.Factory.StartNew(() =>
                                            MunicipalityTaxSchedulesMockData.Get().FirstOrDefault(_ => _.Id == 4)
                                            ));
     });
     _service = new MunicipalityTaxScheduleService(_repoMock.Object);
 }
        public async Task SearchMunicipalityTax_WhenValidRequestAndDataExistsAsYearTax_ShouldReturnTheSame()
        {
            _repoMock.Setup(_ => _.GetByDay(It.IsAny <string>(), It.IsAny <DateTime>())).Returns(() =>
            {
                return(Task.Factory.StartNew(() =>
                                             MunicipalityTaxSchedulesMockData.Get().FirstOrDefault(_ => 1 == 2)
                                             ));
            });
            _repoMock.Setup(_ => _.GetByWeek(It.IsAny <string>(), It.IsAny <DateTime>())).Returns(() =>
            {
                return(Task.Factory.StartNew(() =>
                                             MunicipalityTaxSchedulesMockData.Get().FirstOrDefault(_ => 1 == 2)
                                             ));
            });

            _repoMock.Setup(_ => _.GetByMonth(It.IsAny <string>(), It.IsAny <DateTime>())).Returns(() =>
            {
                return(Task.Factory.StartNew(() =>
                                             MunicipalityTaxSchedulesMockData.Get().FirstOrDefault(_ => 1 == 2)
                                             ));
            });

            var result = await _service.SearchMunicipalityTax("Municipality-1", new DateTime(2016, 01, 01));

            Assert.IsNotNull(result);
            _repoMock.Verify(_ => _.GetByDay(It.IsAny <string>(), It.IsAny <DateTime>()), Times.Once);
            _repoMock.Verify(_ => _.GetByWeek(It.IsAny <string>(), It.IsAny <DateTime>()), Times.Once);
            _repoMock.Verify(_ => _.GetByWeek(It.IsAny <string>(), It.IsAny <DateTime>()), Times.Once);
            _repoMock.Verify(_ => _.GetByWeek(It.IsAny <string>(), It.IsAny <DateTime>()), Times.Once);
        }
 public void SetUp()
 {
     _repoMock = new Mock<IMunicipalityTaxScheduleRepository>();
     _repoMock.Setup(_ => _.GetAll()).Returns(async () =>
     {
         return await Task.Factory.StartNew(() => MunicipalityTaxSchedulesMockData.Get());
     });
     _service = new MunicipalityTaxScheduleService(_repoMock.Object);
 }
示例#4
0
        public async Task GetMunicipalityTaxById_WhenEntryForIdPassedIsNotPresent_ShouldRetunNull()
        {
            _repoMock.Setup(_ => _.GetById(It.IsAny <int>())).Returns(async() =>
            {
                return(await Task.Factory.StartNew(() => MunicipalityTaxSchedulesMockData.Get().Where(_ => 1 == 2).FirstOrDefault()));
            });

            var res = await _service.GetMunicipalityTaxById(100);

            Assert.IsNull(res);
            _repoMock.Verify(_ => _.GetById(It.IsAny <int>()), Times.Once);
        }
        public async Task UpdateExistingMunicipalityTax_WhenEntryNotFoundForPassedId_ShouldThrowValidationException()
        {
            _repoMock.Setup(_ => _.GetById(It.IsAny <int>())).Returns(async() =>
            {
                return(await Task.Factory.StartNew(() => MunicipalityTaxSchedulesMockData.Get().Where(_ => 1 == 2).FirstOrDefault()));
            });

            Assert.ThrowsAsync <NotFoundException>(async() => await _service.UpdateExistingMunicipalityTax(1, requestObject));

            _repoMock.Verify(_ => _.GetById(It.IsAny <int>()), Times.Once);
            _repoMock.Verify(_ => _.UpdateTaxSchedule(It.IsAny <MunicipalityTaxSchedules>()), Times.Never);
            await Task.Factory.StartNew(() => 0);  // workaround to avoid vs warnings
        }
示例#6
0
        public async Task BulkAddMunicipalityTax_WhenPassedEntitiesAreInvalid_ShouldReturnCountOfObjectsAdded()
        {
            _repoMock.Setup(_ => _.GetById(It.IsAny <int>())).Returns(async() =>
            {
                return(await Task.Factory.StartNew(() => MunicipalityTaxSchedulesMockData.Get().Where(_ => 1 == 2).FirstOrDefault()));
            });

            var actual = await _service.BulkAddMunicipalityTax(new List <MunicipalityTaxScheduleDto>(){
                requestObject
            });

            Assert.GreaterOrEqual(actual, 0);
            _repoMock.Verify(_ => _.BulkInsertTaxSchedule(It.IsAny <IEnumerable <MunicipalityTaxSchedules> >()), Times.Once);
        }
 public void SetUp()
 {
     _repoMock = new Mock <IMunicipalityTaxScheduleRepository>();
     _repoMock.Setup(_ => _.AddTaxSchedule(It.IsAny <MunicipalityTaxSchedules>())).Returns(async() =>
     {
         return(await Task.Factory.StartNew(() => MunicipalityTaxSchedulesMockData.Get().First()));
     });
     requestObject = new MunicipalityTaxScheduleDto()
     {
         MunicipalityName = "Municipality-3",
         TaxAmount        = 10.2M,
         TaxSheduleTypeId = (int)eTaxScheduleTypes.Daily,
         FromDate         = DateTime.Now,
         Todate           = null
     };
     _service = new MunicipalityTaxScheduleService(_repoMock.Object);
 }