public void AddDocumentTest() { Mock<IRepository> repositoryMock = new Mock<IRepository>(); Mock<IDocumentStorage> storageMock = new Mock<IDocumentStorage>(); string tagToAdd = "Tag"; Document documentToAdd = new Document() { Imported = new DateTime(2013, 3, 20), Name = "DocumentName", DateReceived = new DateTime(2012, 1, 13), Path = "DocumentPath", Tags = new List<string>() { tagToAdd } }; IDocumentService documentService = new DocumentService(repositoryMock.Object, storageMock.Object); documentService.AddDocument(documentToAdd); repositoryMock.Verify(x => x.Add(documentToAdd)); }
public void GetDocumentByIdTest() { Mock<IRepository> repositoryMock = new Mock<IRepository>(); Mock<IDocumentStorage> storageMock = new Mock<IDocumentStorage>(); string tagToAdd = "Tag"; Document documentToFind = new Document() { Id = "ID", Imported = new DateTime(2013, 3, 20), Name = "DocumentName", DateReceived = new DateTime(2012, 1, 13), Path = "DocumentPath", Tags = new List<string>() { tagToAdd } }; repositoryMock.Setup(x => x.Single<Document>(It.IsAny<Expression<Func<Document, bool>>>())); IDocumentService documentService = new DocumentService(repositoryMock.Object, storageMock.Object); documentService.GetDocumentById(documentToFind.Id); repositoryMock.Verify(x => x.Single<Document>(It.IsAny<Expression<Func<Document, bool>>>())); }