CASA/c_micasad/test/common/TestRequestParser.cs
2005-10-11 19:51:00 +00:00

88 lines
1.5 KiB
C#

#if DEBUG
using System;
using System.Text;
using System.Collections;
//using System.InvalidOperationException;
using NUnit.Framework;
using sscs.common;
using sscs.verbs;
namespace sscs.cache
{
[TestFixture]
public class TestRequestParser
{
RequestParser reqParser = null;
[SetUp]
public void Init()
{
reqParser = new RequestParser();
}
[Test]
[ExpectedException(typeof(FormatException))]
public void TestNullRequest()
{
// SSVerb verb = reqParser.ParseRequest(null);
reqParser.ParseRequest(null);
}
[Test]
public void TestParseRequest()
{
// byte[] buf = new byte[1024];
//buf[0] = 1;
// buf[1] = 1;
int i =1;
byte[] dummy = BitConverter.GetBytes(i);
SSVerb verb = reqParser.ParseRequest(dummy);
Assert.AreEqual("sscs.verbs.OpenSecretStore", verb.GetVerbName());
i = 18;
dummy = BitConverter.GetBytes(i);
verb = reqParser.ParseRequest(dummy);
Assert.AreEqual("sscs.verbs.GetUserState", verb.GetVerbName());
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void TestParseRequestInvalid()
{
byte[] buf = new byte[1024] ;
buf[0] = 25;
buf[1] = 25;
// SSVerb verb = reqParser.ParseRequest(buf);
reqParser.ParseRequest(buf);
}
}
}
#endif