Beispiel #1
0
        public async Task GetTaxForMunicipalityAndDate(string municipalityName, string date, decimal expectedTax)
        {
            var taxManager = new Api.Domain.TaxManager(_testRepository, _mapper);
            var result     = await taxManager.GetMunicipalityTaxForDateAsync(municipalityName, date);

            AssertResult(expectedTax, result);
        }
Beispiel #2
0
        public TaxManagerShould()
        {
            var config = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new TaxEntryProfiler());
            });

            _mapper = config.CreateMapper();

            #region CreateTestData
            _municipalities = new List <Municipality>
            {
                new Municipality(1, "Vilnius"),
                new Municipality(2, "Kaunas")
            };

            _taxEntries = new List <TaxEntry>
            {
                new TaxEntry(1, new DateTime(2016, 1, 1), new DateTime(2017, 01, 1), 1, (int)TaxTypes.Yearly, 0.2m),
                new TaxEntry(2, new DateTime(2016, 5, 1), new DateTime(2016, 6, 1), 1, (int)TaxTypes.Monthly, 0.4m),
                new TaxEntry(3, new DateTime(2016, 1, 1), new DateTime(2016, 1, 2), 1, (int)TaxTypes.Daily, 0.1m),
                new TaxEntry(4, new DateTime(2016, 12, 25), new DateTime(2016, 12, 26), 1, (int)TaxTypes.Daily, 0.1m)
            };
            #endregion

            _taxRepositoryMock = new Mock <ITaxRepository>();
            _taxRepositoryMock.Setup(x => x.GetAllMunicipalities())
            .Returns(_municipalities);

            _testRepository = new TestRepository(_municipalities, _taxEntries, _mapper);
            _taxManager     = new Api.Domain.TaxManager(_taxRepositoryMock.Object, _mapper);
        }
Beispiel #3
0
        public async Task BeAbleToAddTaxEntry(string dateFrom, string dateTo, int municipalityId, TaxTypes taxType, decimal taxApplied, string municipalityName)
        {
            var dateFromAsDate   = Convert.ToDateTime(dateFrom);
            var dateToAsDate     = Convert.ToDateTime(dateTo);
            var taxEntryToInsert = new TaxEntryCreateDto(dateFromAsDate, dateToAsDate, municipalityId, (int)taxType, taxApplied);
            var taxManager       = new Api.Domain.TaxManager(_testRepository, _mapper);

            var result = await taxManager.InsertTaxEntryAsync(taxEntryToInsert);

            Assert.Equal(taxEntryToInsert.TaxType, result.TaxType);
            Assert.Equal(taxEntryToInsert.DateFrom, result.DateFrom);
            Assert.Equal(taxEntryToInsert.DateTo, result.DateTo);
            Assert.Equal(taxEntryToInsert.MunicipalityId, result.MunicipalityId);
            Assert.Equal(taxEntryToInsert.TaxValue, result.TaxValue);
            Assert.NotNull(result.Id);

            var check = await taxManager.GetMunicipalityTaxForDateAsync(municipalityName, dateFrom);

            AssertResult(taxEntryToInsert.TaxValue, check);
        }