private static List <IChangeEvent> GenerateSingleChangeListMock(DotCMIS.Enums.ChangeType type, string objectId = "objId")
        {
            var changeList = new List <IChangeEvent>();

            changeList.Add(GenerateChangeEvent(type, objectId).Object);
            return(changeList);
        }
        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);
        }
        public static Mock <IChangeEvent> GenerateChangeEvent(DotCMIS.Enums.ChangeType type, string objectId)
        {
            var changeEvent = new Mock <IChangeEvent>();

            changeEvent.Setup(ce => ce.ObjectId).Returns(objectId);
            changeEvent.Setup(ce => ce.ChangeType).Returns(type);

            return(changeEvent);
        }
        public static Mock <ISession> GetSessionMockReturningDocumentChange(DotCMIS.Enums.ChangeType type, string id, string documentContentStreamId = null)
        {
            var session = MockSessionUtil.PrepareSessionMockForSingleChange(type, id);

            var newRemoteObject = MockOfIDocumentUtil.CreateRemoteDocumentMock(documentContentStreamId, id, "name", (string)null);

            session.Setup(s => s.GetObject(id, It.IsAny <IOperationContext>())).Returns(newRemoteObject.Object);
            session.Setup(s => s.GetObject(id)).Returns(newRemoteObject.Object);

            return(session);
        }
        public static Mock <ISession> GetSessionMockReturningFolderChange(DotCMIS.Enums.ChangeType type, string id = "folderid", string folderName = "name", string path = "path", string parentId = "", string changetoken = "changetoken")
        {
            if (path.Contains("\\"))
            {
                throw new ArgumentException("Given remote path: " + path + " contains \\");
            }

            var session         = PrepareSessionMockForSingleChange(type, id);
            var newRemoteObject = MockOfIFolderUtil.CreateRemoteFolderMock(id, folderName, path, parentId, changetoken);

            session.Setup(s => s.GetObject(It.IsAny <string>())).Returns(newRemoteObject.Object);
            session.Setup(s => s.GetObject(It.IsAny <string>(), It.IsAny <IOperationContext>())).Returns(newRemoteObject.Object);

            return(session);
        }
        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);
        }