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


C# Mock.SetupGuid方法代码示例

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


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

示例1: RemoteFolderDeletedButNotAllContainingFilesAreSyncedYet

        public void RemoteFolderDeletedButNotAllContainingFilesAreSyncedYet() {
            this.SetUpTestMocks();
            string fileName = "fileName";
            string filePath = Path.Combine(this.path, fileName);
            string syncedFileName = "syncedFileName";
            string syncedFilePath = Path.Combine(this.path, syncedFileName);
            DateTime lastModified = DateTime.UtcNow;
            Guid syncedFileGuid = Guid.NewGuid();
            Mock<IMappedObject> folder = this.storage.AddLocalFolder(this.path, "id");
            var dirInfo = new Mock<IDirectoryInfo>();
            dirInfo.Setup(d => d.FullName).Returns(this.path);
            var fileInfo = new Mock<IFileInfo>();
            fileInfo.Setup(f => f.FullName).Returns(filePath);
            fileInfo.Setup(f => f.Name).Returns(fileName);
            var syncedFileInfo = new Mock<IFileInfo>();
            syncedFileInfo.Setup(s => s.FullName).Returns(syncedFilePath);
            syncedFileInfo.Setup(s => s.Name).Returns(syncedFileName);
            syncedFileInfo.SetupGuid(syncedFileGuid);
            syncedFileInfo.Setup(s => s.LastWriteTimeUtc).Returns(lastModified);
            dirInfo.SetupFiles(fileInfo.Object, syncedFileInfo.Object);
            var mappedSyncedFile = new MappedObject(syncedFileName, "id", MappedObjectType.File, "parentId", "changeToken", 0) { Guid = syncedFileGuid, LastLocalWriteTimeUtc = lastModified };
            this.storage.AddMappedFile(mappedSyncedFile, syncedFilePath);

            Assert.Throws<IOException>(() => this.underTest.Solve(dirInfo.Object, null));

            dirInfo.Verify(d => d.Delete(true), Times.Never());
            syncedFileInfo.Verify(s => s.Delete(), Times.Once());
            fileInfo.Verify(f => f.Delete(), Times.Never());
            this.storage.Verify(s => s.RemoveObject(It.Is<IMappedObject>(o => o == folder.Object)), Times.Once());
        }
开发者ID:OpenDataSpace,项目名称:CmisSync,代码行数:30,代码来源:RemoteObjectDeletedTest.cs

示例2: RunSolveFolder

        private Mock<IDirectoryInfo> RunSolveFolder(
            string folderName,
            string id,
            string parentId,
            string lastChangeToken,
            bool extendedAttributes,
            out Mock<IFolder> folderMock,
            Guid? existingGuid = null,
                TransmissionManager transmissionManager = null)
        {
            string path = Path.Combine(Path.GetTempPath(), folderName);
            var futureRemoteFolder = Mock.Of<IFolder>(
                f =>
                f.Name == folderName &&
                f.Id == id &&
                f.ParentId == parentId &&
                f.ChangeToken == lastChangeToken);
            var futureRemoteFolderId = Mock.Of<IObjectId>(
                o =>
                o.Id == id);

            this.session.Setup(s => s.CreateFolder(It.Is<IDictionary<string, object>>(p => (string)p["cmis:name"] == folderName), It.Is<IObjectId>(o => o.Id == parentId))).Returns(futureRemoteFolderId);
            this.session.Setup(s => s.GetObject(It.Is<IObjectId>(o => o == futureRemoteFolderId), It.IsAny<IOperationContext>())).Returns(futureRemoteFolder);

            var dirInfo = new Mock<IDirectoryInfo>();
            dirInfo.Setup(d => d.FullName).Returns(path);
            dirInfo.Setup(d => d.Name).Returns(folderName);
            dirInfo.Setup(d => d.Exists).Returns(true);
            dirInfo.Setup(d => d.IsExtendedAttributeAvailable()).Returns(extendedAttributes);
            if (existingGuid != null) {
                dirInfo.SetupGuid((Guid)existingGuid);
            }

            var parentDirInfo = this.SetupParentFolder(parentId);
            dirInfo.Setup(d => d.Parent).Returns(parentDirInfo);
            if (transmissionManager == null) {
                transmissionManager = new TransmissionManager();
            }

            var solver = new LocalObjectAdded(this.session.Object, this.storage.Object, this.transmissionStorage.Object, transmissionManager);

            solver.Solve(dirInfo.Object, null);

            folderMock = Mock.Get(futureRemoteFolder);
            return dirInfo;
        }
