예제 #1
0
        public async Task GetAccumulated_APIOK_Value()
        {
            var mockedValue = 4321;

            _repository.Setup(x => x.Retrieve(It.IsAny <Expression <Func <Reseller, bool> > >())).Returns(new[] { _validReseller }.AsQueryable);
            var result = await _service.GetAccumulated(_validReseller.CPF);

            Assert.Equal(mockedValue, result);
        }
예제 #2
0
        public async Task GetAccumulated_CPFNotInDatabase_Exception(string cpf)
        {
            IHttpClientFactory httpClientFactoryMock = HttpFakeConfig(validReturn: false);

            try
            {
                _service = new ResellerService(_repository.Object, httpClientFactoryMock, _configuration, new NullLoggerFactory());
                _repository.Setup(x => x.Retrieve(It.IsAny <Expression <Func <Reseller, bool> > >()));
                await _service.GetAccumulated(cpf);
            }
            catch (Exception ex)
            {
                Assert.Equal(typeof(CashbackServiceException), ex.GetType());
                Assert.Equal(Messages.ResellerNotFoundByCPF, ex.Message);
            }
        }
예제 #3
0
        public async Task GetAccumulated_APIErrorOnConvertReturn_Exception()
        {
            IHttpClientFactory httpClientFactoryMock = HttpFakeConfig(validReturn: false);

            try
            {
                _service = new ResellerService(_repository.Object, httpClientFactoryMock, _configuration, new NullLoggerFactory());
                _repository.Setup(x => x.Retrieve(It.IsAny <Expression <Func <Reseller, bool> > >())).Returns(new[] { _validReseller }.AsQueryable);
                await _service.GetAccumulated(_validReseller.CPF);
            }
            catch (Exception ex)
            {
                Assert.Equal(typeof(CashbackServiceException), ex.GetType());
                Assert.Equal(Messages.ErrorOnConvertResult, ex.Message);
            }
        }