public void Delete_CreatedDocument() { var controller = new DocsController(new DocumentContext()); ContentResult result = (ContentResult)controller.Create(new Document(postBase64)); //Gets id from the newly created document int id = int.Parse(result.Content); //Checks if the document was added var getResult1 = (ObjectResult)controller.Get(); Assert.Equal(1, getResult1.Value); //Check swagger compliance var msg = (NoContentResult)controller.Delete(id); Assert.Equal(204, msg.StatusCode); //Checks if the document was removed var getResult0 = (ObjectResult)controller.Get(); Assert.Equal(0, getResult0.Value); }
public void GetNotExisiting_ShouldReturn404() { var controller = new DocsController(new DocumentContext()); var result = (StatusCodeResult)controller.Get(9); Assert.Equal(404, result.StatusCode); }
public void GetAll_ShouldReturnNoContentResult() { var controller = new DocsController(new DocumentContext()); var result = (ObjectResult)controller.Get(); Assert.Equal(0, result.Value); }
public void PostInvalid_ShouldReturn501() { var controller = new DocsController(new DocumentContext()); ContentResult result = (ContentResult)controller.Create(new Document("asd")); var id = int.Parse(result.Content); Thread.Sleep(2000); var getResult = (StatusCodeResult)controller.Get(id); Assert.Equal(501, getResult.StatusCode); }
public void Post_ShouldCreateDocument() { var controller = new DocsController(new DocumentContext()); ContentResult result = (ContentResult)controller.Create(new Document(postBase64)); //Gets id from the newly created document var id = int.Parse(result.Content); //Sleep while another thread is doing the work Thread.Sleep(10000); //Gets content of Get Response var content = (ObjectResult)controller.Get(id); var document = (Document)content.Value; //Assure the base64 content was correct transfered Assert.Equal(document.Content, postBase64); }