(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / Microsoft.Web.Services / Test / Microsoft.Web.Services.Timestamp / ReceivedTest.cs
blob7bec2c7987e16d82c6858b1c58295558a004e467
1 //
2 // ReceivedTest.cs - NUnit Test Cases for Received
3 //
4 // Author:
5 // Sebastien Pouliot (spouliot@motus.com)
6 //
7 // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
8 //
10 using NUnit.Framework;
11 using Microsoft.Web.Services.Timestamp;
12 using System;
13 using System.Xml;
15 // note: due to compiler confusion between classes and namespace (like Timestamp)
16 // I renamed the test namespace from "MonoTests.Microsoft.Web.Services.Timestamp"
17 // to "MonoTests.MS.Web.Services.Timestamp".
18 namespace MonoTests.MS.Web.Services.Timestamp {
20 [TestFixture]
21 public class ReceivedTest : Assertion {
23 [Test]
24 public void Constructor_Uri ()
26 Uri uri = new Uri ("http://www.go-mono.com/");
27 Received recv = new Received (uri);
28 AssertNotNull ("Received (uri)", recv);
31 [Test]
32 [ExpectedException (typeof (ArgumentNullException))]
33 public void Constructor_UriNull ()
35 Uri nullUri = null;
36 Received recv = new Received (nullUri);
39 [Test]
40 [ExpectedException (typeof (ArgumentNullException))]
41 public void Constructor_XmlElementNull ()
43 XmlElement nullXml = null;
44 Received recv = new Received (nullXml);
47 [Test]
48 public void Properties ()
50 string actor = "http://www.go-mono.com/";
51 Uri uri = new Uri (actor);
52 Received recv = new Received (uri);
54 AssertEquals ("Actor", actor, recv.Actor.AbsoluteUri);
55 // compare longs not objects !!!
56 AllTests.AssertEquals ("Delay", 0, recv.Delay);
57 // we dont check default value because it's UtcNow (too late ;-)
58 DateTime testDate = DateTime.FromFileTime (0xDEADC0DE); // 12/31/1600
59 recv.Value = testDate;
60 AssertEquals ("Value", testDate, recv.Value);
63 [Test]
64 public void Roundtrips ()
66 string actor = "http://www.go-mono.com/";
67 Uri uri = new Uri (actor);
68 Received recv = new Received (uri);
69 recv.Value = DateTime.FromFileTime (0xDEADC0DE); // 12/31/1600
71 XmlDocument doc = new XmlDocument ();
72 XmlElement xel = recv.GetXml (doc);
73 Assertion.AssertEquals ("Xml", "<wsu:Received xmlns:wsu=\"http://schemas.xmlsoap.org/ws/2002/07/utility\">1600-12-31T19:06:13Z</wsu:Received>", xel.OuterXml);
75 try {
76 Received recv2 = new Received (xel);
77 Assertion.Fail ("Expected TimestampFormatException but got none");
79 catch (TimestampFormatException e) {
80 // not logical but as documented
81 if (e.Message != TimestampFormatException.MissingActorAttributeInReceivedElement)
82 Assertion.Fail ("Invalid TimestampFormatException.Message -> MissingActorAttributeInReceivedElement");
84 catch (Exception e) {
85 Assertion.Fail ("Expected TimestampFormatException but got: " + e.ToString ());
88 try {
89 Received recv3 = new Received (uri);
90 recv3.LoadXml (xel);
91 Assertion.Fail ("Expected TimestampFormatException but got none");
93 catch (TimestampFormatException e) {
94 // not logical but as documented
95 if (e.Message != TimestampFormatException.MissingActorAttributeInReceivedElement)
96 Assertion.Fail ("Invalid TimestampFormatException.Message -> MissingActorAttributeInReceivedElement");
98 catch (Exception e) {
99 Assertion.Fail ("Expected TimestampFormatException but got: " + e.ToString ());
103 public void TestDelay ()
105 string actor = "http://www.go-mono.com/";
106 Uri uri = new Uri (actor);
107 Received recv = new Received (uri);
108 recv.Delay = 60;
109 recv.Value = DateTime.FromFileTime (0xDEADC0DE); // 12/31/1600
111 XmlDocument doc = new XmlDocument ();
112 XmlElement xel = recv.GetXml (doc);
113 // Actor isn't present
114 AssertEquals ("Xml", "<wsu:Received Delay=\"60\" xmlns:wsu=\"http://schemas.xmlsoap.org/ws/2002/07/utility\">1600-12-31T19:06:13Z</wsu:Received>", xel.OuterXml);
116 string xml = "<wsu:Received Actor=\"http://www.go-mono.com/\" Delay=\"60\" xmlns:wsu=\"http://schemas.xmlsoap.org/ws/2002/07/utility\">1600-12-31T19:06:13Z</wsu:Received>";
117 doc.LoadXml (xml);
119 // FIXME: Shouldn't need this - Bug in WSE ?
120 xel.SetAttribute (WSTimestamp.AttributeNames.Actor, actor);
121 Received recv2 = new Received (xel);
122 AssertEquals ("Actor", recv.Actor.AbsoluteUri, recv2.Actor.AbsoluteUri);
123 AssertEquals ("Delay", recv.Delay, recv2.Delay);
124 // compare DateTime not objects !!!
125 AllTests.AssertEquals ("Value", recv.Value, recv2.Value);
127 Received recv3 = new Received (uri);
128 recv3.LoadXml (doc.DocumentElement);
129 AssertEquals ("Actor", recv.Actor.AbsoluteUri, recv3.Actor.AbsoluteUri);
130 AssertEquals ("Delay", recv.Delay, recv3.Delay);
131 // compare DateTime not objects !!!
132 AllTests.AssertEquals ("Value", recv.Value, recv3.Value);