Exemplo n.º 1
0
        public void GetRates_Empty_Zip_Expected_Argument_Null_Exception()
        {
            var taxService = new TaxService(taxRepoMock.Object, mapperMock.Object);

            var request = new GetTaxRateModel
            {
                Zip = string.Empty
            };

            Assert.That(() => taxService.GetRates(request), Throws.ArgumentNullException);
        }
Exemplo n.º 2
0
        public void GetRates_Null_Country_Expected_Argument_Null_Exception()
        {
            var taxService = new TaxService(taxRepoMock.Object, mapperMock.Object);

            var request = new GetTaxRateModel
            {
                Zip     = "zip",
                Country = null
            };

            Assert.That(() => taxService.GetRates(request), Throws.ArgumentNullException);
        }
Exemplo n.º 3
0
        public async Task <TaxRateResponse> GetRates(GetTaxRateModel request)
        {
            if (request == null)
            {
                throw new NullReferenceException();
            }

            if (string.IsNullOrEmpty(request.Zip))
            {
                throw new ArgumentNullException(nameof(request.Zip));
            }

            if (string.IsNullOrEmpty(request.Country))
            {
                throw new ArgumentNullException(nameof(request.Country));
            }

            var mapped = mapper.Map <TaxRateRequest>(request);

            return(await taxRepository.Get <TaxRateRequest, TaxRateResponse>(mapped));
        }
Exemplo n.º 4
0
        public void GetRates_Valid_Response_Expected()
        {
            var taxService = new TaxService(taxRepoMock.Object, mapperMock.Object);

            var request = new GetTaxRateModel
            {
                Zip     = "zip",
                Country = "country"
            };

            taxRepoMock.Setup(x => x.Get <TaxRateRequest, TaxRateResponse>(It.IsAny <TaxRateRequest>())).ReturnsAsync(() =>
            {
                return(new TaxRateResponse
                {
                    City = "City"
                });
            });

            var result = taxService.GetRates(request);

            Assert.NotNull(result);
        }