Ejemplo n.º 1
0
        public Task Delete([FromBody] UpdateNutrientModel model)
        {
            this.TryValidateModel(model);

            var command = new UpdateNutrientTitle(model.NutrientId, model.Title);

            return(this.updateNutrientTitleHandler.HandleCommandAsync(command));
        }
Ejemplo n.º 2
0
        public async Task HandleCommandAsync_WithValidArgs_UpdatesNutrientTitle()
        {
            // Arrange
            var id           = this.fixture.Create <Guid>();
            var newTitle     = this.fixture.Create <string>();
            var oldTitle     = this.fixture.Create <string>();
            var command      = new UpdateNutrientTitle(id, newTitle);
            var fakeNutrient = Nutrient.Create(oldTitle);

            A.CallTo(() => this.repository.GetOneByKeyAsync(id))
            .Returns(fakeNutrient);

            // Act
            await this.sut.HandleCommandAsync(command);

            // Assert
            A.CallTo(() => this.repository.GetOneByKeyAsync(id))
            .MustHaveHappenedOnceExactly();
            A.CallTo(() => this.repository.SaveOneAsync(fakeNutrient))
            .MustHaveHappenedOnceExactly();
            fakeNutrient.Title.Should().BeEquivalentTo(newTitle);
        }