public void ShouldGetIfAnElementIsLinkedToOther()
        {
            var elementA = GetElementA();
            var elementB = GetElementB();
            var elementC = GetElementC();
            var model    = new SequenceModel(new MockEventAggregator());

            model.Tracks.Add(new Track {
                TrackType = TrackType.Visual
            });

            model.Tracks[0].Shots.Add(elementA);
            model.Tracks[0].Shots.Add(elementB);
            model.Tracks[0].Shots.Add(elementC);

            // B -> C
            model.LinkNextElement(elementB, elementC);

            var result = model.IsElementLinkedTo(elementB, elementC);

            Assert.IsTrue(result);

            result = model.IsElementLinkedTo(elementA, elementC);

            Assert.IsFalse(result);
        }
        public void ShouldGetLastElementInChainOfLinks()
        {
            var elementA = GetElementA();
            var elementB = GetElementB();
            var elementC = GetElementC();
            var model    = new SequenceModel(new MockEventAggregator());

            model.Tracks.Add(new Track {
                TrackType = TrackType.Visual
            });

            model.Tracks[0].Shots.Add(elementA);
            model.Tracks[0].Shots.Add(elementB);
            model.Tracks[0].Shots.Add(elementC);

            // B -> C
            model.LinkNextElement(elementB, elementC);

            // A -> B
            model.LinkPreviousElement(elementB, elementA);

            var element = model.FindLastElementLinking(elementA, model.Tracks[0]);

            Assert.AreEqual(elementC, element);

            element = model.FindLastElementLinking(elementB, model.Tracks[0]);

            Assert.AreEqual(elementC, element);
        }
        public void LinkRightElementWrongPositionsReturnsFalse()
        {
            var elementA = GetElementA();
            var elementB = GetElementB();
            var elementC = GetElementC();
            var model    = new SequenceModel(new MockEventAggregator());

            model.Tracks.Add(new Track {
                TrackType = TrackType.Visual
            });

            model.Tracks[0].Shots.Add(elementA);
            model.Tracks[0].Shots.Add(elementB);
            model.Tracks[0].Shots.Add(elementC);

            var result = model.LinkNextElement(elementA, elementC);
            var linkA  = model.GetElementLink(elementA);
            var linkB  = model.GetElementLink(elementB);

            Assert.IsFalse(result);
            Assert.AreEqual(Guid.Empty, linkA.PreviousElementId);
            Assert.AreEqual(Guid.Empty, linkA.NextElementId);
            Assert.AreEqual(Guid.Empty, linkB.PreviousElementId);
            Assert.AreEqual(Guid.Empty, linkB.NextElementId);
        }
        public void LinkRightElement()
        {
            var elementA = GetElementA();
            var elementB = GetElementB();
            var model    = new SequenceModel(new MockEventAggregator());

            model.Tracks.Add(new Track {
                TrackType = TrackType.Visual
            });

            model.Tracks[0].Shots.Add(elementA);
            model.Tracks[0].Shots.Add(elementB);

            var result = model.LinkNextElement(elementA, elementB);
            var linkA  = model.GetElementLink(elementA);
            var linkB  = model.GetElementLink(elementB);

            Assert.IsTrue(result);
            Assert.IsNotNull(linkA);
            Assert.IsNotNull(linkB);
            Assert.AreEqual(elementB.Id, linkA.NextElementId);
            Assert.AreEqual(elementA.Id, linkB.PreviousElementId);
            Assert.AreEqual(Guid.Empty, linkA.PreviousElementId);
            Assert.AreEqual(Guid.Empty, linkB.NextElementId);
        }
        public void UnlinkMiddleElementRemovesAllLinks()
        {
            var elementA = GetElementA();
            var elementB = GetElementB();
            var elementC = GetElementC();
            var model    = new SequenceModel(new MockEventAggregator());

            model.Tracks.Add(new Track {
                TrackType = TrackType.Visual
            });

            model.Tracks[0].Shots.Add(elementA);
            model.Tracks[0].Shots.Add(elementB);
            model.Tracks[0].Shots.Add(elementC);

            // link
            var result = model.LinkNextElement(elementA, elementB);

            Assert.IsTrue(result);
            result = model.LinkNextElement(elementB, elementC);
            Assert.IsTrue(result);

            // unlink
            model.UnlinkElement(elementB);

            var linkA = model.GetElementLink(elementA);

            Assert.AreEqual(Guid.Empty, linkA.PreviousElementId);
            Assert.AreEqual(Guid.Empty, linkA.NextElementId);

            var linkB = model.GetElementLink(elementB);

            Assert.AreEqual(Guid.Empty, linkB.PreviousElementId);
            Assert.AreEqual(Guid.Empty, linkB.NextElementId);

            var linkC = model.GetElementLink(elementC);

            Assert.AreEqual(Guid.Empty, linkC.PreviousElementId);
            Assert.AreEqual(Guid.Empty, linkC.NextElementId);
        }