Exemplo n.º 1
0
        public void CorrectlyReadsEnumeratedTextFileColumnByValue()
        {
            string fileContents = "Persistence Mode\r\n1\r\n2\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.GetEnumerationByValue <PersistenceMode>("Persistence Mode"), Is.EqualTo(PersistenceMode.Live));

                canRead = reader.Read();
                Assert.That(canRead, Is.EqualTo(true));
                Assert.That(reader.GetEnumerationByValue <PersistenceMode>("Persistence Mode"), Is.EqualTo(PersistenceMode.Archive));

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

            mocks.VerifyAll();
        }
Exemplo n.º 2
0
		public void CorrectlyReadsEnumeratedTextFileColumnByValue()
		{
			string fileContents = "Persistence Mode\r\n1\r\n2\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.GetEnumerationByValue<PersistenceMode>("Persistence Mode"), Is.EqualTo(PersistenceMode.Live));

				canRead = reader.Read();
				Assert.That(canRead, Is.EqualTo(true));
				Assert.That(reader.GetEnumerationByValue<PersistenceMode>("Persistence Mode"), Is.EqualTo(PersistenceMode.Archive));

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

			mocks.VerifyAll();
		}