public void AreNotEqualIteratesOverTheEntireFile() { using (new TestFile("Test1.txt", "TestText1.txt")) using (new TestFile("Test2.txt", "TestText2.txt")) { FileAssert.AreNotEqual("Test1.txt", "Test2.txt"); } }
public void AreNotEqualPassesWithFiles() { using (var tf1 = new TestFile("Test1.jpg", "TestImage1.jpg")) using (var tf2 = new TestFile("Test2.jpg", "TestImage2.jpg")) { FileAssert.AreNotEqual(tf1.File.FullName, tf2.File.FullName); } }
public void AreNotEqualPassesIfOneIsNull() { using (var tf1 = new TestFile("Test1.jpg", "TestImage1.jpg")) using (FileStream expected = tf1.File.OpenRead()) { FileAssert.AreNotEqual(expected, null); } }
public void AreNotEqualPassesWithFileInfos() { using (var expectedTestFile = new TestFile("Test1.jpg", "TestImage1.jpg")) using (var actualTestFile = new TestFile("Test2.jpg", "TestImage2.jpg")) { FileAssert.AreNotEqual(expectedTestFile.File, actualTestFile.File); } }
public void AreNotEqualIteratesOverTheEntireFile() { using (var tf1 = new TestFile("Test1.txt", "TestText1.txt")) using (var tf2 = new TestFile("Test2.txt", "TestText2.txt")) { FileAssert.AreNotEqual(tf1.File.FullName, tf2.File.FullName); } }
public void AreNotEqualPassesWithFiles() { using (new TestFile("Test1.jpg", "TestImage1.jpg")) using (new TestFile("Test2.jpg", "TestImage2.jpg")) { FileAssert.AreNotEqual("Test1.jpg", "Test2.jpg"); } }
public void AreNotEqualPassesWithFileInfos() { using (new TestFile("Test1.jpg", "TestImage1.jpg")) using (new TestFile("Test2.jpg", "TestImage2.jpg")) { FileInfo expected = new FileInfo("Test1.jpg"); FileInfo actual = new FileInfo("Test2.jpg"); FileAssert.AreNotEqual(expected, actual); } }
public void FileAssertsTest() { FileInfo fileInfo1 = new FileInfo(@"D:\development\Text1.txt"); FileInfo fileInfo2 = new FileInfo(@"D:\development\Text2.txt"); FileAssert.AreEqual(fileInfo1, fileInfo2); FileAssert.AreNotEqual(fileInfo1, new FileInfo(@"D:\Recovery.txt")); FileAssert.Exists(fileInfo1); FileAssert.DoesNotExist(new FileInfo(@"D:\development\Text3.txt")); }
public void AreNotEqualFailsWhenBothAreNull() { FileStream expected = null; FileStream actual = null; expectedMessage = " Expected: not null" + Environment.NewLine + " But was: null" + Environment.NewLine; FileAssert.AreNotEqual(expected, actual); }
public void AreNotEqualFailsWithFiles() { using (TestFile tf1 = new TestFile("Test1.jpg", "TestImage1.jpg")) { expectedMessage = " Expected: not <System.IO.FileStream>" + Environment.NewLine + " But was: <System.IO.FileStream>" + Environment.NewLine; FileAssert.AreNotEqual("Test1.jpg", "Test1.jpg"); } }
public void AreNotEqualIteratesOverTheEntireFile() { using (TestFile tf1 = new TestFile("Test1.txt", "NUnit.Framework.Tests.TestText1.txt")) { using (TestFile tf2 = new TestFile("Test2.txt", "NUnit.Framework.Tests.TestText2.txt")) { FileAssert.AreNotEqual("Test1.txt", "Test2.txt"); } } }
public void AreNotEqualPassesWithFiles() { using (TestFile tf1 = new TestFile("Test1.jpg", "NUnit.Framework.Tests.TestImage1.jpg")) { using (TestFile tf2 = new TestFile("Test2.jpg", "NUnit.Framework.Tests.TestImage2.jpg")) { FileAssert.AreNotEqual("Test1.jpg", "Test2.jpg"); } } }
public void AreNotEqualPassesIfOneIsNull() { using (TestFile tf1 = new TestFile("Test1.jpg", "NUnit.Framework.Tests.TestImage1.jpg")) { using (FileStream expected = File.OpenRead("Test1.jpg")) { FileAssert.AreNotEqual(expected, null); } } }
public void AreNotEqualFailsWithFiles() { using (var tf1 = new TestFile("Test1.jpg", "TestImage1.jpg")) { var expectedMessage = " Expected: not equal to <System.IO.FileStream>" + Environment.NewLine + " But was: <System.IO.FileStream>" + Environment.NewLine; var ex = Assert.Throws <AssertionException>(() => FileAssert.AreNotEqual(tf1.File.FullName, tf1.File.FullName)); Assert.That(ex.Message, Is.EqualTo(expectedMessage)); } }
public void AreNotEqualFailsWhenBothAreNull() { FileStream expected = null; FileStream actual = null; var expectedMessage = " Expected: not equal to null" + Environment.NewLine + " But was: null" + Environment.NewLine; var ex = Assert.Throws <AssertionException>(() => FileAssert.AreNotEqual(expected, actual)); Assert.That(ex.Message, Is.EqualTo(expectedMessage)); }
public void AreNotEqualPassesWithStreams() { using (var tf1 = new TestFile("Test1.jpg", "TestImage1.jpg")) using (var tf2 = new TestFile("Test2.jpg", "TestImage2.jpg")) using (FileStream expected = tf1.File.OpenRead()) { using (FileStream actual = tf2.File.OpenRead()) { FileAssert.AreNotEqual(expected, actual); } } }
public void AreNotEqualPassesWithFileInfos() { using (TestFile tf1 = new TestFile("Test1.jpg", "NUnit.Framework.Tests.TestImage1.jpg")) { using (TestFile tf2 = new TestFile("Test2.jpg", "NUnit.Framework.Tests.TestImage2.jpg")) { FileInfo expected = new FileInfo("Test1.jpg"); FileInfo actual = new FileInfo("Test2.jpg"); FileAssert.AreNotEqual(expected, actual); } } }
public void AreNotEqualIteratesOverTheEntireFileAndFails() { using (var tf1 = new TestFile("Test1.txt", "TestText1.txt")) using (var tf2 = new TestFile("Test2.txt", "TestText1.txt")) { var expectedMessage = " Expected: not equal to <System.IO.FileStream>" + Environment.NewLine + " But was: <System.IO.FileStream>" + Environment.NewLine; var ex = Assert.Throws <AssertionException>(() => FileAssert.AreNotEqual(tf1.File.FullName, tf2.File.FullName)); Assert.That(ex.Message, Is.EqualTo(expectedMessage)); } }
public void AreNotEqualIteratesOverTheEntireFileAndFails() { using (TestFile tf1 = new TestFile("Test1.txt", "TestText1.txt")) { using (TestFile tf2 = new TestFile("Test2.txt", "TestText1.txt")) { expectedMessage = " Expected: not <System.IO.FileStream>" + Environment.NewLine + " But was: <System.IO.FileStream>" + Environment.NewLine; FileAssert.AreNotEqual("Test1.txt", "Test2.txt"); } } }
public void AreNotEqualFailsWithStreams() { using (TestFile tf1 = new TestFile("Test1.jpg", "TestImage1.jpg")) using (TestFile tf2 = new TestFile("Test2.jpg", "TestImage1.jpg")) using (FileStream expected = File.OpenRead("Test1.jpg")) using (FileStream actual = File.OpenRead("Test2.jpg")) { expectedMessage = " Expected: not <System.IO.FileStream>" + Environment.NewLine + " But was: <System.IO.FileStream>" + Environment.NewLine; FileAssert.AreNotEqual(expected, actual); } }
public void AreNotEqualFailsWithFileInfos() { using (new TestFile("Test1.jpg", "TestImage1.jpg")) using (new TestFile("Test2.jpg", "TestImage1.jpg")) { FileInfo expected = new FileInfo("Test1.jpg"); FileInfo actual = new FileInfo("Test2.jpg"); var expectedMessage = " Expected: not equal to <System.IO.FileStream>" + Environment.NewLine + " But was: <System.IO.FileStream>" + Environment.NewLine; var ex = Assert.Throws <AssertionException>(() => FileAssert.AreNotEqual(expected, actual)); Assert.That(ex.Message, Is.EqualTo(expectedMessage)); } }
public void AreNotEqualFailsWithStreams() { using (var tf1 = new TestFile("Test1.jpg", "TestImage1.jpg")) using (var tf2 = new TestFile("Test2.jpg", "TestImage1.jpg")) using (FileStream expected = tf1.File.OpenRead()) using (FileStream actual = tf2.File.OpenRead()) { var expectedMessage = " Expected: not equal to <System.IO.FileStream>" + Environment.NewLine + " But was: <System.IO.FileStream>" + Environment.NewLine; var ex = Assert.Throws <AssertionException>(() => FileAssert.AreNotEqual(expected, actual)); Assert.That(ex.Message, Is.EqualTo(expectedMessage)); } }
public void AreNotEqualFailsWithFileInfos() { using (TestFile tf1 = new TestFile("Test1.jpg", "TestImage1.jpg")) { using (TestFile tf2 = new TestFile("Test2.jpg", "TestImage1.jpg")) { FileInfo expected = new FileInfo("Test1.jpg"); FileInfo actual = new FileInfo("Test2.jpg"); expectedMessage = " Expected: not <System.IO.FileStream>" + Environment.NewLine + " But was: <System.IO.FileStream>" + Environment.NewLine; FileAssert.AreNotEqual(expected, actual); } } }
public void AreNotEqualPassesWithStreams() { using (TestFile tf1 = new TestFile("Test1.jpg", "NUnit.Framework.Tests.TestImage1.jpg")) { using (TestFile tf2 = new TestFile("Test2.jpg", "NUnit.Framework.Tests.TestImage2.jpg")) { using (FileStream expected = File.OpenRead("Test1.jpg")) { using (FileStream actual = File.OpenRead("Test2.jpg")) { FileAssert.AreNotEqual(expected, actual); } } } } }
public void SourceOlderDifferentLengthButNoLengthCheck() { var src = NewFile("foo"); var dest = NewFile("foofoo"); var now = DateTime.UtcNow; File.SetLastWriteTimeUtc(src, now.AddSeconds(-1)); // source is older File.SetLastWriteTimeUtc(dest, now); var task = new CopyIfChanged { BuildEngine = new MockBuildEngine(TestContext.Out), SourceFiles = ToArray(src), DestinationFiles = ToArray(dest), CompareFileLengths = false, }; Assert.IsTrue(task.Execute(), "task.Execute() should have succeeded."); Assert.AreEqual(0, task.ModifiedFiles.Length, "Changes should not have been made."); FileAssert.AreNotEqual(src, dest); }
public void FileAssertsTest() { try { FileStream file1 = File.OpenRead("Test1.txt"); FileStream file2 = File.OpenRead("Test1.txt"); FileStream file3 = File.OpenRead("Test2.txt"); FileAssert.AreEqual(file1, file2, "Two files has equal content"); FileAssert.AreNotEqual(file1, file3, "Two files has different content"); var fileinfo1 = new FileInfo("Test1.txt"); var fileinfo2 = new FileInfo("Test1.txt"); var fileinfo3 = new FileInfo("Test2.txt"); FileAssert.AreEqual(fileinfo1, fileinfo2, "Two files has equal content"); FileAssert.AreNotEqual(fileinfo1, fileinfo3, "Two files has different content"); FileAssert.AreEqual("Test1.txt", "Test1.txt", "Two files has equal content"); FileAssert.AreNotEqual("Test1.txt", "Test2.txt", "Two files has different content"); } catch (IOException ex) { Assert.Fail("IOException - {0}", ex); } }
public void Retransmitted_Blocks_Should_Overwrite_Previously_Transferred_Data() { List <BufferedDataBlock> blocks = CreateBufferedBlocks(); //modify data in one of the blocks Array.Reverse(blocks[10].Data); foreach (var block in blocks) { UploadHandler.WriteBlock(block); } //pause in order to release stream UploadHandler.PauseTransfer(Token.TransferId); FileAssert.AreNotEqual(SourceFile, TargetFile); //write correct block data blocks = CreateBufferedBlocks(); UploadHandler.WriteBlock(blocks[10]); //complete and recompare UploadHandler.CompleteTransfer(Token.TransferId); FileAssert.AreEqual(SourceFile, TargetFile); }
public void BuildBasicApplicationCheckPdb() { var proj = new XamarinAndroidApplicationProject(); using (var b = CreateApkBuilder("temp/BuildBasicApplicationCheckPdb", false, false)) { b.Verbosity = LoggerVerbosity.Diagnostic; var reference = new BuildItem.Reference("PdbTestLibrary.dll") { WebContent = "https://dl.dropboxusercontent.com/u/18881050/Xamarin/PdbTestLibrary.dll" }; proj.References.Add(reference); var pdb = new BuildItem.NoActionResource("PdbTestLibrary.pdb") { WebContent = "https://dl.dropboxusercontent.com/u/18881050/Xamarin/PdbTestLibrary.pdb" }; proj.References.Add(pdb); var netStandardRef = new BuildItem.Reference("NetStandard16.dll") { WebContent = "https://dl.dropboxusercontent.com/u/18881050/Xamarin/NetStandard16.dll" }; proj.References.Add(netStandardRef); var netStandardpdb = new BuildItem.NoActionResource("NetStandard16.pdb") { WebContent = "https://dl.dropboxusercontent.com/u/18881050/Xamarin/NetStandard16.pdb" }; proj.References.Add(netStandardpdb); Assert.IsTrue(b.Build(proj), "Build should have succeeded."); var pdbToMdbPath = Path.Combine(Root, b.ProjectDirectory, "PdbTestLibrary.dll.mdb"); Assert.IsTrue( File.Exists(pdbToMdbPath), "PdbTestLibrary.dll.mdb must be generated next to the .pdb"); Assert.IsTrue( File.Exists(Path.Combine(Root, b.ProjectDirectory, proj.IntermediateOutputPath, "android", "assets", "UnnamedProject.pdb")), "UnnamedProject.pdb must be copied to the Intermediate directory"); Assert.IsFalse( File.Exists(Path.Combine(Root, b.ProjectDirectory, proj.IntermediateOutputPath, "android", "assets", "PdbTestLibrary.pdb")), "PdbTestLibrary.pdb must not be copied to Intermediate directory"); Assert.IsTrue( File.Exists(Path.Combine(Root, b.ProjectDirectory, proj.IntermediateOutputPath, "android", "assets", "PdbTestLibrary.dll.mdb")), "PdbTestLibrary.dll.mdb must be copied to Intermediate directory"); FileAssert.AreNotEqual(pdbToMdbPath, Path.Combine(Root, b.ProjectDirectory, "PdbTestLibrary.pdb"), "The .pdb should NOT match the .mdb"); Assert.IsTrue( File.Exists(Path.Combine(Root, b.ProjectDirectory, proj.IntermediateOutputPath, "android", "assets", "NetStandard16.pdb")), "NetStandard16.pdb must be copied to Intermediate directory"); var apk = Path.Combine(Root, b.ProjectDirectory, proj.IntermediateOutputPath, "android", "bin", "UnnamedProject.UnnamedProject.apk"); using (var zipFile = ZipHelper.OpenZip(apk)) { Assert.IsNotNull(ZipHelper.ReadFileFromZip(zipFile, "assemblies/NetStandard16.pdb"), "assemblies/NetStandard16.pdb should exist in the apk."); Assert.IsNotNull(ZipHelper.ReadFileFromZip(zipFile, "assemblies/PdbTestLibrary.dll.mdb"), "assemblies/PdbTestLibrary.dll.mdb should exist in the apk."); Assert.IsNull(ZipHelper.ReadFileFromZip(zipFile, "assemblies/PdbTestLibrary.pdb"), "assemblies/PdbTestLibrary.pdb should not exist in the apk."); } Assert.IsTrue(b.Build(proj, doNotCleanupOnUpdate: true), "second build failed"); Assert.IsTrue( b.LastBuildOutput.Contains("Skipping target \"_CopyMdbFiles\" because"), "the _CopyMdbFiles target should be skipped"); var lastTime = File.GetLastAccessTimeUtc(pdbToMdbPath); pdb.Timestamp = DateTime.UtcNow; Assert.IsTrue(b.Build(proj, doNotCleanupOnUpdate: true), "third build failed"); Assert.IsFalse( b.LastBuildOutput.Contains("Skipping target \"_CopyMdbFiles\" because"), "the _CopyMdbFiles target should not be skipped"); Assert.Less(lastTime, File.GetLastAccessTimeUtc(pdbToMdbPath), "{0} should have been updated", pdbToMdbPath); } }
public void BaseTest(string name) { var path = TestUtilities.GetFullPathForPrgFile(name); var prg = Prg.Load(path); var temp = Path.GetTempFileName(); //Test variables binary load/save compatible //Bit to bit compatible supported only for current version if (prg.FileVersion == FileVersion.Current) { foreach (var input in prg.Inputs) { VariableVariantToFromTest(input.Value, prg.CustomUnits); ObjectAssert.AreEqual(input, new InputPoint(input.ToBytes()), $"{nameof(input)} ToFromBytes test failed."); } foreach (var output in prg.Outputs) { VariableVariantToFromTest(output.Value, prg.CustomUnits); ObjectAssert.AreEqual(output, new OutputPoint(output.ToBytes()), $"{nameof(output)} ToFromBytes test failed."); } foreach (var variable in prg.Variables) { VariableVariantToFromTest(variable.Value, prg.CustomUnits); ObjectAssert.AreEqual(variable, new VariablePoint(variable.ToBytes()), $"{nameof(variable)} ToFromBytes test failed."); } foreach (var program in prg.Programs) { ObjectAssert.AreEqual(program, new ProgramPoint(program.ToBytes()), $"{nameof(program)} ToFromBytes test failed."); } foreach (var controller in prg.Controllers) { ObjectAssert.AreEqual(controller, new ControllerPoint(controller.ToBytes()), $"{nameof(controller)} ToFromBytes test failed."); } foreach (var screen in prg.Screens) { ObjectAssert.AreEqual(screen, new ScreenPoint(screen.ToBytes()), $"{nameof(screen)} ToFromBytes test failed."); } foreach (var graphic in prg.Graphics) { ObjectAssert.AreEqual(graphic, new GraphicPoint(graphic.ToBytes()), $"{nameof(graphic)} ToFromBytes test failed."); } foreach (var user in prg.Users) { ObjectAssert.AreEqual(user, new UserPoint(user.ToBytes()), $"{nameof(user)} ToFromBytes test failed."); } foreach (var unit in prg.CustomUnits.Digital) { ObjectAssert.AreEqual(unit, new CustomDigitalUnitsPoint(unit.ToBytes()), $"{nameof(unit)} ToFromBytes test failed."); } foreach (var table in prg.Tables) { ObjectAssert.AreEqual(table, new TablePoint(table.ToBytes()), $"{nameof(table)} ToFromBytes test failed."); } { var settings = prg.Settings; ObjectAssert.AreEqual(settings, new Settings(settings.ToBytes()), $"{nameof(settings)} ToFromBytes test failed."); } foreach (var schedule in prg.Schedules) { ObjectAssert.AreEqual(schedule, new SchedulePoint(schedule.ToBytes()), $"{nameof(schedule)} ToFromBytes test failed."); } foreach (var holiday in prg.Holidays) { ObjectAssert.AreEqual(holiday, new HolidayPoint(holiday.ToBytes()), $"{nameof(holiday)} ToFromBytes test failed."); } foreach (var monitor in prg.Monitors) { ObjectAssert.AreEqual(monitor, new MonitorPoint(monitor.ToBytes()), $"{nameof(monitor)} ToFromBytes test failed."); } foreach (var code in prg.ScheduleCodes) { ObjectAssert.AreEqual(code, new ScheduleCode(code.ToBytes(), 0), $"{nameof(code)} ToFromBytes test failed."); } foreach (var code in prg.HolidayCodes) { ObjectAssert.AreEqual(code, new HolidayCode(code.ToBytes(), 0), $"{nameof(code)} ToFromBytes test failed."); } foreach (var code in prg.ProgramCodes) { //Currently unsupported //ObjectAssert.AreEqual(code, new ProgramCode(code.ToBytes(), 0), // $"{nameof(code)} ToFromBytes test failed."); } foreach (var units in prg.CustomUnits.Analog) { ObjectAssert.AreEqual(units, new CustomAnalogUnitsPoint(units.ToBytes()), $"{nameof(units)} ToFromBytes test failed."); } } prg.Save(temp); try { FileAssert.AreEqual(path, temp, $@"Name: {name}. See console log for details. "); } catch (Exception exception) { var offset = GetDifferOffset(exception); Console.WriteLine(DebugUtilities.CompareBytes(File.ReadAllBytes(path), prg.ToBytes(), offset - 35, 70, onlyDif: false, toText: true)); throw; } if (prg.Variables.Count > 0) { prg = Prg.Load(temp); prg.Variables[0].Value = new VariableValue("9998.8999", Unit.DegreesC); prg.Save(temp); FileAssert.AreNotEqual(path, temp); } //Additional check for upgrade to current if (prg.FileVersion != FileVersion.Current) { prg.Upgrade(FileVersion.Current); prg.Save(temp); prg = Prg.Load(temp); Assert.AreEqual(FileVersion.Current, prg.FileVersion); } }
public void TestAssertions() { #region Condition assertions Assert.True(true, "Assert.True and Assert.IsTrue test that the specified condition is true. "); Assert.IsTrue(true); Assert.False(false, "Assert.False and Assert.IsFalse test that the specified condition is false."); Assert.IsFalse(false); Assert.Null(null); Assert.IsNull(null, "Assert.Null and Assert.IsNull test that the specified object is null."); Assert.IsNotNull("10"); Assert.NotNull("10", ""); Assert.IsNaN(Double.NaN, "Assert.IsNaN tests that the specified double value is NaN (Not a number)."); Assert.IsEmpty(""); Assert.IsEmpty(new List <object>()); Assert.IsNotEmpty(new List <object> { 1 }); Assert.IsNotEmpty("MyTestString"); #endregion #region Equality Assert.AreEqual(true, true, "Assert.AreEqual tests whether the two arguments are equal."); Assert.AreNotEqual(true, false); #endregion #region Identity Assert.AreSame(string.Empty, string.Empty, "Assert.AreNotSame tests that the two arguments do not reference the same object."); Assert.AreNotSame(new object(), new object()); //both objects are refering to same object object a = new object(); object b = a; Assert.AreSame(a, b); #endregion #region Comparision //Contrary to the normal order of Asserts, these methods are designed to be read in the "natural" English-language or mathematical order. //Thus Assert.Greater(x, y) asserts that x is greater than y (x > y). Assert.Greater(Decimal.MaxValue, Decimal.MinValue, "Assert.Greater tests whether one object is greater than than another"); Assert.GreaterOrEqual(Decimal.MinValue, Decimal.MinValue); Assert.Less(Decimal.MinValue, Decimal.MaxValue); Assert.LessOrEqual(Decimal.MinValue, Decimal.MinValue); #endregion #region Types Assert.IsInstanceOf <decimal>(decimal.MinValue, "Assert.IsInstanceOf succeeds if the object provided as an actual value is an instance of the expected type."); Assert.IsNotInstanceOf <int>(decimal.MinValue); Assert.IsNotAssignableFrom(typeof(List <Type>), string.Empty, "Assert.IsAssignableFrom succeeds if the object provided may be assigned a value of the expected type."); Assert.IsAssignableFrom(typeof(List <decimal>), new List <decimal>()); Assert.IsNotAssignableFrom <List <Type> >(string.Empty); Assert.IsAssignableFrom <List <decimal> >(new List <decimal>()); #endregion #region Strings //The StringAssert class provides a number of methods that are useful when examining string values StringAssert.Contains("london", "london"); StringAssert.StartsWith("Food", "FoodPanda"); StringAssert.EndsWith("rangers", "Powerrangers"); StringAssert.AreEqualIgnoringCase("DOG", "dog"); StringAssert.IsMatch("[10-29]", "15"); StringAssert.DoesNotContain("abc", "defghijk"); StringAssert.DoesNotEndWith("abc", "abcdefgh"); StringAssert.DoesNotMatch("abc", "def"); string a1 = "abc"; string b1 = "abcd"; //StringAssert.ReferenceEquals(a1, b1); need to debug why it's failing Assert.Contains(string.Empty, new List <object> { string.Empty }, "Assert.Contains is used to test whether an object is contained in a collection."); #endregion #region Collections //The CollectionAssert class provides a number of methods that are useful when examining collections and //their contents or for comparing two collections. These methods may be used with any object implementing IEnumerable. //The AreEqual overloads succeed if the corresponding elements of the two collections are equal. //AreEquivalent tests whether the collection contents are equal, but without regard to order. //In both cases, elements are compared using NUnit's default equality comparison. CollectionAssert.AllItemsAreInstancesOfType(new List <decimal> { 0m }, typeof(decimal)); CollectionAssert.AllItemsAreNotNull(new List <decimal> { 0m }); CollectionAssert.AllItemsAreUnique(new List <decimal> { 0m, 1m }); CollectionAssert.AreEqual(new List <decimal> { 0m }, new List <decimal> { 0m }); CollectionAssert.AreEquivalent(new List <decimal> { 0m, 1m }, new List <decimal> { 1m, 0m }); // Same as AreEqual though order does not mater CollectionAssert.AreNotEqual(new List <decimal> { 0m }, new List <decimal> { 1m }); CollectionAssert.AreNotEquivalent(new List <decimal> { 0m, 1m }, new List <decimal> { 1m, 2m }); // Same as AreNotEqual though order does not matter CollectionAssert.Contains(new List <decimal> { 0m, 1m }, 1m); CollectionAssert.DoesNotContain(new List <decimal> { 0m, 1m }, 2m); CollectionAssert.IsSubsetOf(new List <decimal> { 1m }, new List <decimal> { 0m, 1m }); // {1} is considered a SubSet of {1,2} CollectionAssert.IsNotSubsetOf(new List <decimal> { 1m, 2m }, new List <decimal> { 0m, 1m }); CollectionAssert.IsEmpty(new List <decimal>()); CollectionAssert.IsNotEmpty(new List <decimal> { 1m }); CollectionAssert.IsOrdered(new List <decimal> { 1m, 2m, 3m }); CollectionAssert.IsOrdered(new List <string> { "a", "A", "b" }, StringComparer.CurrentCultureIgnoreCase); CollectionAssert.IsOrdered(new List <int> { 3, 2, 1 }, "The list is ordered"); // Only supports ICompare and not ICompare<T> as of version 2.6 #endregion #region File Assert //Various ways to compare a stream or file. //The FileAssert class provides methods for comparing or verifying the existence of files //Files may be provided as Streams, as FileInfos or as strings giving the path to each file. FileAssert.AreEqual(new MemoryStream(), new MemoryStream()); FileAssert.AreEqual(new FileInfo("MyFile.txt"), new FileInfo("MyFile.txt")); FileAssert.AreEqual("MyFile.txt", "MyFile.txt"); FileAssert.AreNotEqual(new FileInfo("MyFile.txt"), new FileInfo("MyFile2.txt")); FileAssert.AreNotEqual("MyFile.txt", "MyFile2.txt"); FileAssert.AreNotEqual(new FileStream("MyFile.txt", FileMode.Open), new FileStream("MyFile2.txt", FileMode.Open)); FileAssert.Equals(new FileInfo("MyFile.txt"), new FileInfo("MyFile.txt")); FileAssert.ReferenceEquals(new FileInfo("MyFile.txt"), new FileInfo("MyFile.txt")); #endregion #region Utilities // Used to stop test execution and mark them pass or fail or skip if (Convert.ToInt32(DateTime.Now.Second) > 30) { Console.WriteLine("Exaple on Utilities assertions"); Assert.Ignore(); } if (Convert.ToInt32(DateTime.Now.Second) < 30) { Assert.Inconclusive(); } // Defining the failed message Assert.IsTrue(true, "A failed message here"); Assert.Pass(); Assert.Fail(); #endregion }