public void LocalFileIsUsedByAnotherProcess() { string fileName = "fileName"; string fileId = "fileId"; string parentId = "parentId"; string lastChangeToken = "token"; bool extendedAttributes = true; Exception exception = new ExtendedAttributeException(); Mock <IFileInfo> fileInfo = new Mock <IFileInfo>(); fileInfo.Setup(f => f.Length).Returns(0); fileInfo.Setup(f => f.SetExtendedAttribute(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>())).Throws(exception); try { Mock <IDocument> document; this.RunSolveFile(fileName, fileId, parentId, lastChangeToken, extendedAttributes, fileInfo, out document); } catch (RetryException e) { Assert.That(e.InnerException, Is.EqualTo(exception)); fileInfo.Verify(d => d.SetExtendedAttribute(It.IsAny <string>(), It.IsAny <string>(), true), Times.Once()); this.storage.Verify(s => s.SaveMappedObject(It.IsAny <IMappedObject>()), Times.Never()); this.queue.Verify(q => q.AddEvent(It.IsAny <FileTransmissionEvent>()), Times.Never()); fileInfo.VerifyThatLocalFileObjectLastWriteTimeUtcIsNeverModified(); throw; } }
public void LocalFileIsUsedByAnotherProcess() { this.SetUpMocks(true); var exception = new ExtendedAttributeException(); Mock <IFileInfo> fileInfo = new Mock <IFileInfo>(); fileInfo.Setup(f => f.Length).Returns(0); fileInfo.SetupSet(f => f.Uuid = It.IsAny <Guid?>()).Throws(exception); Mock <IDocument> document; this.SetupSolveFile(this.localObjectName, this.remoteObjectId, this.parentId, this.lastChangeToken, this.withExtendedAttributes, fileInfo, out document); var e = Assert.Throws <RetryException>(() => this.RunSolveFile(fileInfo)); Assert.That(e.InnerException, Is.EqualTo(exception)); fileInfo.VerifySet(f => f.Uuid = It.Is <Guid?>(uuid => uuid != null), Times.Once()); this.storage.Verify(s => s.SaveMappedObject(It.IsAny <IMappedObject>()), Times.Never()); fileInfo.VerifyThatLocalFileObjectLastWriteTimeUtcIsNeverModified(); }