public async Task HandleAsync(DeleteSavingTypeCommand message, CancellationToken token = default(CancellationToken))
        {
            var type = await this.GetSavingTypeAsync(message.SavingTypeId);

            _types.Delete(type);
            await _types.SaveChangesAsync();
        }
コード例 #2
0
        public async Task ShouldDeleteExisting()
        {
            // Arrange
            SavingType entity     = SavingType.Create(Guid.NewGuid(), Guid.NewGuid(), "Name", "Symbol");
            var        repository = new Mock <ISavingTypeRepository>();

            repository.Setup(e =>
                             e.GetByIdAsync(It.IsAny <Guid>(), It.IsAny <CancellationToken>())).ReturnsAsync(entity);
            DeleteSavingTypeCommand cmd = new DeleteSavingTypeCommand(entity.Id);

            SavingTypeCommandHandler actual = new SavingTypeCommandHandler(repository.Object);

            // Act
            await actual.HandleAsync(cmd);

            // Assert
            repository.Verify(e =>
                              e.Delete(It.Is <SavingType>(a => a.Equals(entity))),
                              Times.Once
                              );
        }