/// <summary>
 /// Get the Xenstore Item from path, create new one if not exist
 /// </summary>
 /// <param name="path">path of the item</param>
 /// <returns>the target item</returns>
 public override AXenStoreItem GetXenStoreItem(string path)
 {
     if (!mockXenstoreItems.ContainsKey(path))
     {
         MockXenStoreItem item = new MockXenStoreItem(path, this);
         mockXenstoreItems.Add(path, item);
     }
     return(mockXenstoreItems[path]);
 }
 /// <summary>
 /// Get the Xenstore Item from path, create new one if not exist
 /// </summary>
 /// <param name="path">path of the item</param>
 /// <param name="value">the new value of the item, if exist, then override the value</param>
 /// <returns>the target item</returns>
 public AXenStoreItem GetXenStoreItem(string path, string value)
 {
     if (!mockXenstoreItems.ContainsKey(path))
     {
         MockXenStoreItem item = new MockXenStoreItem(path, this);
         mockXenstoreItems.Add(path, item);
     }
     mockXenstoreItems[path].value = value;
     return(mockXenstoreItems[path]);
 }
        public void TestUpdateNetworkInfo()
        {
            vf.accessUpdateNetworkInfo(nics);

            // Check Nic1 xenstore Nic info
            // Check Name
            MockXenStoreItem name = session.GetXenStoreItem("xenserver/attr/net-sriov-vf/1/name") as MockXenStoreItem;

            Assert.AreEqual("Ethernet UT1", name.value);
            // Check Mac
            MockXenStoreItem mac = session.GetXenStoreItem("xenserver/attr/net-sriov-vf/1/mac") as MockXenStoreItem;

            Assert.AreEqual(UTFunctions.getMacString(mac1), mac.value);
            // Check ipv4
            MockXenStoreItem ipv4       = session.GetXenStoreItem("xenserver/attr/net-sriov-vf/1/ipv4/0") as MockXenStoreItem;
            string           ipv4Expect = string.Format("{0:d}.{1:d}.{2:d}.{3:d}", ipv4BytesNic1[0], ipv4BytesNic1[1], ipv4BytesNic1[2], ipv4BytesNic1[3]);

            Assert.AreEqual(ipv4Expect, ipv4.value);
            // Check ipv6
            MockXenStoreItem ipv6         = session.GetXenStoreItem("xenserver/attr/net-sriov-vf/1/ipv6/0") as MockXenStoreItem;
            string           expectedIpv6 = getIpv6String(ipv6BytesNic1);

            Assert.AreEqual(expectedIpv6, ipv6.value);

            // Check Nic2 xenstore Nic info
            // Check Name
            name = session.GetXenStoreItem("xenserver/attr/net-sriov-vf/2/name") as MockXenStoreItem;
            Assert.AreEqual("Ethernet UT2", name.value);
            // Check Mac
            mac = session.GetXenStoreItem("xenserver/attr/net-sriov-vf/2/mac") as MockXenStoreItem;
            Assert.AreEqual(UTFunctions.getMacString(mac2), mac.value);
            // Check ipv4
            ipv4       = session.GetXenStoreItem("xenserver/attr/net-sriov-vf/2/ipv4/0") as MockXenStoreItem;
            ipv4Expect = string.Format("{0:d}.{1:d}.{2:d}.{3:d}", ipv4BytesNic2[0], ipv4BytesNic2[1], ipv4BytesNic2[2], ipv4BytesNic2[3]);
            Assert.AreEqual(ipv4Expect, ipv4.value);
            // Check ipv6
            ipv6         = session.GetXenStoreItem("xenserver/attr/net-sriov-vf/2/ipv6/0") as MockXenStoreItem;
            expectedIpv6 = getIpv6String(ipv6BytesNic2);
            Assert.AreEqual(expectedIpv6, ipv6.value);
        }