コード例 #1
0
        public void ShouldAddElementsToOtherGroupIfNoElementsAreInCommon()
        {
            ILockGroupManager manager = this.CreateGroupLockManager();

            var element1 = new TimelineElement();
            var element2 = new TimelineElement();

            var element3 = new TimelineElement();
            var element4 = new TimelineElement();

            var group1 = new List <TimelineElement> {
                element1, element2
            };
            var group2 = new List <TimelineElement> {
                element3, element4
            };

            Assert.AreEqual(0, manager.LockGroups.Count);

            manager.LockElements(group1);
            manager.LockElements(group2);

            Assert.AreEqual(2, manager.LockGroups.Count);
            Assert.AreEqual(2, manager.LockGroups[0].Count);
            Assert.AreEqual(2, manager.LockGroups[1].Count);

            Assert.IsTrue(manager.LockGroups[0].Contains(element1));
            Assert.IsTrue(manager.LockGroups[0].Contains(element2));

            Assert.IsTrue(manager.LockGroups[1].Contains(element3));
            Assert.IsTrue(manager.LockGroups[1].Contains(element4));
        }
コード例 #2
0
        public void ShouldMergeElementInSingleGroupIfElementsFromMultipleGroupsAreLockedTogether()
        {
            ILockGroupManager manager = this.CreateGroupLockManager();

            var element1 = new TimelineElement();
            var element2 = new TimelineElement();

            var element3 = new TimelineElement();
            var element4 = new TimelineElement();

            var group1 = new List <TimelineElement> {
                element1, element2
            };
            var group2 = new List <TimelineElement> {
                element3, element4
            };

            manager.LockElements(group1);
            manager.LockElements(group2);

            var group3 = new List <TimelineElement> {
                element1, element4
            };

            manager.LockElements(group3);

            Assert.AreEqual(1, manager.LockGroups.Count);

            Assert.AreEqual(4, manager.LockGroups[0].Count);

            Assert.IsTrue(manager.LockGroups[0].Contains(element1));
            Assert.IsTrue(manager.LockGroups[0].Contains(element2));
            Assert.IsTrue(manager.LockGroups[0].Contains(element3));
            Assert.IsTrue(manager.LockGroups[0].Contains(element4));
        }
コード例 #3
0
        public void ShouldNotUpdateGroupIdsAfterUnlockingGroup()
        {
            ILockGroupManager manager = this.CreateGroupLockManager();

            var element1 = new TimelineElement();
            var element2 = new TimelineElement();
            var element3 = new TimelineElement();
            var element4 = new TimelineElement();

            var group1 = new List <TimelineElement> {
                element1, element2
            };
            var group2 = new List <TimelineElement> {
                element3, element4
            };

            manager.LockElements(group1);
            manager.LockElements(group2);

            Assert.AreEqual(1, manager.LockGroups.Last().Id);

            manager.UnlockElementLockGroup(element2);

            Assert.AreEqual(1, manager.LockGroups.Count);

            Assert.AreEqual(1, manager.LockGroups.Last().Id);
        }
コード例 #4
0
        public void ShouldReturnGroupLastNumberWhenLockingElements()
        {
            ILockGroupManager manager = this.CreateGroupLockManager();

            var element1 = new TimelineElement();
            var element2 = new TimelineElement();

            var element3 = new TimelineElement();
            var element4 = new TimelineElement();

            var group1 = new List <TimelineElement> {
                element1, element2
            };
            var group2 = new List <TimelineElement> {
                element3, element4
            };

            int groupId = manager.LockElements(group1);

            Assert.AreEqual(0, groupId);

            groupId = manager.LockElements(group2);

            Assert.AreEqual(1, groupId);

            var group3 = new List <TimelineElement> {
                element1, element4
            };

            groupId = manager.LockElements(group3);

            Assert.AreEqual(0, groupId);
        }
コード例 #5
0
        public void ShouldGetElementsInSameLockGroupWhenRequested()
        {
            ILockGroupManager manager = this.CreateGroupLockManager();

            var element1 = new TimelineElement();
            var element2 = new TimelineElement();

            var element3 = new TimelineElement();
            var element4 = new TimelineElement();

            var group1 = new List <TimelineElement> {
                element1, element2
            };
            var group2 = new List <TimelineElement> {
                element3, element4
            };

            manager.LockElements(group1);
            manager.LockElements(group2);

            IEnumerable <TimelineElement> elementsGroupedWithElement2 = manager.GetGroupedElements(element2);

            Assert.AreEqual(2, elementsGroupedWithElement2.Count());
            Assert.IsTrue(elementsGroupedWithElement2.Contains(element1));
            Assert.IsTrue(elementsGroupedWithElement2.Contains(element2));

            IEnumerable <TimelineElement> elementsGroupedWithElement4 = manager.GetGroupedElements(element4);

            Assert.IsTrue(elementsGroupedWithElement4.Contains(element3));
            Assert.IsTrue(elementsGroupedWithElement4.Contains(element4));

            Assert.AreEqual(2, elementsGroupedWithElement4.Count());
        }