开发者ID:OpenDataSpace,项目名称:CmisSync,代码行数:46,代码来源:LocalObjectAddedTest.cs

示例3: LocalEmptyFileAdded

        public void LocalEmptyFileAdded(bool withExtendedAttributes, bool withAlreadySetUuid) {
            this.SetUpMocks(withExtendedAttributes);
            Guid uuid = Guid.NewGuid();
            Mock<IFileInfo> fileInfo = new Mock<IFileInfo>();
            fileInfo.Setup(f => f.Length).Returns(0);
            if (withAlreadySetUuid) {
                fileInfo.SetupGuid(uuid);
            }

            Mock<IDocument> document;

            this.SetupSolveFile(this.localObjectName, this.remoteObjectId, this.parentId, this.lastChangeToken, this.withExtendedAttributes, fileInfo, out document);
            this.RunSolveFile(fileInfo);

            this.storage.VerifySavedMappedObject(MappedObjectType.File, this.remoteObjectId, this.localObjectName, this.parentId, this.lastChangeToken, this.withExtendedAttributes, checksum: this.emptyhash, contentSize: 0);
            if (withAlreadySetUuid) {
                this.storage.Verify(s => s.SaveMappedObject(It.Is<IMappedObject>(o => o.Guid == uuid)));
            }

            this.VerifyCreateDocument(isEmpty: true);
            if (this.withExtendedAttributes && !withAlreadySetUuid) {
                fileInfo.VerifySet(f => f.Uuid = It.Is<Guid?>(u => u != null), Times.Once());
            } else {
                fileInfo.VerifySet(f => f.Uuid = It.IsAny<Guid?>(), Times.Never());
            }

            fileInfo.VerifyThatLocalFileObjectLastWriteTimeUtcIsNeverModified();
            document.Verify(d => d.AppendContentStream(It.IsAny<IContentStream>(), It.IsAny<bool>(), It.IsAny<bool>()), Times.Never());
        }
开发者ID:OpenDataSpace,项目名称:CmisSync,代码行数:29,代码来源:LocalObjectAddedTest.cs

示例4: CreateTreeFromPathAndGuid

 private ObjectTree<IFileSystemInfo> CreateTreeFromPathAndGuid(string name, string path, Guid guid) {
     var localTree = new ObjectTree<IFileSystemInfo>();
     var fsInfo = new Mock<IDirectoryInfo>();
     fsInfo.SetupGuid(guid);
     fsInfo.Setup(f => f.FullName).Returns(path);
     fsInfo.Setup(f => f.Name).Returns(name);
     fsInfo.Setup(f => f.LastWriteTimeUtc).Returns(zeroDate);
     localTree.Item = fsInfo.Object;
     localTree.Children = new List<IObjectTree<IFileSystemInfo>>();
     return localTree;
 }
开发者ID:OpenDataSpace,项目名称:CmisSync,代码行数:11,代码来源:LocalEventGeneratorTest.cs

示例5: CreateLocalFile

 private Mock<IFileInfo> CreateLocalFile(long? fileLength = 20, DateTime? lastModification = null, bool exists = true) {
     var localFile = new Mock<IFileInfo>();
     localFile.SetupProperty(f => f.LastWriteTimeUtc, lastModification ?? DateTime.UtcNow);
     localFile.Setup(f => f.Length).Returns(fileLength ?? 20);
     localFile.Setup(f => f.FullName).Returns(this.localPath);
     localFile.SetupGuid(this.uuid);
     localFile.Setup(f => f.Exists).Returns(exists);
     return localFile;
 }
开发者ID:OpenDataSpace,项目名称:CmisSync,代码行数:9,代码来源:LocalObjectChangedTest.cs

示例6: CreateLocalDirectory

 private Mock<IDirectoryInfo> CreateLocalDirectory(DateTime modificationDate) {
     var localDirectory = new Mock<IDirectoryInfo>();
     localDirectory.Setup(f => f.LastWriteTimeUtc).Returns(modificationDate.AddMinutes(1));
     localDirectory.Setup(f => f.Exists).Returns(true);
     localDirectory.SetupGuid(this.uuid);
     return localDirectory;
 }
开发者ID:OpenDataSpace,项目名称:CmisSync,代码行数:7,代码来源:LocalObjectChangedTest.cs


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