public void PartsAreNotProcessedIfStartProcessFails()
 {
     var processor = new MultiPartDataProcess((x, y, z) =>
                             {
                                 Assert.Fail();
                                 return false;
                             },
                             x => false);
     var candidate = processor.ProcessData(TestData);
     Assert.IsFalse(candidate);
 }
 public void MultiplePartsAreProcessed()
 {
     var sb = new StringBuilder();
     var count = 1;
     var processor = new MultiPartDataProcess((x, y, z) =>
     {
         Assert.AreEqual(count++, y);
         sb.Append(x);
         return true;
     }, null, null, 3);
     var candidate = processor.ProcessData(TestData);
     Assert.AreEqual(TestData, sb.ToString());
     Assert.IsTrue(candidate);
 }
 public void TestSingleChunkIsProcessed()
 {
     var sb = new StringBuilder();
     var processor = new MultiPartDataProcess((x, y, z) =>
         {
             Assert.AreEqual(1, y);
             Assert.AreEqual(1, z);
             sb.Append(x);
             return true;
         });
     var candidate = processor.ProcessData(TestData);
     Assert.AreEqual(TestData, sb.ToString());
     Assert.IsTrue(candidate);
 }
 public void PartsAreProcessedIfStartProcessSucceeds()
 {
     var sb = new StringBuilder();
     var processor = new MultiPartDataProcess((x, y, z) =>
                             {
                                 sb.Append(x);
                                 return true;
                             },
                             x => true);
     var candidate = processor.ProcessData(TestData);
     Assert.AreEqual(TestData, sb.ToString());
     Assert.IsTrue(candidate);
 }
 public void ReturnsFalseIfEndProcessFails()
 {
     var sb = new StringBuilder();
     var processor = new MultiPartDataProcess((x, y, z) =>
                             {
                                 sb.Append(x);
                                 return true;
                             },
                             x => true,
                             x => false);
     var candidate = processor.ProcessData(TestData);
     Assert.AreEqual(TestData, sb.ToString());
     Assert.IsFalse(candidate);
 }
 public void StopsWithFalseIfPartFailsToProcess()
 {
     var sb = new StringBuilder();
     var count = 1;
     var processor = new MultiPartDataProcess((x, y, z) =>
     {
         Assert.AreEqual(count++, y);
         sb.Append(x);
         return y != 3;
     }, null, null, 3);
     var candidate = processor.ProcessData(TestData);
     Assert.AreEqual(TestData.Substring(0, 3*3), sb.ToString());
     Assert.IsFalse(candidate);
 }