当前位置: 首页>>代码示例>>C#>>正文


C# Mock.SetupSessionDefaultValues方法代码示例

本文整理汇总了C#中Mock.SetupSessionDefaultValues方法的典型用法代码示例。如果您正苦于以下问题:C# Mock.SetupSessionDefaultValues方法的具体用法?C# Mock.SetupSessionDefaultValues怎么用?C# Mock.SetupSessionDefaultValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mock的用法示例。


在下文中一共展示了Mock.SetupSessionDefaultValues方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DoNotFetchIfExtendedAttributeIsMissing

        public void DoNotFetchIfExtendedAttributeIsMissing() {
            var session = new Mock<ISession>();
            session.SetupSessionDefaultValues();
            IDocument remote = MockOfIDocumentUtil.CreateRemoteDocumentMock(null, Id, "name", (string)null).Object;
            session.Setup(s => s.GetObject(Id, It.IsAny<IOperationContext>())).Returns(remote);

            var storage = new Mock<IMetaDataStorage>();
            storage.AddLocalFile(Path, Id, Uuid);

            var fileEvent = new FileEvent(Mock.Of<IFileInfo>());
            var fetcher = new RemoteObjectFetcher(session.Object, storage.Object);
            fetcher.Handle(fileEvent);

            session.Verify(s => s.GetObject(It.IsAny<string>(), It.IsAny<IOperationContext>()), Times.Never());
        }
开发者ID:OpenDataSpace,项目名称:CmisSync,代码行数:15,代码来源:RemoteObjectFetcherTest.cs

示例2: ExecuteCrawlSyncOnNoLocalTokenAvailable

        public void ExecuteCrawlSyncOnNoLocalTokenAvailable() {
            var startSyncEvent = new StartNextSyncEvent(false);
            var session = new Mock<ISession>();
            session.SetupSessionDefaultValues();
            session.Setup(s => s.Binding.GetRepositoryService().GetRepositoryInfo(this.repoId, null).LatestChangeLogToken).Returns(this.changeLogToken);
            var storage = new Mock<IMetaDataStorage>();
            storage.Setup(db => db.ChangeLogToken).Returns((string)null);
            var queue = new Mock<ISyncEventQueue>();
            var changes = new ContentChanges(session.Object, storage.Object, queue.Object);

            Assert.IsTrue(changes.Handle(startSyncEvent));
            queue.Verify(q => q.AddEvent(It.Is<StartNextSyncEvent>(e => e.FullSyncRequested == true)), Times.Once());
        }
开发者ID:OpenDataSpace,项目名称:CmisSync,代码行数:13,代码来源:ContentChangesTest.cs

示例3: HandleStartSyncEventOnNoRemoteChange

 public void HandleStartSyncEventOnNoRemoteChange() {
     var startSyncEvent = new StartNextSyncEvent(false);
     var session = new Mock<ISession>();
     session.SetupSessionDefaultValues();
     session.Setup(s => s.Binding.GetRepositoryService().GetRepositoryInfo(this.repoId, null).LatestChangeLogToken).Returns(this.changeLogToken);
     var storage = new Mock<IMetaDataStorage>();
     storage.Setup(db => db.ChangeLogToken).Returns(this.changeLogToken);
     var queue = new Mock<ISyncEventQueue>();
     var changes = new ContentChanges(session.Object, storage.Object, queue.Object);
     Assert.IsTrue(changes.Handle(startSyncEvent));
 }
开发者ID:OpenDataSpace,项目名称:CmisSync,代码行数:11,代码来源:ContentChangesTest.cs

