<commit_before>using System;
using System.Collections;
using System.Collections.Specialized;
using System.Data;
using MbUnit.Framework;

namespace UnitTests.Subtext
{
	[TestFixture]
	public class SelfTests
	{
		[Test]
		public void SingleResultStubDataReaderReturnsCorrectValues()
		{
DateTime testDate = DateTime.Now;
StubResultSet resultSet = new StubResultSet("col0", "col1", "col2");
resultSet.AddRow(1, "Test", testDate);
resultSet.AddRow(2, "Test2", testDate.AddDays(1));
			
StubDataReader reader = new StubDataReader(resultSet);

// Assertions			
Assert.AreEqual(1, reader["col0"], "Misread row 0, col 0.");
Assert.AreEqual("Test", reader["col1"], "Misread row 0, col 1.");
Assert.AreEqual(testDate, reader["col2"], "Misread row 0, col 3.");
			
			//Advance to first row.
			Assert.IsTrue(reader.Read(), "Expected data.");
			
			Assert.AreEqual(1, reader["col0"], "Misread row 0, col 0.");
			Assert.AreEqual("Test", reader["col1"], "Misread row 0, col 1.");
			Assert.AreEqual(testDate, reader["col2"], "Misread row 0, col 3.");
			Assert.AreEqual(1, reader.GetInt32(0), "Misread row 0, col 0.");
			Assert.AreEqual("Test", reader.GetString(1), "Misread row 0, col 1.");
			Assert.AreEqual(testDate, reader.GetDateTime(2), "Misread row 0, col 3.");
			Assert.AreEqual(1, reader[0], "Misread row 0, col 0.");
			Assert.AreEqual("Test", reader[1], "Misread row 0, col 1.");
			Assert.AreEqual(testDate, reader[2], "Misread row 0, col 3.");
			
			//Advance to second row.
			Assert.IsTrue(reader.Read(), "Expected data.");
			
			Assert.AreEqual(2, reader.GetInt32(0), "Misread row 1, col 0.");
			Assert.AreEqual("Test2", reader.GetString(1), "Misread row 1, col 1.");
			Assert.AreEqual(testDate.AddDays(1), reader.GetDateTime(2), "Misread row 1, col 3.");
			Assert.AreEqual(2, reader[0], "Misread row 1, col 0.");
			Assert.AreEqual("Test2", reader[1], "Misread row 1, col 1.");
			Assert.AreEqual(testDate.AddDays(1), reader[2], "Misread row 1, col 3.");
			Assert.AreEqual(2, reader["col0"], "Misread row 1, col 0.");
			Assert.AreEqual("Test2", reader["col1"], "Misread row 1, col 1.");
			Assert.AreEqual(testDate.AddDays(1), reader["col2"], "Misread row 1, col 3.");
		}
	}
	
	/// <summary>
	/// This class fakes up a data reader.
	/// </summary>
	public class StubDataReader : IDataReader
	{
		StubResultSetCollection stubResultSets;
		private int currentResultsetIndex = 0;
	
		/// <summary>
		/// Initializes a new instance of the <see cref="StubDataReader"/> class. 
		/// Each row in the arraylist is a result set.
		/// </summary>
		/// <param name="stubResultSets">The result sets.</param>
		public StubDataReader(StubResultSetCollection stubResultSets)
		{
			this.stubResultSets = stubResultSets;
		}
		
		/// <summary>
		/// Initializes a new instance of the <see cref="StubDataReader"/> class. 
		/// Each row in the arraylist is a result set.
		/// </summary>
		/// <param name="resultSet">The result sets.</param>
		public StubDataReader(StubResultSet resultSet)
		{
			this.stubResultSets = new StubResultSetCollection();
			this.stubResultSets.Add(resultSet);
		}

		public void Close()
		{
		}

