Exemple #1
0
        public void AreEqualFailsWithStreams()
        {
            string expectedFile = "TestImage1.jpg";
            string actualFile   = "TestImage2.jpg";

            using (TestFile tf1 = new TestFile(expectedFile, Resources.TestImage1))
            {
                using (TestFile tf2 = new TestFile(actualFile, Resources.TestImage2))
                {
                    using (FileStream expected = File.OpenRead(expectedFile))
                    {
                        using (FileStream actual = File.OpenRead(actualFile))
                        {
                            expectedMessage =
                                string.Format("  Expected Stream length {0} but was {1}." + Environment.NewLine,
                                              new FileInfo(expectedFile).Length, new FileInfo(actualFile).Length);
                            EnsureBase <Ensure> .Files.AreEqual(expected, actual);
                        }
                    }
                }
            }
        }
Exemple #2
0
 public void AreNotEqualIteratesOverTheEntireFileAndFails()
 {
     using (TestFile tf1 = new TestFile( "TestText1.txt", Resources.TestText1 ))
     {
         using (TestFile tf2 = new TestFile( "TestText2.txt", Resources.TestText1 ))
         {
             expectedMessage =
                 "  Expected: not <System.IO.FileStream>" + Environment.NewLine +
                 "  But was:  <System.IO.FileStream>" + Environment.NewLine;
             EnsureBase<Ensure>.Files.AreNotEqual( "TestText1.txt", "TestText2.txt" );
         }
     }
 }
Exemple #3
0
 public void AreNotEqualFailsWithFiles()
 {
     using (TestFile tf1 = new TestFile( "TestImage1.jpg", Resources.TestImage1 ))
     {
         expectedMessage =
             "  Expected: not <System.IO.FileStream>" + Environment.NewLine +
             "  But was:  <System.IO.FileStream>" + Environment.NewLine;
         EnsureBase<Ensure>.Files.AreNotEqual( "TestImage1.jpg", "TestImage1.jpg" );
     }
 }
Exemple #4
0
 public void AreNotEqualFailsWithFileInfos()
 {
     using (TestFile tf1 = new TestFile( "TestImage1.jpg", Resources.TestImage1 ))
     {
         using (TestFile tf2 = new TestFile( "TestImage2.jpg", Resources.TestImage1 ))
         {
             FileInfo expected = new FileInfo( "TestImage1.jpg" );
             FileInfo actual = new FileInfo( "TestImage2.jpg" );
             expectedMessage =
                 "  Expected: not <System.IO.FileStream>" + Environment.NewLine +
                 "  But was:  <System.IO.FileStream>" + Environment.NewLine;
             EnsureBase<Ensure>.Files.AreNotEqual( expected, actual );
         }
     }
 }
Exemple #5
0
 public void AreNotEqualFailsWithStreams()
 {
     using (TestFile tf1 = new TestFile( "TestImage1.jpg", Resources.TestImage1 ))
     {
         using (TestFile tf2 = new TestFile( "TestImage2.jpg", Resources.TestImage1 ))
         {
             using (FileStream expected = File.OpenRead( "TestImage1.jpg" ))
             {
                 using (FileStream actual = File.OpenRead( "TestImage2.jpg" ))
                 {
                     EnsureBase<Ensure>.Files.AreNotEqual( expected, actual );
                 }
             }
         }
     }
 }
Exemple #6
0
 public void AreNotEqualIteratesOverTheEntireFile()
 {
     using (TestFile tf1 = new TestFile( "TestText1.txt", Resources.TestText1 ))
     {
         using (TestFile tf2 = new TestFile( "TestText2.txt", Resources.TestText2 ))
         {
             EnsureBase<Ensure>.Files.AreNotEqual( "TestText1.txt", "TestText2.txt" );
         }
     }
 }
Exemple #7
0
 public void AreNotEqualPassesWithFileInfos()
 {
     using (TestFile tf1 = new TestFile( "TestImage1.jpg", Resources.TestImage1 ))
     {
         using (TestFile tf2 = new TestFile( "TestImage2.jpg", Resources.TestImage2 ))
         {
             FileInfo expected = new FileInfo( "TestImage1.jpg" );
             FileInfo actual = new FileInfo( "TestImage2.jpg" );
             EnsureBase<Ensure>.Files.AreNotEqual( expected, actual );
         }
     }
 }