示例4: OperationContextDoesNotUsesTheSessionCache

        public void OperationContextDoesNotUsesTheSessionCache() {
            var session = new Mock<ISession>();
            session.SetupSessionDefaultValues();
            IFolder remote = MockOfIFolderUtil.CreateRemoteFolderMock(Id, "name", "/name").Object;
            session.Setup(s => s.GetObject(Id, It.IsAny<IOperationContext>())).Returns(remote);

            var storage = new Mock<IMetaDataStorage>();
            storage.AddLocalFolder(Path, Id, Uuid);

            var dirMock = new Mock<IDirectoryInfo>();
            dirMock.Setup(d => d.Exists).Returns(true);
            dirMock.Setup(d => d.GetExtendedAttribute(MappedObject.ExtendedAttributeKey)).Returns(Uuid.ToString());
            var folderEvent = new FolderEvent(dirMock.Object);
            var fetcher = new RemoteObjectFetcher(session.Object, storage.Object);

            Assert.That(fetcher.Handle(folderEvent), Is.False);
            session.VerifyThatCachingIsDisabled();
        }
开发者ID:OpenDataSpace,项目名称:CmisSync,代码行数:18,代码来源:RemoteObjectFetcherTest.cs

示例5: FolderEventForRemovedFolder

        public void FolderEventForRemovedFolder() {
            var session = new Mock<ISession>();
            session.SetupSessionDefaultValues();
            session.Setup(s => s.GetObject(Id, It.IsAny<IOperationContext>())).Throws(new CmisObjectNotFoundException());

            var storage = new Mock<IMetaDataStorage>();
            storage.AddLocalFolder(Path, Id);

            var dirMock = new Mock<IDirectoryInfo>();
            dirMock.Setup(d => d.GetExtendedAttribute(MappedObject.ExtendedAttributeKey)).Returns(Uuid.ToString());

            var folderEvent = new FolderEvent(dirMock.Object);

            var fetcher = new RemoteObjectFetcher(session.Object, storage.Object);
            Assert.That(fetcher.Handle(folderEvent), Is.False);
            Assert.That(folderEvent.RemoteFolder, Is.Null);
        }
开发者ID:OpenDataSpace,项目名称:CmisSync,代码行数:17,代码来源:RemoteObjectFetcherTest.cs

示例6: CrawlRequestedEventWithNewRemoteFolder

        public void CrawlRequestedEventWithNewRemoteFolder() {
            var session = new Mock<ISession>();
            session.SetupSessionDefaultValues();
            IFolder remote = MockOfIFolderUtil.CreateRemoteFolderMock(Id, "name", "/name").Object;
            session.Setup(s => s.GetObject(Id, It.IsAny<IOperationContext>())).Returns(remote);

            var storage = new Mock<IMetaDataStorage>();
            storage.AddLocalFolder(Path, Id, Uuid);

            var dirMock = new Mock<IDirectoryInfo>();
            dirMock.Setup(d => d.Exists).Returns(true);
            dirMock.Setup(d => d.Uuid).Returns(Uuid);
            var crawlEvent = new CrawlRequestEvent(localFolder: dirMock.Object, remoteFolder: null);

            var fetcher = new RemoteObjectFetcher(session.Object, storage.Object);
            Assert.That(fetcher.Handle(crawlEvent), Is.False);
            Assert.That(crawlEvent.RemoteFolder, Is.EqualTo(remote));
        }
开发者ID:OpenDataSpace,项目名称:CmisSync,代码行数:18,代码来源:RemoteObjectFetcherTest.cs

示例7: FileEventForRemovedFile

        public void FileEventForRemovedFile() {
            var session = new Mock<ISession>();
            session.SetupSessionDefaultValues();
            session.Setup(s => s.GetObject(Id, It.IsAny<IOperationContext>())).Throws(new CmisObjectNotFoundException());

            var storage = new Mock<IMetaDataStorage>();
            storage.AddLocalFile(Path, Id);

            var fileInfoMock = new Mock<IFileInfo>();
            fileInfoMock.Setup(f => f.GetExtendedAttribute(It.IsAny<string>())).Returns(Uuid.ToString());
            var fileEvent = new FileEvent(fileInfoMock.Object);

            var fetcher = new RemoteObjectFetcher(session.Object, storage.Object);
            Assert.That(fetcher.Handle(fileEvent), Is.False);
            Assert.That(fileEvent.RemoteFile, Is.Null);
        }
