/*********************************************************************** * * Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; version 2.1 * of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, Novell, Inc. * * To contact Novell about this file by physical or electronic mail, * you may find current contact information at www.novell.com. * ***********************************************************************/ #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