示例#1
0
        public void TestProperties()
        {
            var iotedgeAgent = new IoTEdgeAgent(
                893,
                "name 123",
                "version 1.23.3",
                VstsAgentStatus.Online,
                true,
                new HashSet <AgentCapability>()
            {
                new AgentCapability("Agent.OS", "Linux")
            },
                new HashSet <AgentCapability>()
            {
                new AgentCapability("run-long-haul", "true")
            });

            Assert.AreEqual(893, iotedgeAgent.Id);
            Assert.AreEqual("name 123", iotedgeAgent.Name);
            Assert.AreEqual("version 1.23.3", iotedgeAgent.Version);
            Assert.AreEqual(VstsAgentStatus.Online, iotedgeAgent.Status);
            Assert.AreEqual(true, iotedgeAgent.Enabled);
            Assert.Contains(new AgentCapability("Agent.OS", "Linux"), iotedgeAgent.SystemCapabilities);
            Assert.Contains(new AgentCapability("run-long-haul", "true"), iotedgeAgent.UserCapabilities);
            Assert.True(iotedgeAgent.IsAvailable);
        }
示例#2
0
        public void TestCreate()
        {
            VstsAgent agent1 = new VstsAgent
            {
                Enabled            = true,
                Id                 = 8474,
                Name               = "iotedge-win-99",
                Status             = VstsAgentStatus.Online,
                SystemCapabilities = new Dictionary <string, string>
                {
                    { "SysCap1Key", "SysCap1Value" },
                    { "SysCap2Key", "SysCap2Value" }
                },
                UserCapabilities = new Dictionary <string, string>
                {
                    { "UserCap1Key", "UserCap1Value" },
                    { "UserCap2Key", "UserCap2Value" }
                },
                Version = "version99"
            };

            IoTEdgeAgent agent2 = IoTEdgeAgent.Create(agent1);

            Assert.True(agent2.Enabled);
            Assert.AreEqual(8474, agent2.Id);
            Assert.AreEqual("iotedge-win-99", agent2.Name);
            Assert.AreEqual(VstsAgentStatus.Online, agent2.Status);
            Assert.AreEqual(2, agent2.SystemCapabilities.Count);
            Assert.True(agent2.SystemCapabilities.Contains(new AgentCapability("SysCap1Key", "SysCap1Value")));
            Assert.True(agent2.SystemCapabilities.Contains(new AgentCapability("SysCap2Key", "SysCap2Value")));
            Assert.AreEqual(2, agent2.UserCapabilities.Count);
            Assert.True(agent2.UserCapabilities.Contains(new AgentCapability("UserCap1Key", "UserCap1Value")));
            Assert.True(agent2.UserCapabilities.Contains(new AgentCapability("UserCap2Key", "UserCap2Value")));
            Assert.AreEqual("version99", agent2.Version);
        }
示例#3
0
        public void TestIsAvailable()
        {
            var agent1 = new IoTEdgeAgent(
                1001,
                "name1",
                "version1",
                VstsAgentStatus.Online,
                true,
                new HashSet <AgentCapability>()
            {
                new AgentCapability("Agent.OS", "Linux")
            },
                new HashSet <AgentCapability>()
            {
                new AgentCapability("run-long-haul", "true")
            });

            var agent2 = new IoTEdgeAgent(
                1001,
                "name1",
                "version1",
                VstsAgentStatus.Online,
                false,
                new HashSet <AgentCapability>()
            {
                new AgentCapability("Agent.OS", "Linux")
            },
                new HashSet <AgentCapability>()
            {
                new AgentCapability("run-long-haul", "true")
            });

            var agent3 = new IoTEdgeAgent(
                1001,
                "name1",
                "version1",
                VstsAgentStatus.Offline,
                true,
                new HashSet <AgentCapability>()
            {
                new AgentCapability("Agent.OS", "Linux")
            },
                new HashSet <AgentCapability>()
            {
                new AgentCapability("run-long-haul", "true")
            });

            Assert.True(agent1.IsAvailable);
            Assert.False(agent2.IsAvailable);
            Assert.False(agent3.IsAvailable);
        }
示例#4
0
        public void TestMatch()
        {
            var agent1 = new IoTEdgeAgent(
                1001,
                "name1",
                "version1",
                VstsAgentStatus.Online,
                true,
                new HashSet <AgentCapability>()
            {
                new AgentCapability("Agent.OS", "Linux")
            },
                new HashSet <AgentCapability>()
            {
                new AgentCapability("run-long-haul", "true")
            });

            bool match = agent1.Match(
                new AgentCapability[]
            {
                new AgentCapability("Agent.OS", "Linux"),
                new AgentCapability("run-long-haul", "true")
            });

            Assert.True(match);

            match = agent1.Match(
                new AgentCapability[]
            {
                new AgentCapability("Agent.OS", "Linux")
            });
            Assert.True(match);

            match = agent1.Match(
                new AgentCapability[]
            {
                new AgentCapability("Agent.OS", "Linux"),
                new AgentCapability("run-stress", "true")
            });
            Assert.False(match);

            match = agent1.Match(
                new AgentCapability[]
            {
                new AgentCapability("Agent.OS", "Windows"),
                new AgentCapability("run-stress", "true")
            });
            Assert.False(match);
        }
