private static void testJpegOutput(JpegImage jpeg, CompressionParameters parameters, string jpegFileName, string folderWithExpectedResults) { using (FileStream output = new FileStream(jpegFileName, FileMode.Create)) jpeg.WriteJpeg(output, parameters); FileAssert.AreEqual(jpegFileName, Path.Combine(folderWithExpectedResults, jpegFileName)); }
public void AreEqualPassesUsingSameFileTwice() { using (var tf1 = new TestFile("Test1.jpg", "TestImage1.jpg")) { FileAssert.AreEqual(tf1.File.FullName, tf1.File.FullName); } }
public void ExportTextures() { var path = Path.Combine(TestContext.CurrentContext.TestDirectory, "Files", "Textures"); var files = Directory.GetFiles(path, "*.vtex_c"); foreach (var file in files) { var resource = new Resource(); resource.Read(file); var bitmap = ((Texture)resource.Blocks[BlockType.DATA]).GenerateBitmap(); using (var ms = new MemoryStream()) { bitmap.Save(ms, ImageFormat.Png); // TODO: Comparing images as bytes doesn't work #if false using (var expected = new FileStream(Path.ChangeExtension(file, "png"), FileMode.Open, FileAccess.Read)) { FileAssert.AreEqual(expected, ms); } #endif } } }
private static void testBitmapOutput(JpegImage jpeg, string bitmapFileName) { using (FileStream output = new FileStream(bitmapFileName, FileMode.Create)) jpeg.WriteBitmap(output); FileAssert.AreEqual(bitmapFileName, Tester.MapExpectedPath(bitmapFileName)); }
private void AssertModelFiles(List <string> expectedModelAndYamlFileNames, string generatedFilesFolderName) { Assert.Multiple(() => { var expectedFilesPath = OutPutFilePath + generatedFilesFolderName + "\\"; var generatedModelAndYamlFileNamesList = GetFileNamesList(expectedFilesPath); Assert.IsNotEmpty(generatedModelAndYamlFileNamesList, "Hub and Yml files are not generated."); foreach (var expectedFileName in expectedModelAndYamlFileNames) { Assert.Contains(expectedFileName, generatedModelAndYamlFileNamesList); var expected = expectedFilesPath + expectedFileName; var actual = ActualFilesPath + generatedFilesFolderName + "\\" + expectedFileName; FileAssert.Exists(expected, $"{expected} does not exist"); FileAssert.Exists(actual, $"{actual} does not exist"); TestContext.WriteLine(expected + " ---vs--- " + actual); FileAssert.AreEqual(expected, actual, "Test failure for " + expectedFileName); } }); }
public void AreEqualPassesWhenBothAreNull() { FileStream expected = null; FileStream actual = null; FileAssert.AreEqual(expected, actual); }
private static void testJpegOutput(JpegImage jpeg, CompressionParameters parameters, string jpegFileName) { using (FileStream output = new FileStream(jpegFileName, FileMode.Create)) jpeg.WriteJpeg(output, parameters); FileAssert.AreEqual(jpegFileName, Tester.MapExpectedPath(jpegFileName)); }
public void ObjectToFile_ManageFileExtensions() { // Extension gets added silently (See `Serializer.GetExistingFilePathWithFileExtensions()`). serializer.ObjectToFile(first, tempFolderPath + "first_test"); FileAssert.AreEqual( testFolderPath + "first_test." + serializer.PrimaryFileExtension, tempFolderPath + "first_test." + serializer.PrimaryFileExtension ); // `WithFileExtension` creates a new path using primary extension (even if the file in non-existent). serializer.ObjectToFile(second, tempFolderPath + "second_test.json"); // `json` get replaced FileAssert.AreEqual( testFolderPath + "second_test".WithFileExtension(serializer), tempFolderPath + "second_test".WithFileExtension(serializer) ); // `WithExistingFileExtension` only returns a path is there is an existing file there (it iterates over every defined file extension). serializer.ObjectToFile(third, tempFolderPath + "third_test.zip"); // `zip` get replaced FileAssert.AreEqual( (testFolderPath + "third_test").WithExistingFileExtension(serializer), tempFolderPath + "third_test".WithFileExtension(serializer) ); serializer.ObjectToFile(fourth, tempFolderPath + "fourth_test.bytes"); // `bytes` get replaced FileAssert.AreEqual( (testFolderPath + "fourth_test").WithExistingFileExtension(serializer), tempFolderPath + "fourth_test".WithFileExtension(serializer) ); }
public static void WithinAppDomain(string expectedFile, string createdFile, IEnumerable <string> args) { var bd = AppDomain.CurrentDomain.BaseDirectory; var info = new AppDomainSetup() { ApplicationBase = bd, ApplicationName = Program + ".exe", ConfigurationFile = Program + ".exe.config", }; AppDomain ad = AppDomain.CreateDomain("DbMetal Sqlite Test", null, info); var t = typeof(DbMetalAppDomainSetup); var s = (DbMetalAppDomainSetup)ad.CreateInstanceAndUnwrap(t.Assembly.GetName().Name, t.FullName); var stderr = new StringWriter(); s.SetStandardError(stderr); var testdir = Path.Combine(bd, Path.Combine("..", "tests")); var expectedDir = Path.Combine(testdir, "expected"); s.Run(new [] { "/provider:Sqlite", "/conn:Data Source=" + Path.Combine(testdir, "Northwind.db3"), }.Concat(args).ToArray()); AppDomain.Unload(ad); if (stderr.GetStringBuilder().Length != 0) { Console.Error.Write(stderr.GetStringBuilder().ToString()); } Assert.AreEqual(0, stderr.GetStringBuilder().Length); FileAssert.AreEqual(Path.Combine(expectedDir, string.Format(expectedFile, Program)), createdFile); File.Delete(createdFile); }
public void ObjectToFile() { // Using primary file extension. serializer.ObjectToFile(first, tempFolderPath + "first_test"); FileAssert.AreEqual( testFolderPath + "first".WithFileExtension(serializer), tempFolderPath + "first_test".WithFileExtension(serializer) ); serializer.ObjectToFile(second, tempFolderPath + "second_test"); FileAssert.AreEqual( testFolderPath + "second".WithFileExtension(serializer), tempFolderPath + "second_test".WithFileExtension(serializer) ); // Using seconday file extension (in `testFolderPath` folder). serializer.ObjectToFile(third, tempFolderPath + "third_test"); FileAssert.AreEqual( (testFolderPath + "third.data").WithExistingFileExtension(serializer), tempFolderPath + "third_test".WithFileExtension(serializer) ); serializer.ObjectToFile(fourth, tempFolderPath + "fourth_test"); FileAssert.AreEqual( (testFolderPath + "fourth.data").WithExistingFileExtension(serializer), tempFolderPath + "fourth_test".WithFileExtension(serializer) ); }
public void SerializeToFileAt() { first.SerializeToFileAt(tempFolderPath + "first_test"); FileAssert.AreEqual( testFolderPath + "first".WithFileExtension(serializer), tempFolderPath + "first_test".WithFileExtension(serializer) ); second.SerializeToFileAt(tempFolderPath + "second_test"); FileAssert.AreEqual( testFolderPath + "second".WithFileExtension(serializer), tempFolderPath + "second_test".WithFileExtension(serializer) ); third.SerializeToFileAt(tempFolderPath + "third_test"); FileAssert.AreEqual( (testFolderPath + "third").WithExistingFileExtension(serializer), tempFolderPath + "third_test".WithFileExtension(serializer) ); fourth.SerializeToFileAt(tempFolderPath + "fourth_test"); FileAssert.AreEqual( (testFolderPath + "fourth").WithExistingFileExtension(serializer), tempFolderPath + "fourth_test".WithFileExtension(serializer) ); }
public void CreateViaDbSchemaLoader() { #if MONO_STRICT var app = "sqlmetal"; var dbConnectionProvider = "Mono.Data.Sqlite.SqliteConnection, Mono.Data.Sqlite"; var dbLinqSchemaLoader = "DbLinq.Vendor.DbSchemaLoader, System.Data.Linq"; var sqlDialect = "DbLinq.Sqlite.SqliteVendor, System.Data.Linq"; #else var app = "DbMetal"; var dbConnectionProvider = "System.Data.SQLite.SQLiteConnection, System.Data.SQLite"; var dbLinqSchemaLoader = "DbLinq.Vendor.DbSchemaLoader, DbLinq"; var sqlDialect = "DbLinq.Sqlite.SqliteVendor, DbLinq.Sqlite"; #endif var bd = AppDomain.CurrentDomain.BaseDirectory; var testdir = Path.Combine(bd, Path.Combine("..", "tests")); var expectedDir = Path.Combine(testdir, "expected"); Program.Main(new string[] { "/code:Northwind.Sqlite.cs", "/conn:Data Source=" + Path.Combine(testdir, "Northwind.db3"), "/database:Northwind", "/databaseConnectionProvider=" + dbConnectionProvider, "/dbLinqSchemaLoaderProvider=" + dbLinqSchemaLoader, "--generate-timestamps-", "/namespace:nwind", "/pluralize", "/sqlDialectType=" + sqlDialect, }); FileAssert.AreEqual(Path.Combine(expectedDir, "Northwind.Sqlite+DbSchemaLoader-" + app + ".cs"), "Northwind.Sqlite.cs"); File.Delete("Northwind.Sqlite.cs"); }
public void Create_CreateFileSystemAndReadFile_Success() { // The minimum number of clusters for Fat32 is 65525. const int amountOfClusters = 65525; using (MemoryStream disk = new MemoryStream()) { BootSector boot = new BootSector(); boot.FatSize = (uint)Math.Ceiling(amountOfClusters / (double)boot.BytesPerSector); boot.Sectors = (uint)boot.SectorsPerCluster * amountOfClusters + boot.ReservedSectors + boot.FatSize; Fat32FileSystem.Create(disk, boot); byte[] bytes = new byte[4600]; // Use multiple clusters. Random random = new Random(); random.NextBytes(bytes); using (MemoryStream expected = new MemoryStream(bytes)) { Fat32FileSystem system = new Fat32FileSystem(disk); system.Create("Data.bin"); using (Stream file = system.Open("Data.bin")) { expected.CopyTo(file); file.Flush(); } using (Stream file = system.Open("Data.bin")) FileAssert.AreEqual(expected, file); } } }
private static void testBitmapOutput(JpegImage jpeg, string bitmapFileName, string folderWithExpectedResults) { using (FileStream output = new FileStream(bitmapFileName, FileMode.Create)) jpeg.WriteBitmap(output); FileAssert.AreEqual(bitmapFileName, Path.Combine(folderWithExpectedResults, bitmapFileName)); }
public void Run(string[] args, string sourceImage, string targetImage) { // xJpeg.Program.Main is static, so lock concurent access to a test code // use a private field to lock upon lock (locked) { List <string> completeArgs = new List <string>(1 + args.Length + 2); for (int i = 0; i < args.Length; ++i) { completeArgs.Add(args[i]); } completeArgs.Add(sourceImage); completeArgs.Add(targetImage); if (m_compression) { BitMiracle.cJpeg.Program.Main(completeArgs.ToArray()); } else { BitMiracle.dJpeg.Program.Main(completeArgs.ToArray()); } string sampleFile = targetImage.Replace(@"\Output\", @"\Expected\"); FileAssert.AreEqual(sampleFile, targetImage); } }
public void BinaryFileAreEqualTest() { // Test OK. FileAssert.AreEqual( @"M:\work\TestA1.jpg", @"M:\work\TestA2.jpg"); }
public void AreEqualPassesUsingSameFileTwice() { using (TestFile tf1 = new TestFile("Test1.jpg", "TestImage1.jpg")) { FileAssert.AreEqual("Test1.jpg", "Test1.jpg"); } }
public static void Test1() { string _xml = @" <?xml version=""1.0"" encoding=""utf-8"" ?> <users> <user> <userId>1</userId> <firstName>George</firstName> <lastName>Washington</lastName> </user> <user> <userId>2</userId> <firstName>Abraham</firstName> <lastName>Lincoln</lastName> </user> ... </users> "; using (var csvWriter = new ChoCSVWriter(FileNameTest1ActualCSV).WithFirstLineHeader()) { using (var xmlReader = new ChoXmlReader(new StringReader(_xml.Trim()))) csvWriter.Write(xmlReader); } FileAssert.AreEqual(FileNameTest1ExpectedCSV, FileNameTest1ActualCSV); }
public void Given_Container16bppPng_UsedCapacityIsLow_ExpectedDecryptedEqualsInitialSecret() { //Arrange string outputDirPath = Path.Combine(TestsSetUp.TempDirectory, System.Reflection.MethodBase.GetCurrentMethod().Name); Directory.CreateDirectory(outputDirPath); string containerPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", "Containers", "254x256_16.png"); string secretPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", "Secrets", "gecon.jpg"); var key = new PasswordKey("aaaaaa"); IStegoSystem <string, ImageStegoConstraints> stegoSystem = new SudokuImageStegoSystem <byte, string>(new SudokuStegoMethod256(), new SudokuByPasswordMatrixFactory <byte>(), new Method256ImageStegoConstraints()); //Act string stegocontainerPath = stegoSystem.Encrypt(containerPath, secretPath, key, outputDirPath); string restoredSecretPath = stegoSystem.Decrypt(stegocontainerPath, key, outputDirPath); //Assert //restored and initial secrets are equal FileAssert.AreEqual(secretPath, restoredSecretPath); }
public void AreEqualPassesWithTextFiles() { using (var tf1 = new TestFile("Test1.txt", "TestText1.txt")) using (var tf2 = new TestFile("Test2.txt", "TestText1.txt")) { FileAssert.AreEqual(tf1.File.FullName, tf2.File.FullName); } }
public void AreEqualPassesWithFiles() { using (TestFile tf1 = new TestFile("Test1.jpg", "TestImage1.jpg")) using (TestFile tf2 = new TestFile("Test2.jpg", "TestImage1.jpg")) { FileAssert.AreEqual("Test1.jpg", "Test2.jpg", "Failed using file names"); } }
public void AreEqualPassesWithFiles() { using (var tf1 = new TestFile("Test1.jpg", "TestImage1.jpg")) using (var tf2 = new TestFile("Test2.jpg", "TestImage1.jpg")) { FileAssert.AreEqual(tf1.File.FullName, tf2.File.FullName, "Failed using file names"); } }
public void AreEqualPassesWithFileInfos() { using (var expectedTestFile = new TestFile("Test1.jpg", "TestImage1.jpg")) using (var actualTestFile = new TestFile("Test2.jpg", "TestImage1.jpg")) { FileAssert.AreEqual(expectedTestFile.File, actualTestFile.File); } }
public void CopyIfChanged_NoExist() { var src = NewFile("foo"); var dest = NewFile(); Assert.IsTrue(Files.CopyIfChanged(src, dest), "Changes should have occurred"); FileAssert.AreEqual(src, dest); }
public void AreEqualFileInfo() { string pathFile = Assembly.GetExecutingAssembly().Location; FileInfo file = new FileInfo(pathFile); FileInfo file2 = new FileInfo(pathFile); FileAssert.AreEqual(file, file2); }
public void CopyIfChanged_NoChanges() { var src = NewFile("foo"); var dest = NewFile("foo"); Assert.IsFalse(Files.CopyIfChanged(src, dest), "No change should have occurred"); FileAssert.AreEqual(src, dest); }
public void Sharpen24Test() { TestFilter.Test(new Sharpen(), Config.INPUT24_DIR, Config.OUTPUT_DIR); FileAssert.AreEqual(Config.OUTPUT_DIR, Config.SHARPEN24_DIR); Assert.Pass(); }
public void TestRemoveFeaturesByNumber() { SparseFormatWriter.RemoveFeaturesWithNumbers(new[] { 45, 46 }, @"Test\BuhFeatureVectors.txt", @"Test\RemovedBuhFeatureVectors.txt"); var removedBuhFeaturesFileInfo = new FileInfo(@"Test\RemovedBuhFeatureVectors.txt"); var expectedRemovedBuhFeaturesFileInfo = new FileInfo(@"Test\ExpectedRemovedBuhFeatureVectors.txt"); FileAssert.AreEqual(removedBuhFeaturesFileInfo, expectedRemovedBuhFeaturesFileInfo); }
public void TestParsingFile() { SpektrumLog spektrumLog = new SpektrumLog(integrationTestLog); spektrumLog.writeToTextFile(integrationTestWriteResult); FileAssert.AreEqual(integrationTestWriteResult, integrationTestExpectedResult); }
public void TestNbtSmallFileSavingUncompressed() { NbtFile file = TestFiles.MakeSmallFile(); string testFileName = Path.Combine(TestDirName, "test.nbt"); file.SaveToFile(testFileName, NbtCompression.None); FileAssert.AreEqual(TestFiles.Small, testFileName); }