示例#1
0
        public void Link_EngineWithMatching_CorrectLink()
        {
            var engine = new DominoTileEntity(12, 12, true);
            var tile   = new DominoTileEntity(12, 11);

            tile.Link(engine);

            Assert.Equal(engine, tile.GetLinkedTiles().First());
            Assert.Equal("HalfLinkedState", tile.GetStateType().Name);
            Assert.Equal(1, tile.GetUnlinkedValues().Count());
            Assert.Equal(11, tile.GetUnlinkedValues().First());
        }
示例#2
0
        public void Link_OnAlreadyLinkedValue_ThrowsException()
        {
            var tileOne   = new DominoTileEntity(1, 2);
            var tileTwo   = new DominoTileEntity(2, 3);
            var tileThree = new DominoTileEntity(2, 4);

            tileOne.Link(tileTwo);
            Action linkThreeOnTwo = () => tileTwo.Link(tileThree);
            Action linkTwoOnThree = () => tileThree.Link(tileTwo);

            Assert.Equal(1, tileTwo.GetUnlinkedValues().Count());
            Assert.Equal(3, tileTwo.GetUnlinkedValues().First());
            Assert.Equal("HalfLinkedState", tileTwo.GetStateType().Name);
            Assert.ThrowsAny <Exception>(linkThreeOnTwo);
            Assert.ThrowsAny <Exception>(linkTwoOnThree);
        }
示例#3
0
        public void Link_ThreeTiles_LinkedRefsAreCorrect()
        {
            var engine  = new DominoTileEntity(12, 12, true);
            var tileOne = new DominoTileEntity(12, 11);
            var tileTwo = new DominoTileEntity(11, 10);

            tileOne.Link(engine);
            tileTwo.Link(tileOne);

            Assert.True(tileOne.IsLinked(engine));
            Assert.True(tileTwo.IsLinked(tileOne));
            Assert.Equal("FullyLinkedState", tileOne.GetStateType().Name);
            Assert.Equal("HalfLinkedState", tileTwo.GetStateType().Name);
            Assert.Equal(1, tileTwo.GetUnlinkedValues().Count());
            Assert.Equal(10, tileTwo.GetUnlinkedValues().First());
        }
示例#4
0
        public void Link_TwoMatching_CorrectLink()
        {
            var tileOne = new DominoTileEntity(1, 2);
            var tileTwo = new DominoTileEntity(2, 3);

            tileTwo.Link(tileOne);

            Assert.Equal(tileOne, tileTwo.GetLinkedTiles().First());
            Assert.Equal("HalfLinkedState", tileTwo.GetStateType().Name);
            Assert.Equal(1, tileTwo.GetUnlinkedValues().Count());
            Assert.Equal(3, tileTwo.GetUnlinkedValues().First());

            Assert.Equal(tileTwo, tileOne.GetLinkedTiles().First());
            Assert.Equal("HalfLinkedState", tileOne.GetStateType().Name);
            Assert.Equal(1, tileOne.GetUnlinkedValues().Count());
            Assert.Equal(1, tileOne.GetUnlinkedValues().First());
        }