UpgradeResource() public method

public UpgradeResource ( System.Xml.Linq.XElement sourceVersion, System.Version destinationVersion, Action onUpgrade ) : System.Xml.Linq.XElement
sourceVersion System.Xml.Linq.XElement
destinationVersion System.Version
onUpgrade Action
return System.Xml.Linq.XElement
Esempio n. 1
0
        public void ResourceUpgrader_Upgrade_EmptyDictionary()
        {
            //------------Setup for test--------------------------
            var a = new ResourceUpgrader(new List<IUpgradePath>());


            //------------Execute Test---------------------------
            var upgraded = a.UpgradeResource(XElement.Parse("<a></a>"), new Version(1, 2), (x => { }));
            //------------Assert Results-------------------------
            Assert.AreEqual(upgraded.ToString(), "<a></a>");
        }
Esempio n. 2
0
        public void ResourceUpgrader_Upgrade_HasDictionaryDictionary()
        {
            //------------Setup for test--------------------------
            var upgradePaths = new List<IUpgradePath>();
            var source =  XElement.Parse("<a></a>");
            var upgrade1 = new Mock<IUpgradePath>();
            upgrade1.Setup(a => a.UpgradesFrom).Returns(new Version());
            upgrade1.Setup(a => a.UpgradesTo).Returns(new Version());
            var mockUpgrade = new Mock<IResourceUpgrade>();
            upgradePaths.Add(upgrade1.Object);

            mockUpgrade.Setup(a => a.UpgradeFunc).Returns(a => XElement.Parse((a.ToString().Replace("a", "b"))));
            upgrade1.Setup(a=>a.CanUpgrade(source)).Returns(true);
            upgrade1.Setup(a => a.Upgrade).Returns(mockUpgrade.Object);
            var upgrader = new ResourceUpgrader(upgradePaths);


            //------------Execute Test---------------------------
            var upgraded = upgrader.UpgradeResource(source, new Version(1, 2), (x => { }));
            //------------Assert Results-------------------------
            Assert.AreEqual(upgraded.ToString(), "<b ServerVersion=\"" +upgrader.GetType().Assembly.GetName().Version + "\"></b>");
        }