public void CreateClass_UnderNormalConditions_ReturnsCreatedResponse() { //Arrange var classToCreate = new ClassDto() { ClassDescription = "This is a test class.", ClassId = 5, ClassName = "This is a test class name" }; Mock.Arrange(() => _classService.Create(classToCreate)) .Returns(classToCreate) .OccursOnce(); _classController.Request.RequestUri = new Uri("http://localhost/api/class/create"); //Act var actual = _classController.Post(classToCreate) as CreatedNegotiatedContentResult <ClassDto>; var actualContent = actual.Content; //var actualContent = actual.Content; //Assert Mock.Assert(_classService); Assert.That(actual, Is.TypeOf <CreatedNegotiatedContentResult <ClassDto> >()); Assert.That(actualContent, Is.EqualTo(classToCreate)); }
public void PostClass() { // Arrange ClassController controller = new ClassController(); Class ClassObj = new Class { Name = "Graduation" }; var actResult = controller.Post(ClassObj); // Act var result = actResult as OkNegotiatedContentResult <Class>; // Assert Assert.IsNotNull(result); Assert.IsTrue(result.Content.ID > 0); }