Пример #1
0
        public void Attributes_Assembly()
        {
            var context = InitContext <MyClass> (string.Format(typeFrameXml, multiFrameworkXml), 2, forceAlignment: false);

            foreach (var fx in context.fx.Frameworks)
            {
                FrameworkTypeEntry typeEntry = fx.Types.First();

                string[] attributeList = new[] { "One" };

                if (!fx.IsLastFramework && !fx.IsFirstFramework)
                {
                    attributeList = new string[0];
                }


                MDocUpdater.MakeAttributes(context.doc.FirstChild as XmlElement, attributeList, fx, typeEntry);
            }

            var attrNode   = context.doc.FirstChild.SelectSingleNode("Attributes");
            var attributes = attrNode.SelectNodes("Attribute").Cast <XmlElement> ().ToArray();

            Assert.IsTrue(attributes.Count() == 1);
            Assert.AreEqual("One", attributes[0].FirstChild.InnerText);
            Assert.IsTrue(attributes[0].HasAttribute(Consts.FrameworkAlternate));
            Assert.AreEqual("One;Two", attributes[0].GetAttribute(Consts.FrameworkAlternate));
        }
Пример #2
0
        public void Attributes_TypeOrMethod_AttributeRemoved()
        {
            var context = InitContext <MyClass> (string.Format(typeFrameXml, multiFrameworkXml), 2, forceAlignment: false);
            var fx      = context.fx.Frameworks[1];
            FrameworkTypeEntry typeEntry = fx.Types.First();

            string[] attributeList = new[] { "One" };

            MDocUpdater.MakeAttributes(context.doc.FirstChild as XmlElement, attributeList, fx, typeEntry);

            MDocUpdater.MakeAttributes(context.doc.FirstChild as XmlElement, new string[0], fx, typeEntry);
            MDocUpdater.MakeAttributes(context.doc.FirstChild as XmlElement, new string[0], context.fx.Frameworks[2], typeEntry);
            var attrNode = context.doc.FirstChild.SelectSingleNode("Attributes");

            Assert.IsNull(attrNode);
        }
Пример #3
0
        public void Attributes_TypeOrMethod()
        {
            var context = InitContext <MyClass>(string.Format(typeFrameXml, multiFrameworkXml), 2, forceAlignment: false);
            var fx      = context.fx.Frameworks[1];
            FrameworkTypeEntry typeEntry = fx.Types.First();

            string[] attributeList = new[] { "One" };

            MDocUpdater.MakeAttributes(context.doc.FirstChild as XmlElement, attributeList, fx, typeEntry);
            var attrNode   = context.doc.FirstChild.SelectSingleNode("Attributes");
            var attributes = attrNode.SelectNodes("Attribute").Cast <XmlElement>().ToArray();

            Assert.IsTrue(attributes.Count() == 1);
            Assert.AreEqual("One", attributes[0].FirstChild.InnerText);
            Assert.AreEqual("Three", attributes[0].GetAttribute(Consts.FrameworkAlternate));
        }
Пример #4
0
        public void Attributes_TypeOrMethod_AllFX_RunExisting_First()
        {
            var context = InitContext <MyClass> (string.Format(typeFrameXml, multiFrameworkXml), 2, forceAlignment: false);

            // first, go through and add "One" and "Two" to all of them
            foreach (var fx in context.fx.Frameworks)
            {
                FrameworkTypeEntry typeEntry = fx.Types.First();

                string[] attributeList = new[] { "One", "Two" };

                MDocUpdater.MakeAttributes(context.doc.FirstChild as XmlElement, attributeList, fx, typeEntry);
            }

            // Now, to test the first deployment on an existing set
            // in this case, the truth of the matter is that `Two` only exists in the middle
            foreach (var fx in context.fx.Frameworks)
            {
                FrameworkTypeEntry typeEntry = fx.Types.First();

                string[] attributeList = new[] { "One" };

                if (fx.IsFirstFramework)
                {
                    attributeList = new[] { "One", "Two" };
                }

                MDocUpdater.MakeAttributes(context.doc.FirstChild as XmlElement, attributeList, fx, typeEntry);
            }

            var attrNode   = context.doc.FirstChild.SelectSingleNode("Attributes");
            var attributes = attrNode.SelectNodes("Attribute").Cast <XmlElement> ().ToArray();

            Assert.IsTrue(attributes.Count() == 2);
            Assert.AreEqual("One", attributes[0].FirstChild.InnerText);
            Assert.IsFalse(attributes[0].HasAttribute(Consts.FrameworkAlternate));
            Assert.AreEqual("Two", attributes[1].FirstChild.InnerText);
            Assert.IsTrue(attributes[1].HasAttribute(Consts.FrameworkAlternate));
            Assert.AreEqual("One", attributes[1].GetAttribute(Consts.FrameworkAlternate));
        }
Пример #5
0
        public void Attributes_Assembly_OtherAssembly()
        {
            var context = InitContext <MyClass> (string.Format(typeFrameXml, multiFrameworkXml), 2, forceAlignment: false);

            var fx = context.fx.Frameworks[1];


            FrameworkTypeEntry typeEntry = fx.Types.First();

            string[] attributeList = new[] { "One" };

            // this is the 'second' fx, and we've changed the expected assembly name,
            // so the attribute, while it doesn't exist yet, shouldn't have an FX made since it doesn't exist in any other FX
            MDocUpdater.MakeAttributes(context.doc.FirstChild as XmlElement, attributeList, fx, typeEntry);


            var attrNode   = context.doc.FirstChild.SelectSingleNode("Attributes");
            var attributes = attrNode.SelectNodes("Attribute").Cast <XmlElement> ().ToArray();

            Assert.IsTrue(attributes.Count() == 1);
            Assert.AreEqual("One", attributes[0].FirstChild.InnerText);
            Assert.IsTrue(attributes[0].HasAttribute(Consts.FrameworkAlternate));
        }