Exemplo n.º 1
0
        public void TestLoadedTerritoriesAreUnique()
        {
            var earth = BoardBuilder.LoadNewTerritories();
            var rnd1  = _random.Next(0, 41);
            var rnd2  = _random.Next(0, 41);

            while (rnd1 == rnd2)
            {
                rnd2 = _random.Next(0, 41);
            }
            var territory1 = earth.Territories[rnd1];
            var territory2 = earth.Territories[rnd2];

            Assert.AreNotSame(territory1, territory2);
        }
Exemplo n.º 2
0
        public void Builder_AssignNonExistingComponent_InputIgnored()
        {
            // Arrange
            var builder = new BoardBuilder();

            // Act
            var varName  = "InputNode";
            var compName = "Non-existing-component";

            builder.AddComponent(varName, compName);

            // Assert
            var components = builder.Build().Components;

            Assert.IsTrue(!components.ContainsKey(varName));
        }
Exemplo n.º 3
0
        public void Builder_LinkAToNonExisting_NothingIsLinked()
        {
            // Arrange
            var builder = new BoardBuilder();

            // Act
            var varName1 = "A";
            var compName = "Input";

            builder.AddComponent(varName1, compName);

            var varName2 = "B";

            builder.LinkList(varName1, new[] { varName2 });
            // Assert
            var components = builder.Build().Components;
            var node1      = components[varName1];

            Assert.IsTrue(node1.Next.Count == 0);
        }
Exemplo n.º 4
0
        public void Builder_AssignInput_InputExists()
        {
            // Arrange
            var builder = new BoardBuilder();

            // Act
            var varName  = "InputNode";
            var compName = "Input";

            builder.AddComponent(varName, compName);

            // Assert
            var components = builder.Build().Components;

            Assert.IsTrue(components.ContainsKey(varName));

            var node = components[varName];

            Assert.IsInstanceOfType(node, typeof(Input));
        }
Exemplo n.º 5
0
        public void Builder_AssignInputNonExistingValue_InputExistsWithLowValue()
        {
            // Arrange
            var builder = new BoardBuilder();

            // Act
            var varName  = "InputNode";
            var compName = "Input";
            var value    = "Non-Existing";

            builder.AddComponent(varName, compName, value);

            // Assert
            var components = builder.Build().Components;

            Assert.IsTrue(components.ContainsKey(varName));

            var node = components[varName];

            Assert.IsInstanceOfType(node, typeof(Input));
            Assert.AreEqual(Bit.LOW, node.Value);
        }
Exemplo n.º 6
0
        public void Builder_AssignAlreadyExistingVariable_OverwriteComponent()
        {
            // Arrange
            var builder = new BoardBuilder();

            // Act
            var varName  = "Node1";
            var compName = "Input";

            builder.AddComponent(varName, compName);

            var compName2 = "Probe";

            builder.AddComponent(varName, compName2);

            // Assert
            var components = builder.Build().Components;

            Assert.IsTrue(components.ContainsKey(varName));

            var node = components[varName];

            Assert.IsInstanceOfType(node, typeof(Probe));
        }
Exemplo n.º 7
0
        //------------------------DATA------------------------------
        private BoardPosition[,] BuildBlankBoard()
        {
            IBoardBuilder boardBuilder = new BoardBuilder();

            return(boardBuilder.BuildBoard());
        }
Exemplo n.º 8
0
        public void TestAllCardsLoad()
        {
            var cards = BoardBuilder.LoadCards(_random);

            Assert.AreEqual(44, cards.Count);
        }
Exemplo n.º 9
0
        public void TestAllTerritoriesLoad()
        {
            var territories = BoardBuilder.LoadNewTerritories();

            Assert.AreEqual(42, territories.Territories.Count);
        }