示例#1
0
        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);
        }
示例#2
0
        public void GetNotExisiting_ShouldReturn404()
        {
            var controller = new DocsController(new DocumentContext());
            var result     = (StatusCodeResult)controller.Get(9);

            Assert.Equal(404, result.StatusCode);
        }
示例#3
0
        public void GetAll_ShouldReturnNoContentResult()
        {
            var controller = new DocsController(new DocumentContext());
            var result     = (ObjectResult)controller.Get();

            Assert.Equal(0, result.Value);
        }
示例#4
0
        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);
        }
示例#5
0
        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);
        }