public void Put() { var session_id = "ffffessl2"; int[] id = { 1, 4, 0x7fffffff }; string[] pos = { "left", "right" }; var putdata = new DiffController.PutData { data = "AAAAAA==" }; controller.Request.Headers.Add("cookie", "session-id=" + session_id); AddFakeDataToController(session_id, 0, null, null); //PUT /v1/diff/left/1 with "AAAAAA==" for (int i = 0; i < id.Length; i++) { for (int j = 0; j < pos.Length; j++) { var response = controller.Put(id[i], pos[j], putdata); Assert.AreEqual(response.StatusCode, HttpStatusCode.Created); //Verify data is stored in b64data var key_left = new Tuple <int, string>(id[i], pos[j]); Assert.IsTrue(DiffController.g_data[session_id][key_left].SequenceEqual(Convert.FromBase64String(putdata.data))); } } }
public async Task DiffControllerValidatesInput() { // arrange _target.ModelState.AddModelError("error", "error"); // act var result = await _target.Put(1, Side.Left, new DiffRequest { Data = string.Empty }); // assert Assert.True(result is BadRequestObjectResult); }