public void CanRenameCategory() { // ARRANGE var expectedId = Guid.NewGuid(); var expectedNewName = "Red Dwarfs"; var expectedUpdatedCategoryDto = Substitute.For <CategoryDto>(); expectedUpdatedCategoryDto.Name = expectedNewName; _noteTaker.RenameCategory(Arg.Any <SecurityContext>(), expectedId, expectedNewName).Returns(expectedUpdatedCategoryDto); // ACT var result = _subjectUnderTest.Put(expectedId, expectedUpdatedCategoryDto); // ASSERT Assert.That(result, Is.Not.Null); _noteTaker.Received(1).RenameCategory(Arg.Any <SecurityContext>(), expectedId, expectedNewName); }
public IActionResult Put(Guid id, [FromBody] CategoryDto updatedCategory) { var categoryDto = _noteTaker.RenameCategory(SecurityContext, id, updatedCategory.Name); return(CreatedAtAction("Get", new { id = categoryDto.Id }, categoryDto)); }