示例#5
0
        public void TestConstructorWithEmptyUserCredential()
        {
            var iotedgeAgent = new IoTEdgeAgent(
                893,
                "name 123",
                "version 1.23.3",
                VstsAgentStatus.Online,
                true,
                new HashSet <AgentCapability>()
            {
                new AgentCapability("Agent.OS", "Linux")
            },
                null);

            Assert.AreEqual(0, iotedgeAgent.UserCapabilities.Count);
        }
示例#6
0
        public void TestGetAgentGroupReturnsEmpty()
        {
            var agent1 = new IoTEdgeAgent(
                1001,
                "name1",
                "version1",
                VstsAgentStatus.Online,
                true,
                new HashSet <AgentCapability>()
            {
                new AgentCapability("Agent.OS", "Linux")
            },
                new HashSet <AgentCapability>()
            {
                new AgentCapability("run-long-haul", "true")
            });

            Assert.AreEqual(string.Empty, agent1.GetAgentGroup());
        }
示例#7
0
        public void TestGetAgentGroupSuccess()
        {
            var agent1 = new IoTEdgeAgent(
                1001,
                "name1",
                "version1",
                VstsAgentStatus.Online,
                true,
                new HashSet <AgentCapability>()
            {
                new AgentCapability("Agent.OS", "Linux")
            },
                new HashSet <AgentCapability>()
            {
                new AgentCapability("run-long-haul", "true"),
                new AgentCapability("agent-group", "2")
            });

            Assert.AreEqual("2", agent1.GetAgentGroup());
        }
示例#8
0
        public void TestClone()
        {
            var agent1 = new IoTEdgeAgent(
                1001,
                "name1",
                "version1",
                VstsAgentStatus.Online,
                true,
                new HashSet <AgentCapability>()
            {
                new AgentCapability("Agent.OS", "Linux")
            },
                new HashSet <AgentCapability>()
            {
                new AgentCapability("run-long-haul", "true"),
                new AgentCapability("agent-group", "2")
            });

            var agent2 = agent1.Clone();

            Assert.AreNotSame(agent1, agent2);
            Assert.AreEqual(agent1, agent2);
        }
示例#9
0
        public void TestUpdate()
        {
            var agents = new HashSet <IoTEdgeAgent>();
            var agent1 = new IoTEdgeAgent(
                38324,
                "iotedge-pi-04",
                "version",
                VstsAgentStatus.Online,
                true,
                new HashSet <AgentCapability>
            {
                new AgentCapability("Agent.OS", "Linux"),
                new AgentCapability("Agent.OSArchitecture", "ARM"),
            },
                new HashSet <AgentCapability>
            {
                new AgentCapability("agent-osbits", "32"),
                new AgentCapability("run-stress", "true"),
            });

            agents.Add(agent1);

            var agent2 = new IoTEdgeAgent(
                39472,
                "iotedge-win5",
                "version",
                VstsAgentStatus.Online,
                true,
                new HashSet <AgentCapability>
            {
                new AgentCapability("Agent.OS", "Windows_NT"),
                new AgentCapability("Agent.OSArchitecture", "X64"),
            },
                new HashSet <AgentCapability>
            {
                new AgentCapability("agent-os-name", "WinPro_x64"),
                new AgentCapability("run-long-haul", "true"),
            });

            agents.Add(agent2);

            var agentMatrix = new AgentMatrix();

            agentMatrix.Update(agents);

            var rowGroup1 = new AgentDemandSet(
                "Linux ARM32",
                new HashSet <AgentCapability>
            {
                new AgentCapability("Agent.OS", "Linux"),
                new AgentCapability("Agent.OSArchitecture", "ARM"),
                new AgentCapability("agent-osbits", "32"),
            });

            var colGroup1 = new AgentDemandSet(
                "Stress Test",
                new HashSet <AgentCapability>
            {
                new AgentCapability("run-stress", "true"),
            });

            var rowGroup2 = new AgentDemandSet(
                "Windows AMD64",
                new HashSet <AgentCapability>
            {
                new AgentCapability("Agent.OS", "Windows_NT"),
                new AgentCapability("Agent.OSArchitecture", "X64"),
                new AgentCapability("agent-os-name", "WinPro_x64"),
            });

            var colGroup2 = new AgentDemandSet(
                "Long Haul",
                new HashSet <AgentCapability>
            {
                new AgentCapability("run-long-haul", "true"),
            });

            ImmutableDictionary <AgentDemandSet, Dictionary <AgentDemandSet, HashSet <IoTEdgeAgent> > > updatedMatrix = agentMatrix.Matrix;

            foreach (AgentDemandSet row in updatedMatrix.Keys)
            {
                foreach (AgentDemandSet column in updatedMatrix[row].Keys)
                {
                    if (row.Equals(rowGroup1) && column.Equals(colGroup1))
                    {
                        Assert.AreEqual(1, updatedMatrix[row][column].Count);
                    }
                    else if (row.Equals(rowGroup2) && column.Equals(colGroup2))
                    {
                        Assert.AreEqual(1, updatedMatrix[row][column].Count);
                    }
                    else
                    {
                        Assert.AreEqual(0, updatedMatrix[row][column].Count);
                    }
                }
            }
        }