		public bool NextResult()
		{
			if(currentResultsetIndex >= this.stubResultSets.Count)
				return false;
			
			return (++currentResultsetIndex < this.stubResultSets.Count);
		}<commit_msg>Added support and unit test for multi-result set functionality.<commit_after>using System;
using System.Collections;
using System.Collections.Specialized;
using System.Data;
using MbUnit.Framework;

namespace UnitTests.Subtext
{
	[TestFixture]
	public class SelfTests
	{
		[Test]
		public void SingleResultStubDataReaderReturnsCorrectValues()
		{
			DateTime testDate = DateTime.Now;
			StubResultSet resultSet = new StubResultSet("col0", "col1", "col2");
			resultSet.AddRow(1, "Test", testDate);
			resultSet.AddRow(2, "Test2", testDate.AddDays(1));
						
			StubDataReader reader = new StubDataReader(resultSet);

			//Advance to first row.
			Assert.IsTrue(reader.Read(), "Expected data.");
			
			Assert.AreEqual(1, reader["col0"], "Misread row 0, col 0.");
			Assert.AreEqual("Test", reader["col1"], "Misread row 0, col 1.");
			Assert.AreEqual(testDate, reader["col2"], "Misread row 0, col 3.");
			Assert.AreEqual(1, reader.GetInt32(0), "Misread row 0, col 0.");
			Assert.AreEqual("Test", reader.GetString(1), "Misread row 0, col 1.");
			Assert.AreEqual(testDate, reader.GetDateTime(2), "Misread row 0, col 3.");
			Assert.AreEqual(1, reader[0], "Misread row 0, col 0.");
			Assert.AreEqual("Test", reader[1], "Misread row 0, col 1.");
			Assert.AreEqual(testDate, reader[2], "Misread row 0, col 3.");
			
			//Advance to second row.
			Assert.IsTrue(reader.Read(), "Expected data.");
			
			Assert.AreEqual(2, reader.GetInt32(0), "Misread row 1, col 0.");
			Assert.AreEqual("Test2", reader.GetString(1), "Misread row 1, col 1.");
			Assert.AreEqual(testDate.AddDays(1), reader.GetDateTime(2), "Misread row 1, col 3.");
			Assert.AreEqual(2, reader[0], "Misread row 1, col 0.");
			Assert.AreEqual("Test2", reader[1], "Misread row 1, col 1.");
			Assert.AreEqual(testDate.AddDays(1), reader[2], "Misread row 1, col 3.");
			Assert.AreEqual(2, reader["col0"], "Misread row 1, col 0.");
			Assert.AreEqual("Test2", reader["col1"], "Misread row 1, col 1.");
			Assert.AreEqual(testDate.AddDays(1), reader["col2"], "Misread row 1, col 3.");
		}
		
		[Test]
		public void MultipleResultStubDataReaderReturnsCorrectValues()
		{
			DateTime testDate = DateTime.Now;
			StubResultSet resultSet = new StubResultSet("col0", "col1", "col2");
			resultSet.AddRow(1, "Test", testDate);
			
			StubResultSet anotherResultSet = new StubResultSet("first", "second");
			anotherResultSet.AddRow((decimal)1.618, "Foo");
			anotherResultSet.AddRow((decimal)2.718, "Bar");
			anotherResultSet.AddRow((decimal)3.142, "Baz");
						
			StubDataReader reader = new StubDataReader(resultSet, anotherResultSet);

			//Advance to first row.
			Assert.IsTrue(reader.Read(), "Expected data.");
			
			Assert.AreEqual(1, reader["col0"]);
			
			//Advance to second ResultSet.
			Assert.IsTrue(reader.NextResult(), "Expected next result set");
			
			//Advance to first row.
			Assert.IsTrue(reader.Read(), "Expected data.");
			Assert.AreEqual((decimal)1.618, reader["first"]);
			Assert.AreEqual("Foo", reader["second"]);
			Assert.IsTrue(reader.Read(), "Expected data.");
			Assert.AreEqual((decimal)2.718, reader["first"]);
			Assert.AreEqual("Bar", reader["second"]);
			Assert.IsTrue(reader.Read(), "Expected data.");
			Assert.AreEqual((decimal)3.142, reader["first"]);
			Assert.AreEqual("Baz", reader["second"]);
		}
	}
	
	/// <summary>
	/// This class fakes up a data reader.
	/// </summary>
	public class StubDataReader : IDataReader
	{
		StubResultSetCollection stubResultSets;
		private int currentResultsetIndex = 0;
	
		/// <summary>
		/// Initializes a new instance of the <see cref="StubDataReader"/> class. 
		/// Each row in the arraylist is a result set.
		/// </summary>
		/// <param name="stubResultSets">The result sets.</param>
		public StubDataReader(StubResultSetCollection stubResultSets)
		{
			this.stubResultSets = stubResultSets;
		}
	
		/// <summary>
		/// Initializes a new instance of the <see cref="StubDataReader"/> class. 
		/// Each row in the arraylist is a result set.
		/// </summary>
		/// <param name="resultSets">The result sets to add.</param>
		public StubDataReader(params StubResultSet[] resultSets)
		{
			this.stubResultSets = new StubResultSetCollection();
			foreach(StubResultSet resultSet in resultSets)
			{
				this.stubResultSets.Add(resultSet);
			}
		}

		public void Close()
		{
		}

		public bool NextResult()
		{
			if(currentResultsetIndex >= this.stubResultSets.Count)
				return false;
			
			return (++currentResultsetIndex < this.stubResultSets.Count);
		}
{'fraction_non_alphanumeric': 0.15795527156549521, 'fraction_numerical': 0.025047923322683706, 'mean_word_length': 4.06537216828479, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3515669', 'n_tokens_mistral': 2996, 'n_tokens_neox': 2599, 'n_words': 654}