public void InitializeWithCmisException() {
            string errorContent = "error content";
            string message = "message";
            var ex = new CmisBaseException(message, errorContent);
            var exception = new InteractionNeededException(message, ex);
            var underTest = new InteractionNeededEvent(exception);

            Assert.That(underTest.Description, Is.EqualTo(message));
            Assert.That(underTest.Details, Is.EqualTo(errorContent));
        }
 public void InitializeWithException() {
     var ex = new InteractionNeededException();
     var underTest = new InteractionNeededEvent(ex);
     Assert.That(underTest.Exception, Is.EqualTo(ex));
     Assert.That(underTest.Actions, Is.Empty);
     Assert.That(underTest.AffectedFiles, Is.Empty);
     Assert.That(underTest.Title, Is.EqualTo(ex.GetType().Name));
     Assert.That(underTest.Description, Is.EqualTo(ex.Message));
     Assert.That(underTest.Details, Is.Not.Null);
 }
        public void InitializeActions() {
            int called = 0;
            var action = new Action(delegate() { called++; });
            var ex = new InteractionNeededException();
            ex.Actions.Add("invoke", action);
            var underTest = new InteractionNeededEvent(ex);
            underTest.Actions["invoke"]();

            Assert.That(underTest.Actions.Count, Is.EqualTo(1));
            Assert.That(called, Is.EqualTo(1));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CmisSync.Lib.Events.InteractionNeededEvent"/> class.
        /// </summary>
        /// <param name="e">Exception which invokes a need for a user interaction.</param>
        public InteractionNeededEvent(InteractionNeededException e) : base(e) {
            if (e == null) {
                throw new ArgumentNullException("e");
            }

            this.AffectedFiles = new List<IFileSystemInfo>(e.AffectedFiles);
            this.Actions = new Dictionary<string, Action>(e.Actions);
            this.Title = e.Title;
            this.Description = e.Description;
            this.Details = e.Details;
        }
Пример #5
0
        public void AddingInteractionNeededEventToQueueOnInteractionNeededException() {
            var localDetection = new Mock<ISituationDetection<AbstractFolderEvent>>();
            var remoteDetection = new Mock<ISituationDetection<AbstractFolderEvent>>();
            int numberOfSolver = Enum.GetNames(typeof(SituationType)).Length;
            ISolver[,] solver = new ISolver[numberOfSolver, numberOfSolver];
            var interactionNeededProducer = new Mock<ISolver>();
            var exception = new InteractionNeededException("reason");
            interactionNeededProducer.Setup(
                r =>
                r.Solve(
                It.IsAny<IFileSystemInfo>(),
                It.IsAny<IObjectId>(),
                It.IsAny<ContentChangeType>(),
                It.IsAny<ContentChangeType>())).Throws(exception);
            solver[(int)SituationType.NOCHANGE, (int)SituationType.NOCHANGE] = interactionNeededProducer.Object;
            var mechanism = this.CreateMechanism(localDetection.Object, remoteDetection.Object, solver);
            localDetection.Setup(d => d.Analyse(this.storage.Object, It.IsAny<AbstractFolderEvent>())).Returns(SituationType.NOCHANGE);
            remoteDetection.Setup(d => d.Analyse(this.storage.Object, It.IsAny<AbstractFolderEvent>())).Returns(SituationType.NOCHANGE);
            var folderEvent = new FolderEvent(Mock.Of<IDirectoryInfo>(), Mock.Of<IFolder>()) { Local = MetaDataChangeType.NONE, Remote = MetaDataChangeType.NONE };

            Assert.That(mechanism.Handle(folderEvent), Is.True);

            this.queue.Verify(q => q.AddEvent(It.Is<InteractionNeededEvent>(e => e.Exception == exception)), Times.Once());
            this.queue.VerifyThatNoOtherEventIsAddedThan<InteractionNeededEvent>();
        }