public async Task UpdateFunctionAsync_WithTestFunction_ReturnsFunctionModel() { // Arrange var controller = new FunctionController(functionService, orderByHelper, paginationHelper, mapper); functionService.UpdateAsync(functionSubmitModel, Arg.Any <Guid>()) .Returns(functionModel); // Act IActionResult actionResult = await controller.UpdateFunctionAsync(functionSubmitModel.Uuid, functionSubmitModel); // Assert var okResult = actionResult as OkObjectResult; Assert.NotNull(okResult); var function = okResult.Value as Function; Assert.NotNull(function); Assert.True(function.Uuid == functionSubmitModel.Uuid, $"Retrieved Id {function.Uuid} not the same as sample id {functionSubmitModel.Uuid}."); Assert.True(function.Name == functionSubmitModel.Name, $"Retrieved Name {function.Name} not the same as sample Name {functionSubmitModel.Name}."); Assert.True(function.Description == functionSubmitModel.Description, $"Retrieved Description {function.Description} not the same as sample Description {functionSubmitModel.Description}."); Assert.True(function.ApplicationId == functionSubmitModel.ApplicationId, $"Retrieved ApplicationId {function.ApplicationId} not the same as sample ApplicationId {functionSubmitModel.ApplicationId}."); Assert.True(function.Permissions[0].Uuid == functionSubmitModel.Permissions[0], $"Retrieved Permissions id {function.Permissions[0].Uuid} not the same as sample Permissions id {functionSubmitModel.Permissions[0]}."); Assert.True(function.Permissions[1].Uuid == functionSubmitModel.Permissions[1], $"Retrieved Permissions id {function.Permissions[1].Uuid} not the same as sample Permissions id {functionSubmitModel.Permissions[1]}."); }
public async Task UpdateFunctionAsync_WithRandomGuid_ReturnsNotImplemented() { // Arrange var controller = new FunctionController(functionService, orderByHelper, paginationHelper, mapper); // Act IActionResult actionResult = await controller.UpdateFunctionAsync(Guid.NewGuid(), new FunctionSubmit()); // Assert var badRequestResult = actionResult as BadRequestResult; Assert.NotNull(badRequestResult); }
public async Task UpdateFunctionAsync_WithBlankGuid_ReturnsNotImplemented() { // Arrange var controller = new FunctionController(functionService, orderByHelper, paginationHelper, mapper); functionService.UpdateAsync(functionSubmitModel, Arg.Any <Guid>()) .Returns(functionModel); // Act IActionResult actionResult = await controller.UpdateFunctionAsync(Guid.Empty, functionSubmitModel); // Assert var badRequestResult = actionResult as BadRequestResult; Assert.NotNull(badRequestResult); }
public async Task UpdateFunctionAsync_WithRandomGuid_ReturnsNotImplemented() { // Arrange var functionService = Substitute.For <IFunctionService>(); var controller = new FunctionController(functionService); // Act Exception exAssert = null; try { IActionResult actionResult = await controller.UpdateFunctionAsync(new Guid(), null); } catch (Exception ex) { exAssert = ex; } // Assert Assert.False(exAssert is NotImplementedException, $"Updating record should NOT return NotImplementedException"); }