Beispiel #1
0
        public async Task AddAsyncTest_Excluded(BatchDTO batchDto, Batch batchEntity)
        {
            _mapperMock.Setup(m => m.Map <BatchDTO, Batch>(It.IsAny <BatchDTO>()))
            .Returns(batchEntity);
            _mapperMock.Setup(m => m.Map <Batch, BatchDTO>(It.IsAny <Batch>()))
            .Returns(batchDto);

            _repositoryMock.Setup(r => r.InsertAsync(It.IsAny <Batch>()))
            .Returns(Task.FromResult(batchEntity));

            _transactionMock.Setup(t => t.GetByDateWithCategoryAsync(It.IsAny <DateTime>(), It.IsAny <DateTime>()))
            .Returns(Task.FromResult(new List <TransactionDTO> {
            }));

            _categoryMock.Setup(c => c.GetByNameAsync(It.IsAny <string>()))
            .Returns(Task.FromResult((CategoryDTO)null));

            _repositoryMock.Setup(r => r.GetByIdAsync(It.IsAny <int>()))
            .Returns(Task.FromResult(batchEntity));

            var result = await _service.AddAsync(batchDto);

            Assert.Equal(2, result.Excluded);
        }