Exemple #1
0
        public void AreAllSourcesInList(bool isSrc0, bool isSrc1, bool isInList0, bool isInList1, bool exectedResults)
        {
            var execMgr = new ExecMgr();
            Guid id0 = Guid.NewGuid();
            Guid id1 = Guid.NewGuid();
            Guid id2 = Guid.NewGuid();

            IElement el0 = DummyFactory.CreateDummyEl(id0);
            IElement el1 = DummyFactory.CreateDummyEl(id1);

            var mockElX = new Mock<IElement>();

            IList<IElement> sources = new List<IElement>();
            if (isSrc0)
                sources.Add(el0);
            if (isSrc1)
                sources.Add(el1);

            IList<IElement> execList = new List<IElement>();
            if (isSrc0)
                execList.Add(el0);
            if (isSrc1)
                execList.Add(el1);

            mockElX.Setup(m => m.Id).Returns(Guid.NewGuid());
            mockElX.Setup(m => m.SourceElements).Returns(sources);

            bool result = execMgr.AreAllSourcesInList(execList, mockElX.Object);

            Assert.True(result);
        }
Exemple #2
0
        public void AddRoots(bool isRoot0, bool isRoot1, bool isRoot2, int expectedRootsCount)
        {
            var execMgr = new ExecMgr();
            var mockEl0 = new Mock<IElement>();
            var mockEl1 = new Mock<IElement>();
            var mockEl2 = new Mock<IElement>();
            var mockSettingsMgr0 = new Mock<IElementSettingsMgr>();
            var mockSettingsMgr1 = new Mock<IElementSettingsMgr>();
            var mockSettingsMgr2 = new Mock<IElementSettingsMgr>();

            PointF loc0 = new PointF(0f, 0f);
            PointF loc1 = new PointF(0f, 0f);
            PointF loc2 = new PointF(0f, 0f);

            IDictionary<Guid, IElement>  elements = new Dictionary<Guid, IElement>();

            elements.Add(Guid.NewGuid(), mockEl0.Object);
            elements.Add(Guid.NewGuid(), mockEl1.Object);
            elements.Add(Guid.NewGuid(), mockEl2.Object);

            Queue<IElement> qu = new Queue<IElement>();

            mockEl0.Setup(m => m.IsRoot).Returns(isRoot0);
            mockEl1.Setup(m => m.IsRoot).Returns(isRoot1);
            mockEl2.Setup(m => m.IsRoot).Returns(isRoot2);

            mockEl0.Setup(m => m.Settings).Returns(mockSettingsMgr0.Object);
            mockSettingsMgr0.Setup(m => m.Location).Returns(loc0);

            mockEl1.Setup(m => m.Settings).Returns(mockSettingsMgr1.Object);
            mockSettingsMgr1.Setup(m => m.Location).Returns(loc1);

            mockEl2.Setup(m => m.Settings).Returns(mockSettingsMgr2.Object);
            mockSettingsMgr2.Setup(m => m.Location).Returns(loc2);

            int results = execMgr.AddRoots(qu, elements);
            Assert.Equal(expectedRootsCount, results);
            Assert.Equal(expectedRootsCount, qu.Count);
        }
Exemple #3
0
 public void Execute()
 {
     var em = new ExecMgr();
     em.ExecRoots(ElementsMgr, true);
 }
Exemple #4
0
        public void UpdateQ_WithNewElement()
        {
            var execMgr = new ExecMgr();
            Guid id0 = Guid.NewGuid();
            Guid id1 = Guid.NewGuid();
            Guid id2 = Guid.NewGuid();
            Guid idX = Guid.NewGuid();

            IElement el0 = DummyFactory.CreateDummyEl(id0);
            IElement el1 = DummyFactory.CreateDummyEl(id1);
            IElement el2 = DummyFactory.CreateDummyEl(id2);
            IElement elX = DummyFactory.CreateDummyEl(idX);

            IList<IElement> list = new List<IElement>();

            list.Add(el0);
            list.Add(el1);
            list.Add(el2);

            execMgr.UpdateQ(list, elX);

            Assert.Equal(4, list.Count);

            Assert.Same(elX, list[3]);
        }
