Пример #1
0
        public void CorrectlyReadsStringColumn()
        {
            string fileContents = "String Column\r\nKevin\r\nHurwitz\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.GetString("String Column"), Is.EqualTo("Kevin"));

                canRead = reader.Read();
                Assert.That(canRead, Is.EqualTo(true));
                Assert.That(reader.GetString("String Column"), Is.EqualTo("Hurwitz"));

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

            mocks.VerifyAll();
        }
Пример #2
0
		public void CanReadEmptyString()
		{
			string fileContents = "StringColumn1\tStringColumn2\r\nString 1";

			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.GetString("StringColumn2"), Is.EqualTo(string.Empty));

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

			mocks.VerifyAll();
		}