Exemple #1
0
        public void TestGetDocumentByIdWorksOnExistingDocument()
        {
            Mock <IUserRepository>     mockUserRepository     = new Mock <IUserRepository>();
            Mock <IDocumentRepository> mockDocumentRepository = new Mock <IDocumentRepository>();
            IDocumentManagementService documentLogic          = new DocumentManagementService()
            {
                UserRepository     = mockUserRepository.Object,
                DocumentRepository = mockDocumentRepository.Object
            };
            Guid     fakeId       = Guid.NewGuid();
            Document fakeDocument = new Document
            {
                Id         = fakeId,
                Creator    = GetFakeUser(),
                StyleClass = new StyleClass()
            };

            mockDocumentRepository
            .Setup(wl => wl.Exists(fakeId))
            .Returns(true);
            mockDocumentRepository
            .Setup(wl => wl.GetById(fakeId))
            .Returns(fakeDocument);

            Document result = documentLogic.GetById(fakeId);

            mockDocumentRepository.VerifyAll();
            Assert.IsNotNull(result);
            Assert.AreEqual(fakeDocument, result);
        }
Exemple #2
0
        public void TestGetDocumentByIdFailsOnMissingDocument()
        {
            Mock <IUserRepository>     mockUserRepository     = new Mock <IUserRepository>();
            Mock <IDocumentRepository> mockDocumentRepository = new Mock <IDocumentRepository>();
            IDocumentManagementService documentLogic          = new DocumentManagementService()
            {
                UserRepository     = mockUserRepository.Object,
                DocumentRepository = mockDocumentRepository.Object
            };
            Guid     fakeId       = Guid.NewGuid();
            Document fakeDocument = new Document
            {
                Id         = fakeId,
                Creator    = GetFakeUser(),
                StyleClass = new StyleClass()
            };

            mockDocumentRepository
            .Setup(wl => wl.Exists(fakeId))
            .Returns(false);

            Document result = documentLogic.GetById(fakeId);

            mockDocumentRepository.VerifyAll();
        }