예제 #1
0
        public void Handle_GivenInvalidId_ThrowsException()
        {
            var command = new UpdateCategoryCommand
            {
                Id           = 99,
                CategoryName = "Bucket List",
            };

            var handler = new UpdateCategoryCommand.UpdateCategoryCommandHandler(Context);

            Should.ThrowAsync <NotFoundException>(() =>
                                                  handler.Handle(command, CancellationToken.None));
        }
예제 #2
0
        public async Task Handle_GivenValidId_ShouldUpdatePersistedCategory()
        {
            var command = new UpdateCategoryCommand
            {
                Id           = 1,
                CategoryName = "Shopping",
            };

            var handler = new UpdateCategoryCommand.UpdateCategoryCommandHandler(Context);

            await handler.Handle(command, CancellationToken.None);

            var entity = Context.Categories.Find(command.Id);

            entity.ShouldNotBeNull();
            entity.CategoryName.ShouldBe(command.CategoryName);
        }