Exemplo n.º 1
0
        public void LanTest1()
        {
            bool[,] relationsMatrix = new bool[3, 3];
            relationsMatrix[0, 0] = true;
            relationsMatrix[0, 1] = false;
            relationsMatrix[0, 2] = true;

            relationsMatrix[1, 0] = false;
            relationsMatrix[1, 1] = true;
            relationsMatrix[1, 2] = false;

            relationsMatrix[2, 0] = true;
            relationsMatrix[2, 1] = false;
            relationsMatrix[2, 2] = true;

            _2.Lan.PcInfo[] computers = new _2.Lan.PcInfo[3];
            computers[0].Infected = false;
            computers[0].InfectionProbability = 1;
            computers[1].Infected = true;
            computers[1].InfectionProbability = 1;
            computers[2].Infected = false;
            computers[2].InfectionProbability = 1;
            _2.Lan lan = new _2.Lan(relationsMatrix, computers);

            Assert.IsFalse(computers[0].Infected);
            Assert.IsTrue(computers[1].Infected);
            Assert.IsFalse(computers[2].Infected);

            lan.MakeMove();

            Assert.IsFalse(computers[0].Infected);
            Assert.IsTrue(computers[1].Infected);
            Assert.IsFalse(computers[2].Infected);
        }
Exemplo n.º 2
0
        public void LanTest2()
        {
            bool[,] relationsMatrix = new bool[8, 8];
            relationsMatrix[0, 0] = true;
            relationsMatrix[0, 1] = false;
            relationsMatrix[0, 2] = false;
            relationsMatrix[0, 3] = false;
            relationsMatrix[0, 4] = false;
            relationsMatrix[0, 5] = false;
            relationsMatrix[0, 6] = false;
            relationsMatrix[0, 7] = false;

            relationsMatrix[1, 0] = false;
            relationsMatrix[1, 1] = true;
            relationsMatrix[1, 2] = true;
            relationsMatrix[1, 3] = false;
            relationsMatrix[1, 4] = false;
            relationsMatrix[1, 5] = true;
            relationsMatrix[1, 6] = true;
            relationsMatrix[1, 7] = false;

            relationsMatrix[2, 0] = false;
            relationsMatrix[2, 1] = true;
            relationsMatrix[2, 2] = true;
            relationsMatrix[2, 3] = false;
            relationsMatrix[2, 4] = true;
            relationsMatrix[2, 5] = false;
            relationsMatrix[2, 6] = false;
            relationsMatrix[2, 7] = false;

            relationsMatrix[3, 0] = false;
            relationsMatrix[3, 1] = false;
            relationsMatrix[3, 2] = false;
            relationsMatrix[3, 3] = true;
            relationsMatrix[3, 4] = false;
            relationsMatrix[3, 5] = false;
            relationsMatrix[3, 6] = false;
            relationsMatrix[3, 7] = false;

            relationsMatrix[4, 0] = false;
            relationsMatrix[4, 1] = false;
            relationsMatrix[4, 2] = true;
            relationsMatrix[4, 3] = false;
            relationsMatrix[4, 4] = true;
            relationsMatrix[4, 5] = false;
            relationsMatrix[4, 6] = false;
            relationsMatrix[4, 7] = true;

            relationsMatrix[5, 0] = false;
            relationsMatrix[5, 1] = true;
            relationsMatrix[5, 2] = false;
            relationsMatrix[5, 3] = false;
            relationsMatrix[5, 4] = false;
            relationsMatrix[5, 5] = true;
            relationsMatrix[5, 6] = false;
            relationsMatrix[5, 7] = false;

            relationsMatrix[6, 0] = false;
            relationsMatrix[6, 1] = true;
            relationsMatrix[6, 2] = false;
            relationsMatrix[6, 3] = false;
            relationsMatrix[6, 4] = false;
            relationsMatrix[6, 5] = false;
            relationsMatrix[6, 6] = true;
            relationsMatrix[6, 7] = false;

            relationsMatrix[7, 0] = false;
            relationsMatrix[7, 1] = false;
            relationsMatrix[7, 2] = false;
            relationsMatrix[7, 3] = false;
            relationsMatrix[7, 4] = true;
            relationsMatrix[7, 5] = false;
            relationsMatrix[7, 6] = false;
            relationsMatrix[7, 7] = true;

            _2.Lan.PcInfo[] computers = new _2.Lan.PcInfo[8];
            computers[0].Infected = false;
            computers[0].InfectionProbability = 1;
            computers[1].Infected = false;
            computers[1].InfectionProbability = 1;
            computers[2].Infected = false;
            computers[2].InfectionProbability = 0;
            computers[3].Infected = false;
            computers[3].InfectionProbability = 1;
            computers[4].Infected = true;
            computers[4].InfectionProbability = 1;
            computers[5].Infected = true;
            computers[5].InfectionProbability = 1;
            computers[6].Infected = false;
            computers[6].InfectionProbability = 1;
            computers[7].Infected = false;
            computers[7].InfectionProbability = 1;
            _2.Lan lan = new _2.Lan(relationsMatrix, computers);

            lan.MakeMove();

            Assert.IsFalse(computers[0].Infected);
            Assert.IsTrue(computers[1].Infected);
            Assert.IsFalse(computers[2].Infected);
            Assert.IsFalse(computers[3].Infected);
            Assert.IsTrue(computers[4].Infected);
            Assert.IsTrue(computers[5].Infected);
            Assert.IsFalse(computers[6].Infected);
            Assert.IsTrue(computers[7].Infected);

            lan.MakeMove();

            Assert.IsFalse(computers[0].Infected);
            Assert.IsTrue(computers[1].Infected);
            Assert.IsFalse(computers[2].Infected);
            Assert.IsFalse(computers[3].Infected);
            Assert.IsTrue(computers[4].Infected);
            Assert.IsTrue(computers[5].Infected);
            Assert.IsTrue(computers[6].Infected);
            Assert.IsTrue(computers[7].Infected);

            for (int i = 0; i < 1000; i++)
            {
                lan.MakeMove();
            }

            Assert.IsFalse(computers[0].Infected);
            Assert.IsTrue(computers[1].Infected);
            Assert.IsFalse(computers[2].Infected);
            Assert.IsFalse(computers[3].Infected);
            Assert.IsTrue(computers[4].Infected);
            Assert.IsTrue(computers[5].Infected);
            Assert.IsTrue(computers[6].Infected);
            Assert.IsTrue(computers[7].Infected);
        }