2003-10-12 Todd Berman <tberman@gentoo.org>
authorTodd Berman <tberman@mono-cvs.ximian.com>
Sun, 12 Oct 2003 19:03:49 +0000 (19:03 -0000)
committerTodd Berman <tberman@mono-cvs.ximian.com>
Sun, 12 Oct 2003 19:03:49 +0000 (19:03 -0000)
* Adding tests and modifying makefile to work with make test

svn path=/trunk/mcs/; revision=18922

mcs/class/Microsoft.Web.Services/ChangeLog
mcs/class/Microsoft.Web.Services/Makefile
mcs/class/Microsoft.Web.Services/Microsoft.Web.Services.1_test.dll [new file with mode: 0755]
mcs/class/Microsoft.Web.Services/Microsoft.Web.Services.2_test.dll.sources [new file with mode: 0644]
mcs/class/Microsoft.Web.Services/Test/Microsoft.Web.Services.Addressing/Action.cs [new file with mode: 0644]
mcs/class/Microsoft.Web.Services/Test/Microsoft.Web.Services.Addressing/Address.cs [new file with mode: 0644]
mcs/class/Microsoft.Web.Services/Test/Microsoft.Web.Services.Addressing/AddressList.cs [new file with mode: 0644]
mcs/class/Microsoft.Web.Services/Test/Microsoft.Web.Services.Addressing/AddressingHeaders.cs [new file with mode: 0644]
mcs/class/Microsoft.Web.Services/Test/Microsoft.Web.Services.Addressing/EndpointReference.cs [new file with mode: 0644]

index 9367df3e5963939dac23b9d410e475dc65e6d20a..82b2a5c7c5784778ead1da71b04dd39a786a222e 100644 (file)
@@ -1,3 +1,7 @@
+2003-10-12  Todd Berman <tberman@gentoo.org>
+
+       * Makefile: Fixed up the test target so it works now
+
 2003-10-08  Todd Berman <tberman@gentoo.org>
 
        * Microsoft.Web.Services.dll2.sources: Added RelatesTo.cs
index 49f99022d8a270d729177fe6b21ab34be0ec0f8d..ac2b2c689b64227579154d493a93367616c34ebc 100644 (file)
@@ -34,15 +34,15 @@ ifndef NO_TEST
 test_lib = $(patsubst %.dll,%_test.dll,$(LIBRARY))
 test_lib2 = $(patsubst %.dll, %_test.dll,$(LIBRARY2))
 test_pdb = $(patsubst %.dll,%.pdb,$(test_lib))
-test_pdb = $(patsubst %.dll,%.pdb,$(test_lib2))
+test_pdb2 = $(patsubst %.dll,%.pdb,$(test_lib2))
 test_sourcefile = $(test_lib).sources
-test_sourcefile2 = Microsoft.Web.Services.dll.2.sources
+test_sourcefile2 = $(test_lib2).sources
 test_response = $(depsdir)/$(test_lib).response
-test_response2 = $(depsdir)/$(test_lib2).response
+test_response2 = $(depsdir)/a.response
 test_makefrag = $(depsdir)/$(test_lib).makefrag
-test_makefrag2 = $(depsdir)/$(test_lib2).makefrag
+test_makefrag2 = $(depsdir)/a.makefrag
 test_stampfile = $(depsdir)/$(test_lib).stamp
-test_stampfile2 = $(depsdir)/$(test_lib2).stamp
+test_stampfile2 = $(depsdir)/a.stamp
 test_flags = /r:$(the_lib) /r:$(topdir)/class/lib/NUnit.Framework.dll $(TEST_MCS_FLAGS)
 test_flags2 = /r:$(the_lib2) /r:$(topdir)/class/lib/NUnit.Framework.dll $(TEST_MCS_FLAGS)
 endif
@@ -77,13 +77,13 @@ ifdef PLATFORM_CHANGE_SEPARATOR_CMD
 endif
 
 ifndef NO_TEST
-test-local: $(the_lib) $(test_lib)
+test-local: $(the_lib) $(test_lib) $(the_lib2) $(test_lib2) 
 
 run-test-local:
        $(TEST_RUNTIME) $(TEST_HARNESS) $(test_lib)
 
 else
-test-local: $(the_lib)
+test-local: $(the_lib) $(the_lib2)
 
 run-test-local:
 endif
@@ -94,6 +94,7 @@ ifdef NO_TEST
 TEST_FILES = 
 else
 TEST_FILES = `cat $(test_sourcefile) |sed -e 's,^\(.\),Test/\1,'`
