コード例 #1
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>");
        }