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); }
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); } }
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); } }