+TEST_FILES2 = `cat $(test_sourcefile2) |sed -e 's,^\(.\),Test/\1,'`
 endif
 
 dist-local: dist-default
@@ -192,3 +193,31 @@ $(test_stampfile):
        touch $@
 endif
 
+ifndef NO_TEST
+$(test_lib2): $(test_makefrag2) $(the_lib2) $(test_response2) $(test_stampfile2)
+       $(CSCOMPILE) /target:library /out:$@ $(test_flags2) @$(test_response2)
+
+$(test_response2): $(test_sourcefile2)
+       @echo Creating $@ ...
+ifdef PLATFORM_CHANGE_SEPARATOR_CMD
+       @cat $< |sed -e 's,^\(.\),Test/\1,' |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
+else
+       @cat $< |sed -e 's,^\(.\),Test/\1,' >$@
+endif
+
+$(test_makefrag2): $(test_response2)
+       @echo Creating $@ ...
+       @echo "HAVE_TEST_MAKEFRAG = yes" >$@.new
+       @echo "$(test_stampfile2): \\" >>$@.new
+       @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
+       @cat $@.new |sed -e '$$s, \\$$,,' >$@
+       @$(ECHO_ESCAPE) "\ttouch \$$@" >>$@
+       @rm -rf $@.new
+
+-include $(test_makefrag2)
+endif
+#
+ifndef HAVE_TEST_MAKEFRAG
+$(test_stampfile2):
+       touch $@
+endif
diff --git a/mcs/class/Microsoft.Web.Services/Microsoft.Web.Services.1_test.dll b/mcs/class/Microsoft.Web.Services/Microsoft.Web.Services.1_test.dll
new file mode 100755 (executable)
index 0000000..7c6f640
Binary files /dev/null and b/mcs/class/Microsoft.Web.Services/Microsoft.Web.Services.1_test.dll differ
diff --git a/mcs/class/Microsoft.Web.Services/Microsoft.Web.Services.2_test.dll.sources b/mcs/class/Microsoft.Web.Services/Microsoft.Web.Services.2_test.dll.sources
new file mode 100644 (file)
index 0000000..1bb2211
--- /dev/null
@@ -0,0 +1,5 @@
+Microsoft.Web.Services.Addressing/Action.cs
+Microsoft.Web.Services.Addressing/Address.cs
+Microsoft.Web.Services.Addressing/AddressingHeaders.cs
+Microsoft.Web.Services.Addressing/AddressList.cs
+Microsoft.Web.Services.Addressing/EndpointReference.cs
diff --git a/mcs/class/Microsoft.Web.Services/Test/Microsoft.Web.Services.Addressing/Action.cs b/mcs/class/Microsoft.Web.Services/Test/Microsoft.Web.Services.Addressing/Action.cs
new file mode 100644 (file)
index 0000000..ce4aa4d
--- /dev/null
@@ -0,0 +1,99 @@
+using System;\r
+using NUnit.Framework;\r
+using System.Xml;\r
+using Microsoft.Web.Services;\r
+\r
+namespace Microsoft.Web.Services.Addressing.Tests\r
+{\r
+       \r
+       [TestFixture]\r
+       public class ActionTest\r
+       {\r
+               \r
+               [Test]\r
+               public void CreateAction ()\r
+               {\r
+                       Action a = new Action("urn:action:test");\r
+                       Assert.IsTrue (a.Value == "urn:action:test");\r
+               }\r
+               \r
+               [Test]\r
+               public void ActionToXml ()\r
+               {\r
+                       Action a = new Action("urn:action:test");\r
+                       XmlElement element = a.GetXml(new XmlDocument());\r
+                       Assert.IsTrue (element.OuterXml.Length != 0);\r
+               }\r
+               \r
+               [Test]\r
+               public void XmlToAction ()\r
+               {\r
+                       XmlDocument document = new XmlDocument ();\r
+                       \r
+                       XmlElement element = document.CreateElement("wsa", "Action", "http://schemas.xmlsoap.org/ws/2003/03/addressing");\r
+                       element.InnerText = "urn:action:test";\r
+                       \r
+                       Action a = new Action (element);\r
+                       \r
+                       Assert.IsTrue (a.Value == "urn:action:test");\r
+               }\r
+               \r
+               [Test]\r
+               public void RoundTripFromAction ()\r
+               {\r
+                       Action a = new Action ("urn:action:test");\r
+                       XmlElement element = a.GetXml(new XmlDocument());\r
+                       \r
+                       Action b = new Action (element);\r
+                       \r
+                       Assert.IsTrue (b.Value == "urn:action:test");\r
+               }\r
+               \r
+               [Test]\r
+               public void RoundTripFromXml ()\r
+               {\r
+                       XmlDocument document = new XmlDocument ();\r
+                       \r
+                       XmlElement element = document.CreateElement("wsa", "Action", "http://schemas.xmlsoap.org/ws/2003/03/addressing");\r
+                       element.InnerText = "urn:action:test";\r
+                       \r
+                       Action a = new Action (element);\r
+                       \r
+                       XmlElement element2 = a.GetXml(new XmlDocument ());\r
+                       \r
+                       Assert.IsTrue (element.OuterXml == element2.OuterXml);\r
+                       \r
+               }\r
+               \r
+               [Test]\r
+               public void ImplicitString ()\r
+               {\r
+                       Action a = new Action ("urn:action:test");\r
+                       \r
+                       Assert.IsTrue ("urn:action:test" == a);\r
+               }\r
+               \r
+               [Test]\r
+               public void ImplicitAction ()\r
+               {\r
+                       Action a = "urn:action:test";\r
+                       \r
+                       Assert.IsTrue ("urn:action:test" == a);\r
+                       \r
+               }\r
+               \r
+               [Test]\r
+               [ExpectedException(typeof(ArgumentException))]\r
+               public void InvalidElementExceptionTest ()\r
+               {\r
+                       XmlDocument doc = new XmlDocument ();\r
+                       \r
+                       XmlElement el = doc.CreateElement("b", "a", "d");\r
+                       \r
+                       Action a = new Action (el);\r
+               }\r
+               \r
+       }\r
+       \r
+       \r
+}\r
diff --git a/mcs/class/Microsoft.Web.Services/Test/Microsoft.Web.Services.Addressing/Address.cs b/mcs/class/Microsoft.Web.Services/Test/Microsoft.Web.Services.Addressing/Address.cs
new file mode 100644 (file)
index 0000000..5a37c76
--- /dev/null
@@ -0,0 +1,101 @@
+using System;\r
+using System.Xml;\r
+using NUnit.Framework;\r
+using Microsoft.Web.Services.Addressing;\r
+\r
+namespace Microsoft.Web.Services.Addressing.Tests\r
+{\r
+       \r
+       [TestFixture]\r
+       public class AddressTests\r
+       {\r
+               \r
+               [Test]\r
+               public void CreateAddress ()\r
+               {\r
+                       Address a = new Address (new Uri("soap.tcp://127.0.0.1/"));\r
+                       Assert.IsNotNull (a);\r
+               }\r
+               \r
+               [Test]\r
+               public void AddressToXml ()\r
+               {\r
+                       Address a = new Address (new Uri("soap.tcp://127.0.0.1/"));\r
+                       XmlElement e = a.GetXml (new XmlDocument ());\r
+                       \r
+                       Assert.IsTrue (e.OuterXml.Length != 0);\r
+               }\r
+               \r
+               [Test]\r
+               public void XmlToAddress ()\r
+               {\r
+                       XmlDocument doc = new XmlDocument ();\r
+                       XmlElement e = doc.CreateElement ("wsa", "Address", "http://schemas.xmlsoap.org/ws/2003/03/addressing");\r
+                       \r
+                       e.InnerText = "soap.tcp://127.0.0.1/";\r
+                       \r
+                       Address a = new Address (e);\r
+                       \r
+                       Assert.IsTrue (a.Value.AbsoluteUri == e.InnerText);\r
+               }\r
+               \r
+               [Test]\r
+               public void RoundTripFromAddress ()\r
+               {\r
+                       Address a = new Address (new Uri("soap.tcp://127.0.0.1"));\r
+                       \r
+                       XmlElement e = a.GetXml (new XmlDocument ());\r
+                       \r
+                       Address b = new Address (e);\r
+                       \r
+                       Assert.IsTrue (a.Value.AbsoluteUri == b.Value.AbsoluteUri);\r
+               }\r
+               \r
+               [Test]\r
+               public void RoundTripFromXml ()\r
+               {\r
+                       XmlDocument doc = new XmlDocument ();\r
+                       XmlElement e = doc.CreateElement ("wsa", "Address", "http://schemas.xmlsoap.org/ws/2003/03/addressing");\r
+                       \r
+                       e.InnerText = "soap.tcp://127.0.0.1/";\r
+                       \r
+                       Address a = new Address (e);\r
+                       \r
+                       XmlElement e2 = a.GetXml (new XmlDocument ());\r
+                       \r
+                       Assert.IsTrue (e.OuterXml == e2.OuterXml);\r
+               }\r
+               \r
+               [Test]\r
+               public void ImplicitUri ()\r
+               {\r
+                       Uri u = new Uri ("soap.tcp://127.0.0.1/");\r
+                       \r
+                       Address a = new Address(u);\r
+                       \r
+                       Assert.IsTrue (u.AbsoluteUri == ((Uri)a).AbsoluteUri);\r
+               }\r
+               \r
+               [Test]\r
+               public void ImplicitAddress ()\r
+               {\r
+                       Uri u = new Uri ("soap.tcp://127.0.0.1");\r
+                       \r
+                       Address a = new Address (u);\r
+                       \r
+                       Assert.AreEqual (u, (Uri)a);\r
+               }\r
+               \r
+               [Test]\r
+               [ExpectedException(typeof(ArgumentException))]\r
+               public void InvalidArgumentException()\r
+               {\r
+                       XmlDocument document = new XmlDocument ();\r
+                       XmlElement e = document.CreateElement ("b", "a", "d");\r
+                       \r
+                       Address a = new Address (e);\r
+               }\r
+               \r
+       }\r
+       \r
+}\r
diff --git a/mcs/class/Microsoft.Web.Services/Test/Microsoft.Web.Services.Addressing/AddressList.cs b/mcs/class/Microsoft.Web.Services/Test/Microsoft.Web.Services.Addressing/AddressList.cs
new file mode 100644 (file)
index 0000000..6196298
--- /dev/null
@@ -0,0 +1,15 @@
+using System;\r
+using NUnit.Framework;\r
+using Microsoft.Web.Services.Addressing;\r
+\r
+namespace Microsoft.Web.Services.Addressing.Tests\r
+{\r
+       [TestFixture]\r
+       public class AddressListTests\r
+       {\r
+               [Test]\r
+               public void NoTestsYet ()\r
+               {\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/Microsoft.Web.Services/Test/Microsoft.Web.Services.Addressing/AddressingHeaders.cs b/mcs/class/Microsoft.Web.Services/Test/Microsoft.Web.Services.Addressing/AddressingHeaders.cs
new file mode 100644 (file)
index 0000000..9554af8
--- /dev/null
@@ -0,0 +1,19 @@
+using System;\r
+using NUnit.Framework;\r
+using Microsoft.Web.Services.Addressing;\r
+\r
+namespace Microsoft.Web.Services.Addressing.Tests\r
+{\r
+       \r
+       [TestFixture]\r
+       public class AddressingHeadersTest\r
+       {\r
+               \r
+               [Test]\r
+               public void NoTestsYet ()\r
+               {\r
+               }\r
+               \r
+       }\r
+       \r
+}\r
diff --git a/mcs/class/Microsoft.Web.Services/Test/Microsoft.Web.Services.Addressing/EndpointReference.cs b/mcs/class/Microsoft.Web.Services/Test/Microsoft.Web.Services.Addressing/EndpointReference.cs
new file mode 100644 (file)
index 0000000..b7cc96d
--- /dev/null
@@ -0,0 +1,122 @@
+using System;\r
+using System.Xml;\r
+using NUnit.Framework;\r
+using Microsoft.Web.Services.Xml;\r
+using Microsoft.Web.Services.Addressing;\r
+\r
+namespace Microsoft.Web.Services.Addressing.Tests\r
+{\r
+       [TestFixture]\r
+       public class EndpointReferenceTests\r
+       {\r
+               \r
+               [Test]\r
+               public void CreateEndpointReferenceFromAddress ()\r
+               {\r
+                       EndpointReference e = new EndpointReference( new Address ( new Uri ("soap.tcp://127.0.0.1") ) );\r
+                       \r
+                       Assert.IsNotNull (e.Address.Value);\r
+               }\r
+               \r
+               [Test]\r
+               public void CreateEndpointReferenceFromUri ()\r
+               {\r
+                       EndpointReference e = new EndpointReference( new Uri ("soap.tcp://127.0.0.1") );\r
+                       \r
+                       Assert.IsNotNull (e.Address.Value);\r
+               }\r
+               \r
+               [Test]\r
+               public void MinimalXmlToEndpointReference ()\r
+               {\r
+                       XmlDocument doc = new XmlDocument ();\r
+                       XmlElement element = doc.CreateElement ("wsa", "EndpointReference", "http://schemas.xmlsoap.org/ws/2003/03/addressing");\r
+                       \r
+                       Address a = new Address ( new Uri ("soap.tcp://127.0.0.1") );\r
+                       \r
+                       element.AppendChild (a.GetXml (doc));\r
+                       \r
+                       EndpointReference e = new EndpointReference (element);\r
+               }\r
+               \r
+               [Test]\r
+               public void EndpointReferenceToMinimalXml ()\r
+               {\r
+                       EndpointReference e = new EndpointReference ( new Uri ("soap.tcp://127.0.0.1/") );\r
+                       XmlElement e2 = e.GetXml (new XmlDocument ());\r
+                       \r
+                       Assert.IsTrue (e2.FirstChild.InnerText == "soap.tcp://127.0.0.1/");\r
+               }\r
+               \r
+               [Test]\r
+               public void EndpointReferenceToXmlWithPortType ()\r
+               {\r
+                       EndpointReference e = new EndpointReference ( new Uri ("soap.tcp://127.0.0.1/") );\r
+                       e.PortType = new PortType (new QualifiedName ("a","s","http://schemas.xmlsoap.org/ws/2003/03/addressing"));\r
+                       \r
+                       XmlElement element = e.GetXml (new XmlDocument ());\r
+                       \r
+                       Assert.IsTrue (element.FirstChild.NextSibling.InnerText == "a:s");\r
+               }\r
+               \r
+               [Test]\r
+               public void EndpointReferenceToXmlWithProperties ()\r
+               {\r
+                       EndpointReference e = new EndpointReference (new Uri ("soap.tcp://127.0.0.1/") );\r
+                       e.ReferenceProperties = new ReferenceProperties ();\r
+                       \r
+                       XmlElement element = e.GetXml (new XmlDocument ());\r
+                       \r
+                       Assert.IsTrue (element.FirstChild.NextSibling.LocalName == "ReferenceProperties");\r
+               }\r
+               \r
+               [Test]\r
+               public void EndpointReferenceToXmlWithServiceName ()\r
+               {\r
+                       EndpointReference e = new EndpointReference (new Uri ("soap.tcp://127.0.0.1/") );\r
+                       e.ServiceName = new ServiceName( new QualifiedName ("a", "s", "http://schemas.xmlsoap.org/ws/2003/03/addressing"));\r
+                       e.ServiceName.PortName = "test";\r
+                       \r
+                       XmlElement element = e.GetXml (new XmlDocument ());\r
+                       \r
+                       Assert.IsTrue (element.FirstChild.NextSibling.Attributes["wsa:PortName"].InnerText == "test");\r
+               }\r
+               \r
+               [Test]\r
+               public void RoundTripFromXml ()\r
+               {\r
+                       XmlDocument doc = new XmlDocument ();\r
+                       XmlElement element = doc.CreateElement ("wsa", "EndpointReference", "http://schemas.xmlsoap.org/ws/2003/03/addressing");\r
+                       \r
+                       Address a = new Address ( new Uri ("soap.tcp://127.0.0.1") );\r
+                       \r
+                       element.AppendChild (a.GetXml (doc));\r
+                       \r
+                       PortType p = new PortType (new QualifiedName ("wsa", "s", "http://schemas.xmlsoap.org/ws/2003/03/addressing"));\r
+                       \r
+                       element.AppendChild (p.GetXml (doc));\r
+                       \r
+                       \r
+                       \r
+                       EndpointReference e = new EndpointReference (element);\r
+                       \r
+                       XmlElement e2 = e.GetXml (new XmlDocument ());\r
+                       \r
+                       Assert.IsTrue (element.OuterXml == e2.OuterXml);\r
+               }\r
+               \r
+               [Test]\r
+               public void RoundTripFromEndpointReference ()\r
+               {\r
+                       EndpointReference e = new EndpointReference ( new Uri ("soap.tcp://127.0.0.1/") );\r
+                       XmlElement e2 = e.GetXml (new XmlDocument ());\r
+                       \r
+                       EndpointReference er = new EndpointReference (e2);\r
+                       \r
+                       Assert.IsTrue (e.Address.Value.AbsoluteUri == er.Address.Value.AbsoluteUri);\r
+               }\r
+               \r
+               //Not going to bother testing the implicit operators, they work fine.\r
+               \r
+       }\r
+}\r