Exemple #5
0
        public void InsertRoot(float y0, float y1, float y2, int expectedResult)
        {
            var execMgr = new ExecMgr();
            var mockEl0 = new Mock<IElement>();
            var mockEl1 = new Mock<IElement>();
            var mockEl2 = new Mock<IElement>();

            IList<IElement> roots = new List<IElement>();

            roots.Add(mockEl0.Object);
            roots.Add(mockEl1.Object);
            //roots.Add(el2);

            var mockSettingsMgr0 = new Mock<IElementSettingsMgr>();
            var mockSettingsMgr1 = new Mock<IElementSettingsMgr>();
            var mockSettingsMgr2 = new Mock<IElementSettingsMgr>();

            PointF loc0 = new PointF(0f, y0);
            PointF loc1 = new PointF(0f, y1);
            PointF loc2 = new PointF(0f, y2);

            mockEl0.Setup(m => m.Settings).Returns(mockSettingsMgr0.Object);
            mockSettingsMgr0.Setup(m => m.Location).Returns(loc0);

            mockEl1.Setup(m => m.Settings).Returns(mockSettingsMgr1.Object);
            mockSettingsMgr1.Setup(m => m.Location).Returns(loc1);

            mockEl2.Setup(m => m.Settings).Returns(mockSettingsMgr2.Object);
            mockSettingsMgr2.Setup(m => m.Location).Returns(loc2);

            int index = execMgr.InsertRoot(roots, mockEl2.Object);

            mockEl2.VerifyAll();
            mockSettingsMgr2.VerifyAll();
            Assert.Equal(expectedResult, index);
            IElement tmp = roots[index];
            Assert.NotNull(tmp);
            Assert.Same(mockEl2.Object, tmp);
        }
Exemple #6
0
        public void GetRoots(bool isRoot0, bool isRoot1, bool isRoot2, int expectedRootsCount)
        {
            var execMgr = new ExecMgr();
            var mockEl0 = new Mock<IElement>();
            var mockEl1 = new Mock<IElement>();
            var mockEl2 = new Mock<IElement>();

            IList<IElement> roots = new List<IElement>();

            roots.Add(mockEl0.Object);
            roots.Add(mockEl1.Object);
            //roots.Add(el2);

            var mockSettingsMgr0 = new Mock<IElementSettingsMgr>();
            var mockSettingsMgr1 = new Mock<IElementSettingsMgr>();
            var mockSettingsMgr2 = new Mock<IElementSettingsMgr>();

            IDictionary<Guid, IElement>  elements = new Dictionary<Guid, IElement>();

            elements.Add(Guid.NewGuid(), mockEl0.Object);
            elements.Add(Guid.NewGuid(), mockEl1.Object);
            elements.Add(Guid.NewGuid(), mockEl2.Object);

            mockEl0.Setup(m => m.IsRoot).Returns(isRoot0);
            mockEl1.Setup(m => m.IsRoot).Returns(isRoot1);
            mockEl2.Setup(m => m.IsRoot).Returns(isRoot2);

            mockEl0.Setup(m => m.Settings).Returns(mockSettingsMgr0.Object);
             //   mockSettingsMgr0.Setup(m => m.Location).Returns(loc0);

            mockEl1.Setup(m => m.Settings).Returns(mockSettingsMgr1.Object);
             //   mockSettingsMgr1.Setup(m => m.Location).Returns(loc1);

            mockEl2.Setup(m => m.Settings).Returns(mockSettingsMgr2.Object);
             //   mockSettingsMgr2.Setup(m => m.Location).Returns(loc2);

            IList<IElement> results = execMgr.GetRoots(elements);
            Assert.NotNull(results);
            Assert.Equal(expectedRootsCount, results.Count);
        }