示例#10
0
 public void TestCreateWithNullValue()
 {
     Assert.That(() => IoTEdgeAgent.Create(null), Throws.TypeOf <ArgumentNullException>());
 }
示例#11
0
        public void TestEquals()
        {
            var a1 = new IoTEdgeAgent(
                1001,
                "name1",
                "version1",
                VstsAgentStatus.Online,
                true,
                new HashSet <AgentCapability>()
            {
                new AgentCapability("Agent.OS", "Linux")
            },
                new HashSet <AgentCapability>()
            {
                new AgentCapability("run-long-haul", "true")
            });
            var a2 = new IoTEdgeAgent(
                1001,
                "name1",
                "version1",
                VstsAgentStatus.Online,
                true,
                new HashSet <AgentCapability>()
            {
                new AgentCapability("Agent.OS", "Linux")
            },
                new HashSet <AgentCapability>()
            {
                new AgentCapability("run-long-haul", "true")
            });
            var a3 = new IoTEdgeAgent(
                1002,
                "name1",
                "version1",
                VstsAgentStatus.Online,
                true,
                new HashSet <AgentCapability>()
            {
                new AgentCapability("Agent.OS", "Linux")
            },
                new HashSet <AgentCapability>()
            {
                new AgentCapability("run-long-haul", "true")
            });
            var a4 = new IoTEdgeAgent(
                1001,
                "name2",
                "version1",
                VstsAgentStatus.Online,
                true,
                new HashSet <AgentCapability>()
            {
                new AgentCapability("Agent.OS", "Linux")
            },
                new HashSet <AgentCapability>()
            {
                new AgentCapability("run-long-haul", "true")
            });
            var a5 = new IoTEdgeAgent(
                1001,
                "name1",
                "version2",
                VstsAgentStatus.Online,
                true,
                new HashSet <AgentCapability>()
            {
                new AgentCapability("Agent.OS", "Linux")
            },
                new HashSet <AgentCapability>()
            {
                new AgentCapability("run-long-haul", "true")
            });
            var a6 = new IoTEdgeAgent(
                1001,
                "name1",
                "version1",
                VstsAgentStatus.Offline,
                true,
                new HashSet <AgentCapability>()
            {
                new AgentCapability("Agent.OS", "Linux")
            },
                new HashSet <AgentCapability>()
            {
                new AgentCapability("run-long-haul", "true")
            });
            var a7 = new IoTEdgeAgent(
                1001,
                "name1",
                "version1",
                VstsAgentStatus.Online,
                false,
                new HashSet <AgentCapability>()
            {
                new AgentCapability("Agent.OS", "Linux")
            },
                new HashSet <AgentCapability>()
            {
                new AgentCapability("run-long-haul", "true")
            });
            var a8 = new IoTEdgeAgent(
                1001,
                "name1",
                "version1",
                VstsAgentStatus.Online,
                false,
                new HashSet <AgentCapability>()
            {
                new AgentCapability("Agent.OS", "Windows")
            },
                new HashSet <AgentCapability>()
            {
                new AgentCapability("run-long-haul", "true")
            });
            var a9 = new IoTEdgeAgent(
                1001,
                "name1",
                "version1",
                VstsAgentStatus.Online,
                false,
                new HashSet <AgentCapability>()
            {
                new AgentCapability("Agent.OS", "Linux")
            },
                new HashSet <AgentCapability>());

            Assert.False(a1.Equals(null));
            Assert.True(a1.Equals(a1));
            Assert.True(a1.Equals(a2));

            Assert.False(a1.Equals((object)null));
            Assert.True(a1.Equals((object)a1));
            Assert.True(a1.Equals((object)a2));
            Assert.False(a1.Equals(new object()));

            Assert.False(a1.Equals(a3));
            Assert.False(a1.Equals(a4));
            Assert.False(a1.Equals(a5));
            Assert.False(a1.Equals(a6));
            Assert.False(a1.Equals(a7));
            Assert.False(a1.Equals(a8));
            Assert.False(a1.Equals(a9));
        }