public void ConstructorSetsServerPropertyCorrectly([Values(true, false)]bool serverCanModifyLastModificationDate) {
            var session = new Mock<ISession>();
            session.SetupTypeSystem(serverCanModifyLastModificationDate);
            var underTest = new SolverClass(session.Object, Mock.Of<IMetaDataStorage>());

            Assert.That(underTest.GetModification(), Is.EqualTo(serverCanModifyLastModificationDate));
        }
        public void EnsureLegalCharactersThrowsExceptionIfFilenameContainsUtf8Character() {
            var session = new Mock<ISession>();
            session.SetupTypeSystem();
            var underTest = new SolverClass(session.Object, Mock.Of<IMetaDataStorage>());
            var exception = new CmisConstraintException();
            var fileInfo = Mock.Of<IFileSystemInfo>(f => f.Name == @"ä" && f.FullName == @"ä");

            Assert.Throws<InteractionNeededException>(() => underTest.CallEnsureThatLocalFileNameContainsLegalCharacters(fileInfo, exception));
        }
        public void ConstructorSetsPropertiesCorrectly([Values(true, false)]bool withGivenTransmissionStorage) {
            var session = new Mock<ISession>();
            session.SetupTypeSystem();
            var storage = Mock.Of<IMetaDataStorage>();
            var transmissionStorage = withGivenTransmissionStorage ? Mock.Of<IFileTransmissionStorage>() : null;
            var underTest = new SolverClass(session.Object, storage, transmissionStorage);

            Assert.That(underTest.GetSession(), Is.EqualTo(session.Object));
            Assert.That(underTest.GetStorage(), Is.EqualTo(storage));
            Assert.That(underTest.GetTransmissionStorage(), Is.EqualTo(transmissionStorage));
        }
 public void ConstructorThrowsExceptionIfSolverIsNull() {
     Mock<ISession> session = new Mock<ISession>();
     session.SetupTypeSystem();
     Assert.Throws<ArgumentNullException>(() => new LocalObjectRenamedRemoteObjectChanged(session.Object, Mock.Of<IMetaDataStorage>(), null));
 }
        public void UploadFileClosesTransmissionOnIOException() {
            var session = new Mock<ISession>();
            session.SetupTypeSystem();

            var underTest = new SolverClass(session.Object, Mock.Of<IMetaDataStorage>());

            underTest.Upload(null, null, null);
            Assert.Fail("TODO");
        }
        public void EnsureLegalCharactersIfFilenameIsValid() {
            var session = new Mock<ISession>();
            session.SetupTypeSystem();
            var underTest = new SolverClass(session.Object, Mock.Of<IMetaDataStorage>());
            var exception = new CmisConstraintException();
            var fileInfo = Mock.Of<IFileSystemInfo>(f => f.Name == "foo");

            underTest.CallEnsureThatLocalFileNameContainsLegalCharacters(fileInfo, exception);
        }
 public void ConstructorThrowsExceptionIfFiltersAreNull() {
     var session = new Mock<ISession>();
     session.SetupTypeSystem();
     Assert.Throws<ArgumentNullException>(() => new RemoteObjectDeleted(session.Object, Mock.Of<IMetaDataStorage>(), null));
 }
Example #8
0
 public void RunFakeEvent() {
     var session = new Mock<ISession>();
     session.SetupTypeSystem();
     var observer = new ObservableHandler();
     var storage = this.GetInitializedStorage();
     var queue = this.CreateQueue(session, storage, observer);
     var myEvent = new Mock<ISyncEvent>();
     queue.AddEvent(myEvent.Object);
     queue.Run();
     Assert.That(observer.List.Count, Is.EqualTo(1));
 }
 public void DefaultConstructorTest() {
     var session = new Mock<ISession>();
     session.SetupTypeSystem();
     new RemoteObjectDeleted(session.Object, Mock.Of<IMetaDataStorage>(), Mock.Of<IFilterAggregator>());
 }
Example #10
0
 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)));
 }
Example #11
0
        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);
        }
        private static SuccessfulLoginEvent CreateNewSessionEvent(bool changeEventSupported, bool supportsSelectiveIgnore = true, string id = "i", string token = "t") {
            var session = new Mock<ISession>();
            var remoteObject = new Mock<IFolder>();
            remoteObject.Setup(r => r.Id).Returns(id);
            remoteObject.Setup(r => r.ChangeToken).Returns(token);
            remoteObject.Setup(r => r.Path).Returns("path");
            session.SetupTypeSystem(true, supportsSelectiveIgnore);
            session.Setup(s => s.GetObjectByPath(It.IsAny<string>())).Returns(remoteObject.Object);
            if (changeEventSupported) {
                session.Setup(s => s.RepositoryInfo.Capabilities.ChangesCapability).Returns(CapabilityChanges.All);
            }

            return new SuccessfulLoginEvent(new Uri("http://example.com"), session.Object);
        }
 public void DefaultConstructorTest() {
     var session = new Mock<ISession>();
     session.SetupTypeSystem();
     new RemoteObjectRenamed(session.Object, Mock.Of<IMetaDataStorage>());
 }
 public void ConstructorTakesSessionAndStorageAndDateSyncDisabled() {
     var session = new Mock<ISession>();
     session.SetupTypeSystem();
     new LocalObjectChangedRemoteObjectChanged(session.Object, Mock.Of<IMetaDataStorage>(), null, new TransmissionManager());
 }
 public void ConstructorThrowsExceptionIfTransmissionManagerIsNull() {
     var session = new Mock<ISession>();
     session.SetupTypeSystem();
     Assert.Throws<ArgumentNullException>(() => new LocalObjectChanged(session.Object, Mock.Of<IMetaDataStorage>(), null, null));
 }
 public void DefaultConstructorTest() {
     var session = new Mock<ISession>();
     session.SetupTypeSystem();
     new LocalObjectChanged(session.Object, Mock.Of<IMetaDataStorage>(), null, Mock.Of<ITransmissionManager>());
 }