FileReaderUnitTest.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 » FileReaderUnitTest.cs
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.IO;
using Systin.Library;

namespace Systin.Library.UnitTests{
    [TestFixture]
    public class FileReaderUnitTest
    {
        const string  PathToTestTextFile = @"E:\Projects\Systin\TestDirectory\TestSuite\Test.txt";
        const string ExpectedTextContained = @"Test_Method_called";

        /// <summary>
        /// Loadeds the test file does not return null value.
        /// </summary>
        [Test]
        [Category("FileAccess")]
        public void LoadedTestFileDoesNotReturnNullValue()
        {
            TestFileLoader readFile = this.LoadTestTextFile();
            Assert.IsNotNull(readFile, "Attempt to read test file resulted in null object returned");
        }
        /// <summary>
        /// Loadeds the test file contains expected string.
        /// </summary>
        
        [Test]
        public void FileReaderFactoryCreatorCreatesEmptyFileReaderObject()
        {
            TestFileLoader file = TestFileLoader.Factory();
            Assert.IsNotNull(file, "The File reader object returned is null when it should not be");
            Assert.AreEqual(file.FileName, String.Empty, "TestFileName is not empty");
        }
        /// <summary>
        /// Opens the test file method accepts test file info as input.
        /// </summary>
        [Test]
        [Category("FileAccess")]
        public void OpenTestFileMethodAcceptsTestFileInfoAsInput()
        {
            FileInfo file = new FileInfo(PathToTestTextFile);
            TestFileLoader testInputFile = TestFileLoader.OpenTestFile(file);
            Assert.AreEqual(testInputFile.FileHandle.FullName, PathToTestTextFile);
        }
        /// <summary>
        /// Attempts to load instructions with A null file reader object.
        /// </summary>
        [Test]
        [ExpectedException(typeof(ArgumentException))]
        public void AttemptToLoadInstructionsWithANullFileReaderObject()
        {
            TestFileLoader emptyInputFile = TestFileLoader.Factory();
            TestFileLoader.LoadInstructionFileContent(emptyInputFile);
        }

        /// <summary>
        /// Gets the instructions from A valid test input file.
        /// </summary>
        [Test]
        [Category("FileAccess")]
        [Ignore("Instructions object on inputFile value is null for some reason")]
        public void GetInstructionsFromAValidTestInputFile()
        {
            TestFileLoader inputFile = this.LoadTestTextFile();
            TestFileLoader.LoadInstructionFileContent(inputFile);
            Assert.IsTrue(inputFile.TestFileContent.Length > 0);
            Assert.IsTrue(inputFile.Instructions.Count > 0);
        }

        /// <summary>
        /// Opens the and process input file processes test input correctly.
        /// </summary>
        [Test]
        [Category("FileAccess")]
        public void OpenAndProcessInputFileProcessesTestInputCorrectly()
        {            
            TestFileLoader inputFile = TestFileLoader.OpenAndProcessInputFile(this.GetTestFileInfoObject());
            Assert.IsTrue(inputFile.TestFileContent.Length > 0);
        }

        [Test]
        [ExpectedException(typeof(ArgumentNullException))]
        public void LoadContentsWithANullFile()
        {
            TestFileLoader.LoadInstructionFileContent(null);
        }
        

        #region Helper methods
        private FileInfo GetTestFileInfoObject()
        {
            return new FileInfo(PathToTestTextFile);
        }
        private TestFileLoader LoadTestTextFile()
        {
            return (TestFileLoader.OpenTestFile(new FileInfo(PathToTestTextFile)));
        } 
        #endregion

    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.