public void BatchRecordFormatter_FormatAll_1() { string database = "IBIS"; int batchSize = 500; string format = "Format"; Mock <IIrbisConnection> mock = GetMock(); IIrbisConnection connection = mock.Object; BatchRecordFormatter batch = (BatchRecordFormatter)BatchRecordFormatter.Interval ( connection, database, format, 1, 3, batchSize ); List <string> formatted = batch.FormatAll(); Assert.AreEqual(3, batch.RecordsFormatted); Assert.AreEqual(3, formatted.Count); Assert.AreEqual("Format IBIS 1", formatted[0]); Assert.AreEqual("Format IBIS 2", formatted[1]); Assert.AreEqual("Format IBIS 3", formatted[2]); mock.Verify(c => c.GetMaxMfn(It.IsAny <string>()), Times.Once); mock.Verify(c => c.FormatRecords(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <IEnumerable <int> >()), Times.Once); }
public void BatchRecordFormatter_FormatAll_2() { string connectionString = "Connection String"; string database = "IBIS"; int batchSize = 500; string format = "Format"; Mock <IIrbisConnection> mock = GetMock(); IIrbisConnection connection = mock.Object; Func <string, IIrbisConnection> previousCreator = ConnectionFactory.ConnectionCreator; ConnectionFactory.ConnectionCreator = cs => connection; try { BatchRecordFormatter batch = new BatchRecordFormatter ( connectionString, database, format, batchSize, Enumerable.Range(1, 3) ); List <string> formatted = batch.FormatAll(); Assert.AreEqual(3, batch.RecordsFormatted); Assert.AreEqual(3, formatted.Count); Assert.AreEqual("Format IBIS 1", formatted[0]); Assert.AreEqual("Format IBIS 2", formatted[1]); Assert.AreEqual("Format IBIS 3", formatted[2]); } finally { ConnectionFactory.ConnectionCreator = previousCreator; } mock.Verify(c => c.GetMaxMfn(It.IsAny <string>()), Times.Never); mock.Verify(c => c.FormatRecords(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <IEnumerable <int> >()), Times.Once); }