开发者ID:OpenDataSpace,项目名称:CmisSync,代码行数:16,代码来源:RemoteObjectFetcherTest.cs

示例8: FolderEventWithoutObjectIdAndExtendedAttributeExceptionOnUuidRequest

        public void FolderEventWithoutObjectIdAndExtendedAttributeExceptionOnUuidRequest() {
            var session = new Mock<ISession>();
            session.SetupSessionDefaultValues();
            IFolder remote = MockOfIFolderUtil.CreateRemoteFolderMock(Id, "name", "/name").Object;
            session.Setup(s => s.GetObject(Id, It.IsAny<IOperationContext>())).Returns(remote);

            var storage = new Mock<IMetaDataStorage>();
            storage.AddLocalFolder(Path, Id, Uuid);

            var dirMock = new Mock<IDirectoryInfo>();
            dirMock.Setup(d => d.Exists).Returns(true);
            dirMock.Setup(d => d.Uuid).Throws<ExtendedAttributeException>();

            var folderEvent = new FolderEvent(dirMock.Object);
            var fetcher = new RemoteObjectFetcher(session.Object, storage.Object);

            Assert.That(fetcher.Handle(folderEvent), Is.False);
            Assert.That(folderEvent.RemoteFolder, Is.Null);
        }
开发者ID:OpenDataSpace,项目名称:CmisSync,代码行数:19,代码来源:RemoteObjectFetcherTest.cs

示例9: FileEventWithoutObjectId

        public void FileEventWithoutObjectId() {
            var session = new Mock<ISession>();
            session.SetupSessionDefaultValues();
            IDocument remote = MockOfIDocumentUtil.CreateRemoteDocumentMock(null, Id, "name", (string)null).Object;
            session.Setup(s => s.GetObject(Id, It.IsAny<IOperationContext>())).Returns(remote);

            var storage = new Mock<IMetaDataStorage>();
            storage.AddLocalFile(Path, Id, Uuid);

            var fileInfoMock = new Mock<IFileInfo>();
            fileInfoMock.Setup(f => f.Uuid).Returns(Uuid);
            fileInfoMock.Setup(f => f.Exists).Returns(true);
            var fileEvent = new FileEvent(fileInfoMock.Object);
            var fetcher = new RemoteObjectFetcher(session.Object, storage.Object);

            Assert.That(fetcher.Handle(fileEvent), Is.False);
            Assert.That(fileEvent.RemoteFile, Is.Not.Null);
        }
开发者ID:OpenDataSpace,项目名称:CmisSync,代码行数:18,代码来源:RemoteObjectFetcherTest.cs

示例10: GetSessionMockReturning3Changesin2Batches

        public static Mock<ISession> GetSessionMockReturning3Changesin2Batches(DotCMIS.Enums.ChangeType type = DotCMIS.Enums.ChangeType.Updated, bool overlapping = false) {
            var changeEvents = new Mock<IChangeEvents>();
            changeEvents.Setup(ce => ce.HasMoreItems).ReturnsInOrder((bool?)true, (bool?)false);
            changeEvents.Setup(ce => ce.LatestChangeLogToken).ReturnsInOrder("A", "B");
            changeEvents.Setup(ce => ce.TotalNumItems).ReturnsInOrder(3, overlapping ? 2 : 1);
            var event1 = MockSessionUtil.GenerateChangeEvent(type, "one");
            var event2 = MockSessionUtil.GenerateChangeEvent(type, "two");
            var event3 = MockSessionUtil.GenerateChangeEvent(type, "three");
            List<IChangeEvent> changeList1 = new List<IChangeEvent>();
            changeList1.Add(event1.Object);
            changeList1.Add(event2.Object);
            List<IChangeEvent> changeList2 = new List<IChangeEvent>();
            if (overlapping) {
                changeList2.Add(event2.Object);
            }

            changeList2.Add(event3.Object);
            changeEvents.Setup(ce => ce.ChangeEventList).ReturnsInOrder(changeList1, changeList2);

            var session = new Mock<ISession>();
            session.SetupSessionDefaultValues();
            session.Setup(s => s.Binding.GetRepositoryService().GetRepositoryInfo(It.IsAny<string>(), null).LatestChangeLogToken).Returns("token");
            session.Setup(s => s.GetContentChanges(It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<long>())).Returns(changeEvents.Object);

            return session;
        }
