public async Task PutHomework_BadRequest() { var response = await HomeworkController.Put(null); var code = (StatusCodeResult)response.Result; Assert.AreEqual((int)HttpStatusCode.BadRequest, code.StatusCode); }
public async Task PutHomework_ValidCall() { var response = await HomeworkController.Put(ViewModel().Result); var code = ((ObjectResult)response.Result).StatusCode; Assert.AreEqual((int)HttpStatusCode.OK, code); }
public async Task PutHomework_NotFound() { Mock.Setup(service => service.Find(It.IsAny <Func <Homework, bool> >())) .Returns(PutNotFoundTest()); var response = await HomeworkController.Put(ViewModel().Result); var code = (StatusCodeResult)response.Result; Assert.AreEqual((int)HttpStatusCode.NotFound, code.StatusCode); }
public JsonResult UpdateHomework(FormCollection collection) { HomeworkController obj = new HomeworkController(); var homework = collection["Homework"]; tbl_homework Homework = JsonConvert.DeserializeObject <tbl_homework>(homework); var files = System.Web.HttpContext.Current.Request.Files; if (files.Count > 0) { using (var binaryReader = new BinaryReader(files[0].InputStream)) { Homework.name = files[0].FileName; Homework.contenttype = files[0].ContentType; Homework.data = binaryReader.ReadBytes(files[0].ContentLength); } } var response = obj.Put(Homework.id, Homework); return(Json(response, JsonRequestBehavior.AllowGet)); }