public void Createstage_Invalid_BookIdOrStageName_ReturnsBadRequest() { // Arrange Stage stage = new Stage { BookId = 1, StageId = 3, Description = "desc", EnvId = 2, StageName = null, StatusId = 2 }; int bookId = 0; // Act var controller = new StageController(logger.Object, stageServiceMoq.Object); var response = controller.CreateStage(stage, bookId) as BadRequestObjectResult; // Assert Assert.IsType <BadRequestObjectResult>(response); Assert.Equal("Invalid BookId or Stage Name", response.Value); }
public void CreateStage_UnSuccessfull() { Stage stage = new Stage { BookId = 1, StageId = 3, Description = "desc", EnvId = 2, StageName = "prod", StatusId = 2 }; int bookId = 1; stageServiceMoq.Setup(c => c.CreateStage(stage, bookId)).Returns(false); // Act var controller = new StageController(logger.Object, stageServiceMoq.Object); var response = controller.CreateStage(stage, bookId) as OkObjectResult; // Assert Assert.IsType <OkObjectResult>(response); Assert.Equal("Unsuccessful while creating stage", response.Value); stageServiceMoq.Verify(c => c.CreateStage(stage, bookId), Times.Once); }