2009-06-26 Robert Jordan <robertj@gmx.net>
[mono.git] / mcs / class / System.Web.Services / Test / System.Web.Services.Description / OperationMessageCollectionTest.cs
1 //
2 // MonoTests.System.Web.Services.Description.OperationMessageCollectionTest.cs
3 //
4 // Author:
5 //   Erik LeBel <eriklebel@yahoo.ca>
6 //
7 // (C) 2003 Erik LeBel
8 //
9
10 using NUnit.Framework;
11
12 using System;
13 using System.Web.Services.Description;
14 using System.Xml;
15
16 namespace MonoTests.System.Web.Services.Description
17 {
18         [TestFixture]
19         public class OperationMessageCollectionTest
20         {
21                 OperationMessageCollection operations;
22
23                 [SetUp]
24                 public void InitializeOperation()
25                 {
26                         // workaround for internal constructor
27                         Operation op = new Operation();
28                         operations = op.Messages;
29                 }
30
31                 [Test]
32                 public void TestDefaultProperties()
33                 {
34                         Assert.AreEqual (OperationFlow.None, operations.Flow);
35                         Assert.IsNull (operations.Input);
36                         Assert.IsNull (operations.Output);
37                         Assert.AreEqual (0, operations.Count);
38                 }
39
40                 [Test]
41                 public void TestAddInput()
42                 {
43                         operations.Add(new OperationInput());
44                         
45                         Assert.AreEqual (OperationFlow.OneWay, operations.Flow);
46                         Assert.IsNotNull (operations.Input);
47                         Assert.IsNull (operations.Output);
48                         Assert.AreEqual (1, operations.Count);
49                 }
50                 
51                 [Test]
52                 public void TestAddOutput()
53                 {
54                         operations.Add(new OperationOutput());
55                         
56                         Assert.AreEqual (OperationFlow.Notification, operations.Flow);
57                         Assert.IsNull (operations.Input);
58                         Assert.IsNotNull (operations.Output);
59                         Assert.AreEqual (1, operations.Count);
60                 }
61
62                 [Test]
63                 public void TestAddInputAndOutput()
64                 {
65                         operations.Add(new OperationInput());
66                         operations.Add(new OperationOutput());
67                         
68                         Assert.AreEqual (OperationFlow.RequestResponse, operations.Flow);
69                         Assert.IsNotNull (operations.Input);
70                         Assert.IsNotNull (operations.Output);
71                         Assert.AreEqual (2, operations.Count);
72                 }
73
74                 [Test]
75                 public void TestAddOutputAndInput()
76                 {
77                         operations.Add(new OperationOutput());
78                         operations.Add(new OperationInput());
79                         
80                         Assert.AreEqual (OperationFlow.SolicitResponse, operations.Flow);
81                         Assert.IsNotNull (operations.Input);
82                         Assert.IsNotNull (operations.Output);
83                         Assert.AreEqual (2, operations.Count);
84                 }
85
86                 [Test]
87                 [ExpectedException (typeof (ArgumentException))]
88                 public void TestAddNull()
89                 {
90                         operations.Add(null);
91                 }
92                 
93                 [Test]
94                 [ExpectedException (typeof (ArgumentException))]
95                 public void TestAddFault()
96                 {
97                         operations.Add(new OperationFault());
98                 }
99
100                 [Test]
101                 [ExpectedException (typeof (InvalidOperationException))]
102                 public void TestAddInputAndInput()
103                 {
104                         operations.Add(new OperationInput());
105                         operations.Add(new OperationInput());
106                 }
107
108                 [Test]
109                 [ExpectedException (typeof (InvalidOperationException))]
110                 public void TestAddOutputAndOutput()
111                 {
112                         operations.Add(new OperationOutput());
113                         operations.Add(new OperationOutput());
114                 }
115
116                 [Test]
117                 [ExpectedException (typeof (InvalidOperationException))]
118                 public void TestAddThreeOperationMessages()
119                 {
120                         operations.Add(new OperationOutput());
121                         operations.Add(new OperationOutput());
122                         operations.Add(new OperationOutput());
123                 }
124
125                 [Test]
126                 [ExpectedException (typeof (ArgumentException))]
127                 public void TestAddInputAndFault()
128                 {
129                         operations.Add(new OperationInput());
130                         operations.Add(new OperationFault());
131                 }
132         }
133 }