using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using Systin.Library;
using System.Collections;
namespace Systin.Library.UnitTests{
[TestFixture]
public class InstructionParserUnitTest
{
#region private static String TestInputText
private static String TestInputText = @"launch_accounting_program
login_as_administrator
go_to_user_admin_panel
logout
verify_user_can_see personal_info_screen
verify_user_cannot_see user_admin_panel
logout
close_accounting_program";
#endregion
[Test]
public void ParseSingleMethodCallDoesNotReturnNull(){
string testMethod = @"Some_TestMethod.";
InstructionParser parser = InstructionParser.Parse(testMethod);
Assert.IsNotNull(parser.Instructions);
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void AttemptToParseNullValue()
{
InstructionParser.Parse(null);
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void NullInputStringObjectShouldThrowANullException()
{
InstructionParser.Parse(null);
}
[Test]
public void ParseSingleMethodCallReturnsCountOfOne(){
string testMethod = @"Some_TestMethod";
Queue<Instruction> parserQueue = ParseMessageAbstractTest(testMethod, 1);
//Assert that the instruction contained does not contain a period
Instruction instruction = parserQueue.Dequeue();
Assert.AreEqual(instruction.InstructionContent.ToString(), testMethod);
}
[Test]
public void parseMultipleMethodCallsResultingInFourInstructions()
{
Queue<Instruction> parserQueue = ParseMessageAbstractTest(TestInputText, 10);
}
private static Queue<Instruction> ParseMessageAbstractTest(string testMethod, int ExpectedCount)
{
InstructionParser parser = InstructionParser.Parse(testMethod);
//Assert only one message got parsed
Assert.AreEqual(parser.Instructions.Count, ExpectedCount);
Assert.AreEqual(parser.TestInput, testMethod, "Text To be parsed does not match text in InstructionParser Object");
return parser.Instructions;
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void TestMethodStringLengthOfZeroShouldThrowArgumentException()
{
InstructionParser.Parse("");
}
}
}
|