コード例 #6
0
        public void ShouldUpdateGroupToWhichElementBelongsToAfterGroupsAreMerged()
        {
            ILockGroupManager manager = this.CreateGroupLockManager();

            var element1 = new TimelineElement();
            var element2 = new TimelineElement();

            var element3 = new TimelineElement();
            var element4 = new TimelineElement();

            var group1 = new List <TimelineElement> {
                element1, element2
            };
            var group2 = new List <TimelineElement> {
                element3, element4
            };

            manager.LockElements(group1);
            manager.LockElements(group2);

            var group3 = new List <TimelineElement> {
                element1, element4
            };

            manager.LockElements(group3);

            var elements = manager.GetGroupedElements(element3);

            Assert.IsTrue(elements.Contains(element1));
            Assert.IsTrue(elements.Contains(element2));
            Assert.IsTrue(elements.Contains(element3));
            Assert.IsTrue(elements.Contains(element4));
        }
コード例 #7
0
        public void ShouldReturnNegativeOneWhenLockingZeroOrOneElement()
        {
            ILockGroupManager manager = this.CreateGroupLockManager();

            var element1 = new TimelineElement();

            var group1 = new List <TimelineElement>();

            Assert.AreEqual(0, manager.LockGroups.Count);

            int groupId = manager.LockElements(group1);

            Assert.AreEqual(-1, groupId);

            group1.Add(element1);

            groupId = manager.LockElements(group1);

            Assert.AreEqual(-1, groupId);
        }
コード例 #8
0
        public void ShouldNotCreateWhenGroupingZeroOrOneElement()
        {
            ILockGroupManager manager = this.CreateGroupLockManager();

            var element1 = new TimelineElement();

            var group1 = new List <TimelineElement>();

            Assert.AreEqual(0, manager.LockGroups.Count);

            manager.LockElements(group1);

            Assert.AreEqual(0, manager.LockGroups.Count);

            group1.Add(element1);

            manager.LockElements(group1);

            Assert.AreEqual(0, manager.LockGroups.Count);
        }
コード例 #9
0
        public void ShouldProvideLowestAvailableGroupIdWhenGroupingNewElements()
        {
            ILockGroupManager manager = this.CreateGroupLockManager();

            var element1 = new TimelineElement();
            var element2 = new TimelineElement();
            var element3 = new TimelineElement();
            var element4 = new TimelineElement();
            var element5 = new TimelineElement();
            var element6 = new TimelineElement();
            var element7 = new TimelineElement();
            var element8 = new TimelineElement();

            var group1 = new List <TimelineElement> {
                element1, element2
            };
            var group2 = new List <TimelineElement> {
                element3, element4
            };
            var group3 = new List <TimelineElement> {
                element5, element6
            };
            var group4 = new List <TimelineElement> {
                element7, element8
            };

            manager.LockElements(group1);
            manager.LockElements(group2);
            manager.LockElements(group3);

            manager.UnlockElementLockGroup(element1);

            manager.LockElements(group4);

            Assert.AreEqual(0, manager.LockGroups.Last().Id);
        }
コード例 #10
0
        public void ShouldAddElementToLockGroupWhenAdded()
        {
            ILockGroupManager manager = this.CreateGroupLockManager();

            var element1 = new TimelineElement();
            var element2 = new TimelineElement();
            var element3 = new TimelineElement();

            var elements = new List <TimelineElement> {
                element1, element2, element3
            };

            Assert.AreEqual(0, manager.LockGroups.Count);

            manager.LockElements(elements);

            Assert.AreEqual(1, manager.LockGroups.Count);
            Assert.AreEqual(3, manager.LockGroups[0].Count);
            Assert.IsTrue(manager.LockGroups[0].Contains(element1));
            Assert.IsTrue(manager.LockGroups[0].Contains(element2));
            Assert.IsTrue(manager.LockGroups[0].Contains(element3));
        }
コード例 #11
0
        public void ShouldReturnSingleElementAfterUnlockingGroup()
        {
            ILockGroupManager manager = this.CreateGroupLockManager();

            var element1 = new TimelineElement();
            var element2 = new TimelineElement();

            var group1 = new List <TimelineElement> {
                element1, element2
            };

            manager.LockElements(group1);

            manager.UnlockElementLockGroup(element2);

            Assert.AreEqual(0, manager.LockGroups.Count);

            var elements = manager.GetGroupedElements(element1);

            Assert.AreEqual(1, elements.Count());

            elements = manager.GetGroupedElements(element2);
            Assert.AreEqual(1, elements.Count());
        }