1 /*----------------------------------------------------------------------------
2 Name: KeyTest.cs
3 Project: xmlBlaster.org
4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
5 Comment: Test cases for Qos.cs
6 Author: "Marcel Ruff" <xmlBlaster@marcelruff.info>
7 Date: 12/2006
8 See: http://www.xmlblaster.org/xmlBlaster/doc/requirements/interface.html
9 -----------------------------------------------------------------------------*/
10 using System;
11 using System.Collections.Generic;
12 using System.Text;
13 using NUnit.Framework;
14 using System.Reflection;
15 using System.Collections;
16
17 namespace org.xmlBlaster.client
18 {
19 [TestFixture]
20 public class KeyTest
21 {
22 [Test]
23 public void CheckComplete()
24 {
25 string clientTags =
26 "<AGENT id='192.168.124.20' subId='1' type='generic'>"
27 + "<DRIVER id='FileProof' pollingFreq='10'/>"
28 + "</AGENT>";
29 string keyStr =
30 "<key oid='4711' contentMime='text/xml' contentMimeExtended='V1.0'>"
31 + clientTags
32 + "</key>";
33
34 MsgKey key = new MsgKey(keyStr);
35 Assert.AreEqual("4711", key.GetOid());
36 Assert.AreEqual("text/xml", key.GetContentMime());
37 Assert.AreEqual("V1.0", key.GetContentMimeExtended());
38 Assert.AreEqual(false, key.IsAdministrative());
39 Assert.AreEqual(false, key.IsDeadMessage());
40 Assert.AreEqual(true, key.IsDefaultDomain());
41 #if XMLBLASTER_MONO
42 #else
43 string inner = key.GetClientTags();
44 //We need a XMLUnit ...
45 //Assert.AreSame(clientTags.Trim(), inner.Trim());
46 StringAssert.Contains("AGENT", inner);
47 StringAssert.Contains("DRIVER", inner);
48 #endif
49 }
50
51 [Test]
52 public void CheckEmpty()
53 {
54 string keyStr = "";
55 MsgKey key = new MsgKey(keyStr);
56 Assert.IsNotNull(key);
57 }
58
59 [ExpectedException(typeof(System.Xml.XmlException))]
60 [Test]
61 public void CheckInvalid()
62 {
63 string keyStr = "<keydstf>";
64 MsgKey key = new MsgKey(keyStr);
65 Assert.AreEqual("sdf", key.GetOid());
66 }
67
68 [Test]
69 public void CheckStatusKey()
70 {
71 string keyStr = "<key oid='' queryType='XPATH' domain='some'>"
72 + " //something"
73 + "</key>";
74 StatusKey key = new StatusKey(keyStr);
75 Assert.AreEqual("XPATH", key.GetQueryType());
76 Assert.AreEqual("//something", key.GetQueryString().Trim());
77 Assert.AreEqual("some", key.GetDomain());
78 Assert.AreEqual(false, key.IsDefaultDomain());
79 Assert.AreEqual("xpath://something", key.GetUrl());
80 }
81 }
82 }
syntax highlighted by Code2HTML, v. 0.9.1