Example #1
0
        public void ShouldUpdateDocument()
        {
            var testDocument = MakeNew(2);
            var response     = _docsController.Create(testDocument);
            var result       = Assert.IsType <OkObjectResult>(response.Result);

            Assert.NotNull(result.Value);
            var newDocument = Assert.IsType <Document>(result.Value);

            Assert.Null(newDocument.UpdateTime);

            newDocument.Title  = "Updated document title";
            newDocument.Author = "Updated author";
            response           = _docsController.Update(newDocument);
            result             = Assert.IsType <OkObjectResult>(response.Result);
            Assert.NotNull(result.Value);
            var updatedDocument = Assert.IsType <Document>(result.Value);

            Assert.NotNull(updatedDocument.UpdateTime);
            Assert.Equal(newDocument.Id, updatedDocument.Id);
            Assert.Equal(newDocument.Title, updatedDocument.Title);
            Assert.Equal(newDocument.Author, updatedDocument.Author);
        }