开发者ID:OpenDataSpace,项目名称:CmisSync,代码行数:26,代码来源:MockSessionUtil.cs

示例11: PrepareSessionMockForSingleChange

        public static Mock<ISession> PrepareSessionMockForSingleChange(DotCMIS.Enums.ChangeType type, string objectId = "objectId", string changeLogToken = "token", string latestChangeLogToken = "latestChangeLogToken") {
            var changeEvents = new Mock<IChangeEvents>();
            var changeList = GenerateSingleChangeListMock(type, objectId); 
            changeEvents.Setup(ce => ce.HasMoreItems).Returns((bool?)false);
            changeEvents.Setup(ce => ce.LatestChangeLogToken).Returns(latestChangeLogToken);
            changeEvents.Setup(ce => ce.TotalNumItems).Returns(1);
            changeEvents.Setup(ce => ce.ChangeEventList).Returns(changeList);

            var session = new Mock<ISession>();
            session.SetupSessionDefaultValues();
            session.SetupChangeLogToken(changeLogToken);
            session.Setup(s => s.GetContentChanges(It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<long>())).Returns(changeEvents.Object);
            return session;
        }
开发者ID:OpenDataSpace,项目名称:CmisSync,代码行数:14,代码来源:MockSessionUtil.cs

示例12: RunFSEventFolderDeleted

        public void RunFSEventFolderDeleted() {
            var storage = this.GetInitializedStorage();
            var path = new Mock<IFileInfo>();
            var name = "a";
            path.Setup(p => p.FullName).Returns(Path.Combine(this.localRoot, name));
            string id = "id";

            var mappedObject = new MappedObject(name, id, MappedObjectType.Folder, null, "changeToken");
            storage.SaveMappedObject(mappedObject);

            var session = new Mock<ISession>();
            session.SetupSessionDefaultValues();
            session.SetupChangeLogToken("default");
            session.SetupTypeSystem();
            IFolder remote = MockOfIFolderUtil.CreateRemoteFolderMock(id, name, (string)null, changetoken: "changeToken").Object;
            session.Setup(s => s.GetObject(id, It.IsAny<IOperationContext>())).Returns(remote);
            var myEvent = new FSEvent(WatcherChangeTypes.Deleted, path.Object.FullName, true);
            var queue = this.CreateQueue(session, storage);
            queue.AddEvent(myEvent);
            queue.Run();

            Mock.Get(remote).Verify(d => d.DeleteTree(false, UnfileObject.DeleteSinglefiled, true), Times.Once());
            Assert.That(storage.GetObjectByRemoteId(id), Is.Null);
        }
开发者ID:OpenDataSpace,项目名称:CmisSync,代码行数:24,代码来源:AllHandlersIT.cs

示例13: RunStartNewSyncEvent

 public void RunStartNewSyncEvent() {
     string rootFolderName = "/";
     string rootFolderId = "root";
     var storage = this.GetInitializedStorage();
     storage.SaveMappedObject(new MappedObject(rootFolderName, rootFolderId, MappedObjectType.Folder, null, "oldtoken"));
     var session = new Mock<ISession>();
     session.SetupSessionDefaultValues();
     session.SetupChangeLogToken("default");
     session.SetupTypeSystem();
     var observer = new ObservableHandler();
     var queue = this.CreateQueue(session, storage, observer);
     queue.RunStartSyncEvent();
     Assert.That(observer.List.Count, Is.EqualTo(1));
     Assert.That(observer.List[0], Is.TypeOf(typeof(FullSyncCompletedEvent)));
 }
开发者ID:OpenDataSpace,项目名称:CmisSync,代码行数:15,代码来源:AllHandlersIT.cs


注:本文中的Mock.SetupSessionDefaultValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。