Example #1
0
        public void CorrectlyReadsMultiColumnTable()
        {
            string fileContents = "Column 1\tColumn 2\r\n80\t85";

            MockRepository       mocks       = new MockRepository();
            IResourceFileLocator fileLocator = mocks.CreateMock <IResourceFileLocator>();

            Expect.Call(fileLocator.ReadTextFile("MyCompany.MyAssembly", _testDataFile)).Return(fileContents);

            mocks.ReplayAll();

            using (IDataFileReader reader = new DataFileReader(fileLocator))
            {
                reader.Open("MyCompany.MyAssembly", "Test", "DataFilePath");

                bool canRead = reader.Read();
                Assert.That(canRead, Is.EqualTo(true));
                Assert.That(reader.GetInteger("Column 1"), Is.EqualTo(80));
                Assert.That(reader.GetInteger("Column 2"), Is.EqualTo(85));

                canRead = reader.Read();
                Assert.That(canRead, Is.EqualTo(false));
            }

            mocks.VerifyAll();
        }
		public void CorrectlyReadsIntegerColumn()
		{
			string fileContents = "Integer Column\r\n80\r\n85\r\n";

			MockRepository mocks = new MockRepository();
			IResourceFileLocator fileLocator = mocks.CreateMock<IResourceFileLocator>();
			Expect.Call(fileLocator.ReadTextFile("MyCompany.MyAssembly", _testDataFile)).Return(fileContents);

			mocks.ReplayAll();

			using (IDataFileReader reader = new DataFileReader(fileLocator))
			{
				reader.Open("MyCompany.MyAssembly", "Test", "DataFilePath");

				bool canRead = reader.Read();
				Assert.That(canRead, Is.EqualTo(true));
				Assert.That(reader.GetInteger("Integer Column"), Is.EqualTo(80));

				canRead = reader.Read();
				Assert.That(canRead, Is.EqualTo(true));
				Assert.That(reader.GetInteger("Integer Column"), Is.EqualTo(85));

				canRead = reader.Read();
				Assert.That(canRead, Is.EqualTo(false));
			}

			mocks.VerifyAll();
		}
Example #3
0
        public void CorrectlyThrowsExceptionIfUnknownColumnSpecified()
        {
            string fileContents = "My Good Column Name\r\nMy Data\r\n";

            MockRepository       mocks       = new MockRepository();
            IResourceFileLocator fileLocator = mocks.CreateMock <IResourceFileLocator>();

            Expect.Call(fileLocator.ReadTextFile("MyCompany.MyAssembly", _testDataFile)).Return(fileContents);

            mocks.ReplayAll();

            using (IDataFileReader reader = new DataFileReader(fileLocator))
            {
                reader.Open("MyCompany.MyAssembly", "Test", "DataFilePath");

                reader.Read();
                reader.GetInteger("My Bad Column Name");
            }
        }
		public void CorrectlyThrowsExceptionIfUnknownColumnSpecified()
		{
			string fileContents = "My Good Column Name\r\nMy Data\r\n";

			MockRepository mocks = new MockRepository();
			IResourceFileLocator fileLocator = mocks.CreateMock<IResourceFileLocator>();
			Expect.Call(fileLocator.ReadTextFile("MyCompany.MyAssembly", _testDataFile)).Return(fileContents);

			mocks.ReplayAll();

			using (IDataFileReader reader = new DataFileReader(fileLocator))
			{
				reader.Open("MyCompany.MyAssembly", "Test", "DataFilePath");

				reader.Read();
				reader.GetInteger("My Bad Column Name");
			}
		}