public async Task GetFunctionAsync_WithTestGuid_ReturnsCorrectResult() { // Arrange var functionService = Substitute.For <IFunctionService>(); var testGuid = Guid.NewGuid(); var testName = "TestUserName"; functionService.GetByIdAsync(testGuid).Returns(new Function { Uuid = testGuid, Name = testName }); var controller = new FunctionController(functionService, orderByHelper, paginationHelper, mapper); // Act IActionResult actionResult = await controller.GetFunctionAsync(testGuid); // Assert var okResult = actionResult as OkObjectResult; Assert.NotNull(okResult); var function = okResult.Value as Function; Assert.NotNull(function); Assert.True(function.Uuid == testGuid, $"Retrieved Id {function.Uuid} not the same as sample id {testGuid}."); Assert.True(function.Name == testName, $"Retrieved Name {function.Name} not the same as sample id {testName}."); }
public async Task GetFunctionAsync_WithRandomGuid_ReturnsNotFoundResult() { // Arrange var controller = new FunctionController(functionService, orderByHelper, paginationHelper, mapper); // Act var result = await controller.GetFunctionAsync(Guid.NewGuid()); // Assert Assert.IsType <NotFoundResult>(result); }
public async Task GetFunctionAsync_WithRandomGuid_ReturnsNotFoundResult() { // Arrange var functionService = Substitute.For <IFunctionService>(); var controller = new FunctionController(functionService); // Act var result = await controller.GetFunctionAsync(Guid.NewGuid()); // Assert Assert.IsType <NotFoundResult>(result); }
public async Task GetFunctionAsync_WithEmptyGuid_ReturnsBadRequest() { // Arrange var controller = new FunctionController(functionService, orderByHelper, paginationHelper, mapper); // Act var result = await controller.GetFunctionAsync(Guid.Empty); // Assert var badRequestResult = result as BadRequestResult; Assert.NotNull(badRequestResult); }
public async Task GetFunctionAsync_WithEmptyGuid_ReturnsBadRequest() { // Arrange var functionService = Substitute.For <IFunctionService>(); var controller = new FunctionController(functionService); // Act var result = await controller.GetFunctionAsync(Guid.Empty); // Assert var badRequestResult = result as BadRequestResult; Assert.NotNull(badRequestResult); }