Esempio n. 1
0
        public async Task TestInsert()
        {
            _serviceMock = new Mock <ICurrentAccountService>();
            _serviceMock.Setup(m => m.Insert(entity)).ReturnsAsync(Id);
            _service = _serviceMock.Object;

            var resultId = await _service.Insert(entity);

            Assert.False(resultId == Guid.Empty);

            _serviceMockHistoric = new Mock <IHistoricCurrentAccountService>();
            _serviceMockHistoric.Setup(m => m.Insert(entityHistoric)).ReturnsAsync(HistoricCurrentAccountId);
            _serviceHistoric = _serviceMockHistoric.Object;

            var historicResultId = await _serviceHistoric.Insert(entityHistoric);

            Assert.False(historicResultId == Guid.Empty);
        }
Esempio n. 2
0
        public async Task TestGet()
        {
            _serviceMock = new Mock <ICurrentAccountService>();
            _serviceMock.Setup(m => m.Get(UserId)).ReturnsAsync(currentAccountDtoResult);
            _service = _serviceMock.Object;

            var result = await _service.Get(UserId);

            Assert.NotNull(result);
            Assert.True(result.Id == Id);
            Assert.Equal(Balance, result.Balance);
            Assert.Equal(UserId, result.UserId);

            _serviceMock = new Mock <ICurrentAccountService>();
            _serviceMock.Setup(m => m.Get(It.IsAny <Guid>())).Returns(Task.FromResult((CurrentAccountDtoResult)null));
            _service = _serviceMock.Object;

            var resultNull = await _service.Get(UserId);

            Assert.Null(resultNull);

            var listResult = new List <HistoricCurrentAccountDtoResult>();

            _serviceMockHistoric = new Mock <IHistoricCurrentAccountService>();
            _serviceMockHistoric.Setup(m => m.FindByUserId(UserId)).ReturnsAsync(listHistoricDtoResult);
            _serviceHistoric = _serviceMockHistoric.Object;

            var resultHistoric = await _serviceHistoric.FindByUserId(UserId);

            Assert.NotEmpty(resultHistoric);
            Assert.True(resultHistoric.Count() == 1);

            _serviceMockHistoric = new Mock <IHistoricCurrentAccountService>();
            _serviceMockHistoric.Setup(m => m.FindByUserId(It.IsAny <Guid>())).ReturnsAsync(listResult.AsEnumerable);
            _serviceHistoric = _serviceMockHistoric.Object;

            var resultHistoricEmpty = await _serviceHistoric.FindByUserId(Id);

            Assert.Empty(resultHistoricEmpty);
        }
 public HistoricCurrentAccountController(IHistoricCurrentAccountService service)
 {
     _service = service;
 }