Exemplo n.º 1
0
        public void PutReturnsDocument()
        {
            //Arrange
            var moq = new Mock <IDocumentsRepository>();

            moq.Setup(m => m.Put(It.IsAny <Document>())).Returns <Document>(d => Task.FromResult(d));
            moq.Setup(m => m.Exists(It.IsAny <object[]>())).Returns(Task.FromResult(true));
            DocumentsController controller = new DocumentsController(moq.Object);

            //Act
            var result = (controller.Put(0, new Document()).Result as OkObjectResult).Value;

            //Assert
            Assert.IsInstanceOfType(result, typeof(Document));
        }