Exemple #8
0
 public void AreNotEqualPassesWithFiles()
 {
     using (TestFile tf1 = new TestFile( "TestImage1.jpg", Resources.TestImage1 ))
     {
         using (TestFile tf2 = new TestFile( "TestImage2.jpg", Resources.TestImage2 ))
         {
             EnsureBase<Ensure>.Files.AreNotEqual( "TestImage1.jpg", "TestImage2.jpg" );
         }
     }
 }
Exemple #9
0
 public void AreNotEqualPassesIfOneIsNull()
 {
     using (TestFile tf1 = new TestFile( "TestImage1.jpg", Resources.TestImage1 ))
     {
         using (FileStream expected = File.OpenRead( "TestImage1.jpg" ))
         {
             EnsureBase<Ensure>.Files.AreNotEqual( expected, null );
         }
     }
 }
Exemple #10
0
 public void AreEqualFailsWithTextFilesAfterReadingBothFiles()
 {
     using (TestFile tf1 = new TestFile( "TestText1.txt", Resources.TestText1 ))
     {
         using (TestFile tf2 = new TestFile( "TestText2.txt", Resources.TestText2 ))
         {
             expectedMessage =
                 "  Stream lengths are both 65600. Streams differ at offset 65597." + Environment.NewLine;
             EnsureBase<Ensure>.Files.AreEqual( "TestText1.txt", "TestText2.txt" );
         }
     }
 }
Exemple #11
0
 public void AreEqualFailsWithFiles()
 {
     string expected = "TestImage1.jpg";
     string actual = "TestImage2.jpg";
     using (TestFile tf1 = new TestFile( expected, Resources.TestImage1 ))
     {
         using (TestFile tf2 = new TestFile( actual, Resources.TestImage2 ))
         {
             expectedMessage =
                 string.Format( "  Expected Stream length {0} but was {1}." + Environment.NewLine,
                                new FileInfo( expected ).Length, new FileInfo( actual ).Length );
             EnsureBase<Ensure>.Files.AreEqual( expected, actual );
         }
     }
 }
Exemple #12
0
 public void AreEqualFailsWithFileInfos()
 {
     using (TestFile tf1 = new TestFile( "TestImage1.jpg", Resources.TestImage1 ))
     {
         using (TestFile tf2 = new TestFile( "TestImage2.jpg", Resources.TestImage2 ))
         {
             FileInfo expected = new FileInfo( "TestImage1.jpg" );
             FileInfo actual = new FileInfo( "TestImage2.jpg" );
             expectedMessage =
                 string.Format( "  Expected Stream length {0} but was {1}." + Environment.NewLine,
                                expected.Length, actual.Length );
             EnsureBase<Ensure>.Files.AreEqual( expected, actual );
         }
     }
 }
Exemple #13
0
 public void AreEqualFailsWhenOneIsNull()
 {
     using (TestFile tf1 = new TestFile( "TestImage1.jpg", Resources.TestImage1 ))
     {
         using (FileStream expected = File.OpenRead( "TestImage1.jpg" ))
         {
             expectedMessage =
                 "  Expected: <System.IO.FileStream>" + Environment.NewLine +
                 "  But was:  null" + Environment.NewLine;
             EnsureBase<Ensure>.Files.AreEqual( expected, null );
         }
     }
 }
Exemple #14
0
 public void AreEqualPassesWithTextFiles()
 {
     using (TestFile tf1 = new TestFile( "TestText1.txt", Resources.TestText1 ))
     {
         using (TestFile tf2 = new TestFile( "TestText2.txt", Resources.TestText1 ))
         {
             EnsureBase<Ensure>.Files.AreEqual( "TestText1.txt", "TestText2.txt" );
         }
     }
 }
Exemple #15
0
 public void AreEqualPassesUsingSameFileTwice()
 {
     using (TestFile tf1 = new TestFile( "TestImage1.jpg", Resources.TestImage1 ))
     {
         EnsureBase<Ensure>.Files.AreEqual( "TestImage1.jpg", "TestImage1.jpg" );
     }
 }