public JsonResult UpdateClass(int CID, Class _Class) { ClassController obj = new ClassController(); var response = obj.Put(CID, _Class); return(Json(response, JsonRequestBehavior.AllowGet)); }
public void PutClass() { // Arrange ClassController controller = new ClassController(); Class ClassObj = new Class { ID = 1, Name = "Put request sucessfull", }; var actResult = controller.Put(1, ClassObj); // Act var result = actResult as OkNegotiatedContentResult <Class>; // Assert Assert.IsNotNull(result); Assert.IsTrue(result.Content.Name.Equals("Put request sucessfull")); }
public void UpdateClass_WhereClassExists_ReturnsOkResponse([Values(1, 2, 3)] int idOfClassToUpdate) { //Arrange var classToBeUpdated = _mockClassList.FirstOrDefault(x => x.ClassId == idOfClassToUpdate); Mock.Arrange(() => _classService.Update(classToBeUpdated)) .Returns(classToBeUpdated) .OccursOnce(); //Act var actual = _classController.Put(classToBeUpdated) as OkNegotiatedContentResult <ClassDto>; var actualContent = actual.Content; //Assert Mock.Assert(_classService); Assert.That(actual, Is.Not.Null); Assert.That(actualContent, Is.EqualTo(classToBeUpdated)); Assert.That(actual, Is.TypeOf <OkNegotiatedContentResult <ClassDto> >()); }