diff options
author | Joel Martinez <joelmartinez@gmail.com> | 2018-06-14 21:35:29 +0300 |
---|---|---|
committer | Joel Martinez <joelmartinez@gmail.com> | 2018-06-19 00:32:22 +0300 |
commit | 00775ff1a51447ca0bd888924e01ca06d034e412 (patch) | |
tree | 91bf219c64ce29ecd927f1021ae6112ff4aea475 /mdoc/mdoc.Test/XmlUpdateTests.cs | |
parent | 1b1a49d8322929c0876c5da9ef8f02d01a9215c4 (diff) |
revert fix for #76.
Commit being reverted - f92ac8bcf7f4c0f7c1f12c3d23c1e5a829d7041d
Diffstat (limited to 'mdoc/mdoc.Test/XmlUpdateTests.cs')
-rw-r--r-- | mdoc/mdoc.Test/XmlUpdateTests.cs | 343 |
1 files changed, 8 insertions, 335 deletions
diff --git a/mdoc/mdoc.Test/XmlUpdateTests.cs b/mdoc/mdoc.Test/XmlUpdateTests.cs index 39f58663..4d4aba38 100644 --- a/mdoc/mdoc.Test/XmlUpdateTests.cs +++ b/mdoc/mdoc.Test/XmlUpdateTests.cs @@ -8,45 +8,29 @@ using System.Collections.Generic; using Mono.Documentation.Updater.Frameworks; using Mono.Documentation.Updater; -namespace mdoc.Test +namespace mdoc.Test2 { - public class OneAttribute : Attribute { } - public class TwoAttribute : Attribute { } - - [One] public class MyClass { - [One] - public void Meth (int a, string d, int c) { } - + public void Meth (int a, string b, int c) { } } public class MyClass2 { - public void Meth (int a, string b, int c) { } + public void Meth (int d, string e, int f) { } } - } - -namespace mdoc.Test2 +namespace mdoc.Test { - using mdoc.Test; - - [One, Two] public class MyClass { - [One, Two] - public void Meth (int a, string b, int c) { } - } + public void Meth(int a, string d, int c) {} - [Two] + } public class MyClass2 { - [Two] - public void Meth (int d, string e, int f) { } + public void Meth (int a, string b, int c) { } } -} -namespace mdoc.Test -{ + /// <summary> /// Tests functions that update the EcmaXMl under various conditions from /// corresponding classes. @@ -428,313 +412,6 @@ namespace mdoc.Test Assert.IsTrue (matches.Any (m => m.Member == context.method && m.Node != null), "didn't match the member"); } - [Test] - 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, context.method.DeclaringType, 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)); - } - - [Test] - public void Attributes_TypeOrMethod_AllFX () - { - var context = InitContext<MyClass> (string.Format (typeFrameXml, multiFrameworkXml), 2, forceAlignment: false); - - foreach (var fx in context.fx.Frameworks) - { - //var fx = context.fx.Frameworks[1]; - FrameworkTypeEntry typeEntry = fx.Types.First (); - - string[] attributeList = new[] { "One" }; - - MDocUpdater.MakeAttributes (context.doc.FirstChild as XmlElement, attributeList, fx, context.method.DeclaringType, 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.IsFalse (attributes[0].HasAttribute (Consts.FrameworkAlternate)); - } - - [Test] - public void Attributes_TypeOrMethod_AllFX_OneMissing () - { - var context = InitContext<MyClass> (string.Format (typeFrameXml, multiFrameworkXml), 2, forceAlignment: false); - - foreach (var fx in context.fx.Frameworks) - { - //var fx = context.fx.Frameworks[1]; - FrameworkTypeEntry typeEntry = fx.Types.First (); - - string[] attributeList = new[] { "One" }; - - if (fx.IsFirstFramework) - attributeList = new string[0]; - - MDocUpdater.MakeAttributes (context.doc.FirstChild as XmlElement, attributeList, fx, context.method.DeclaringType, 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 ("Three;Two", attributes[0].GetAttribute (Consts.FrameworkAlternate)); - } - - [Test] - public void Attributes_TypeOrMethod_AllFX_OneMissing_Last () - { - var context = InitContext<MyClass> (string.Format (typeFrameXml, multiFrameworkXml), 2, forceAlignment: false); - - foreach (var fx in context.fx.Frameworks) - { - //var fx = context.fx.Frameworks[1]; - FrameworkTypeEntry typeEntry = fx.Types.First (); - - string[] attributeList = new[] { "One" }; - - if (fx.IsLastFramework) - attributeList = new string[0]; - - MDocUpdater.MakeAttributes (context.doc.FirstChild as XmlElement, attributeList, fx, context.method.DeclaringType, 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;Three", attributes[0].GetAttribute (Consts.FrameworkAlternate)); - } - - [Test] - public void Attributes_TypeOrMethod_AllFX_RunExisting_Middle () - { - 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, context.method.DeclaringType, 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 && !fx.IsLastFramework) { - attributeList = new[] { "One", "Two" }; - } - - MDocUpdater.MakeAttributes (context.doc.FirstChild as XmlElement, attributeList, fx, context.method.DeclaringType, 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 ("Three", attributes[1].GetAttribute (Consts.FrameworkAlternate)); - } - - [Test] - 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, context.method.DeclaringType, 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, context.method.DeclaringType, 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)); - } - - [Test] - public void Attributes_TypeOrMethod_AllFX_RunExisting_Last () - { - 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, context.method.DeclaringType, 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[] { "Two" }; - - if (fx.IsLastFramework) - { - attributeList = new[] { "One", "Two" }; - } - - MDocUpdater.MakeAttributes (context.doc.FirstChild as XmlElement, attributeList, fx, context.method.DeclaringType, 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[1].FirstChild.InnerText); - Assert.IsTrue (attributes[1].HasAttribute (Consts.FrameworkAlternate)); - Assert.AreEqual ("Two", attributes[1].GetAttribute (Consts.FrameworkAlternate)); - Assert.AreEqual ("Two", attributes[0].FirstChild.InnerText); - Assert.IsFalse (attributes[0].HasAttribute (Consts.FrameworkAlternate)); - - } - - [Test] - public void Attributes_TypeOrMethod_AllFX_OneMissing_Middle () - { - var context = InitContext<MyClass> (string.Format (typeFrameXml, multiFrameworkXml), 2, forceAlignment: false); - - foreach (var fx in context.fx.Frameworks) - { - //var fx = context.fx.Frameworks[1]; - 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, context.method.DeclaringType, 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)); - } - - - [Test] - 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" }; - string assemblyName = "one.dll"; - if (!fx.IsLastFramework && !fx.IsFirstFramework) - { - attributeList = new string[0]; - assemblyName = "three.dll"; - } - - - MDocUpdater.MakeAttributes (context.doc.FirstChild as XmlElement, attributeList, fx, - - assemblyFilename: "three.dll"); - } - - 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)); - } - - [Test] - 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, - assemblyFilename: "three.dll"); - - - 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.IsFalse (attributes[0].HasAttribute (Consts.FrameworkAlternate)); - } - string Normalize(string xml) { XmlDocument doc = new XmlDocument (); @@ -953,10 +630,6 @@ namespace mdoc.Test { var t = f.ProcessType (type); t.ProcessMember (method); - - var aset = new AssemblySet (new[] { "one.dll" }); - f.AddAssemblySet (aset); - } else { var t = f.ProcessType (type2); |