public void PostQuestion_Negative_ReturnsBadRequest() { var dataRepo = new Mock <IDatabaseRepository>(); Question question = null; dataRepo.Setup(d => d.PostToTopic(question)).Returns(question); SMEController sMEController = new SMEController(dataRepo.Object); var actionResult = sMEController.Post(question); Assert.IsType <BadRequestObjectResult>(actionResult); }
public void PostTechnology_Negative_ReturnsBadRequest() { var dataRepo = new Mock <IDatabaseRepository>(); Technology technology = null; dataRepo.Setup(d => d.PostToTechnology(technology)).Returns(technology); SMEController sMEController = new SMEController(dataRepo.Object); var actionResult = sMEController.Post(technology); Assert.IsType <BadRequestObjectResult>(actionResult); }
public void PostQuestion_Positive_ReturnsCreatedObject() { var dataRepo = new Mock <IDatabaseRepository>(); Question question = new Question(); dataRepo.Setup(d => d.PostToTopic(question)).Returns(question); SMEController sMEController = new SMEController(dataRepo.Object); var actionResult = sMEController.Post(question); Assert.NotNull(actionResult); var createdResult = actionResult as CreatedResult; Assert.NotNull(createdResult); var model = createdResult.Value as Question; Assert.NotNull(model); }
public void PostTechnology_Positive_ReturnsCreatedObject() { var dataRepo = new Mock <IDatabaseRepository>(); Technology technology = new Technology { Name = "Java", Topics = new List <Topic>() }; dataRepo.Setup(d => d.PostToTechnology(technology)).Returns(technology); SMEController sMEController = new SMEController(dataRepo.Object); var actionResult = sMEController.Post(technology); Assert.NotNull(actionResult); var createdResult = actionResult as CreatedResult; Assert.NotNull(createdResult); var model = createdResult.Value as Technology; Assert.NotNull(model); }