InstructionParserUnitTest.cs :  » Testing » SystiN » Systin.Library.UnitTests » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Testing » SystiN 
SystiN » Systin.Library.UnitTests » InstructionParserUnitTest.cs
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("");
        }
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.