public void UnpackMegFile_Test__UnpackedFilesAreBinaryEquivalent() { string exportTestPath = m_fileSystem.Path.Combine(TestConstants.BASE_PATH, nameof(UnpackMegFile_Test__UnpackedFilesAreBinaryEquivalent)); IMegFileProcessService svc = new MegFileProcessService(m_fileSystem); svc.UnpackMegFile(TestConstants.FILE_PATH_MEG_FILE, exportTestPath); Assert.IsTrue(m_fileSystem.Directory.Exists(exportTestPath)); string fullExportPath = m_fileSystem.Path.Combine(exportTestPath, "DATA", "XML"); Assert.IsTrue(m_fileSystem.Directory.Exists(fullExportPath)); string[] files = m_fileSystem.Directory.GetFiles(fullExportPath); Assert.IsTrue(files.Length == 2); Assert.IsTrue(files.Contains(m_fileSystem.Path.Combine(fullExportPath, TestConstants.FILE_NAME_CAMPAIGNFILES.ToUpper()))); Assert.IsTrue(files.Contains(m_fileSystem.Path.Combine(fullExportPath, TestConstants.FILE_NAME_GAMEOBJECTFILES.ToUpper()))); byte[] expected = m_fileSystem.File.ReadAllBytes(TestConstants.FILE_PATH_GAMEOBJECTFILES); byte[] actual = m_fileSystem.File.ReadAllBytes(m_fileSystem.Path.Combine(fullExportPath, TestConstants.FILE_NAME_GAMEOBJECTFILES.ToUpper())); TestUtility.AssertAreBinaryEquivalent(expected, actual); expected = m_fileSystem.File.ReadAllBytes(TestConstants.FILE_PATH_GAMEOBJECTFILES); actual = m_fileSystem.File.ReadAllBytes(m_fileSystem.Path.Combine(fullExportPath, TestConstants.FILE_NAME_GAMEOBJECTFILES.ToUpper())); TestUtility.AssertAreBinaryEquivalent(expected, actual); }
public void ToBytes_Test__AreBinaryEquivalent(uint input) { MtdHeader header = new MtdHeader(input); byte[] actual = header.ToBytes(); TestUtility.AssertAreBinaryEquivalent(BitConverter.GetBytes(input), actual); }
public void Ctor_Test__IsBinaryEquivalentToExpected() { byte[] actual = new MtdImageTableRecord(Constants.DEFAULT_TEST_RECORD_NAME, Constants.DEFAULT_TEST_RECORD_X_POSITION, Constants.DEFAULT_TEST_RECORD_Y_POSITION, Constants.DEFAULT_TEST_RECORD_X_EXTEND, Constants.DEFAULT_TEST_RECORD_Y_EXTEND, Constants.DEFAULT_TEST_RECORD_ALPHA).ToBytes(); Assert.AreEqual(Constants.OBJECT_SIZE_IN_BYTE, actual.Length); TestUtility.AssertAreBinaryEquivalent(Constants.EXPECTED_MTD_IMAGE_TABLE_RECORD_AS_BYTES, actual); }
public void UnpackSingleFileFromMegFile_Test__DirectoryHierarchyFlatUnpackedFileIsBinaryEquivalent() { string exportTestPath = m_fileSystem.Path.Combine(TestConstants.BASE_PATH, "UnpackSingleFileFromMegFile_Test__UnpackedFileIsBinaryEquivalent"); IMegFileProcessService svc = new MegFileProcessService(m_fileSystem); MegFileHolder megFileHolder = svc.Load(TestConstants.FILE_PATH_MEG_FILE); svc.UnpackSingleFileFromMegFile(megFileHolder, exportTestPath, TestConstants.FILE_NAME_GAMEOBJECTFILES, false); byte[] expected = m_fileSystem.File.ReadAllBytes(TestConstants.FILE_PATH_GAMEOBJECTFILES); byte[] actual = m_fileSystem.File.ReadAllBytes(m_fileSystem.Path.Combine(exportTestPath, TestConstants.FILE_NAME_GAMEOBJECTFILES.ToUpper())); TestUtility.AssertAreBinaryEquivalent(expected, actual); }
public void ToBytes_Test__AreBinaryEquivalent() { MtdFile mtdFile = new MtdFile(new[] { new MtdImageTableRecord(TestConstants.MtdImageTableRecordTestConstants.DEFAULT_TEST_RECORD_NAME, TestConstants.MtdImageTableRecordTestConstants.DEFAULT_TEST_RECORD_X_POSITION, TestConstants.MtdImageTableRecordTestConstants.DEFAULT_TEST_RECORD_Y_POSITION, TestConstants.MtdImageTableRecordTestConstants.DEFAULT_TEST_RECORD_X_EXTEND, TestConstants.MtdImageTableRecordTestConstants.DEFAULT_TEST_RECORD_Y_EXTEND, TestConstants.MtdImageTableRecordTestConstants.DEFAULT_TEST_RECORD_ALPHA), new MtdImageTableRecord(TestConstants.MtdImageTableRecordTestConstants.DEFAULT_TEST_RECORD_NAME, TestConstants.MtdImageTableRecordTestConstants.DEFAULT_TEST_RECORD_X_POSITION, TestConstants.MtdImageTableRecordTestConstants.DEFAULT_TEST_RECORD_Y_POSITION, TestConstants.MtdImageTableRecordTestConstants.DEFAULT_TEST_RECORD_X_EXTEND, TestConstants.MtdImageTableRecordTestConstants.DEFAULT_TEST_RECORD_Y_EXTEND, TestConstants.MtdImageTableRecordTestConstants.DEFAULT_TEST_RECORD_ALPHA) }); byte[] actual = mtdFile.ToBytes(); TestUtility.AssertAreBinaryEquivalent(TestConstants.MtdFileTestConstants.METADATA_TO_BYTES, actual); }
public void ToBytes_Test__AreBinaryEquivalent() { MtdImageTable mtdImageTable = new MtdImageTable(new[] { new MtdImageTableRecord(TestConstants.MtdImageTableRecordTestConstants.DEFAULT_TEST_RECORD_NAME, TestConstants.MtdImageTableRecordTestConstants.DEFAULT_TEST_RECORD_X_POSITION, TestConstants.MtdImageTableRecordTestConstants.DEFAULT_TEST_RECORD_Y_POSITION, TestConstants.MtdImageTableRecordTestConstants.DEFAULT_TEST_RECORD_X_EXTEND, TestConstants.MtdImageTableRecordTestConstants.DEFAULT_TEST_RECORD_Y_EXTEND, TestConstants.MtdImageTableRecordTestConstants.DEFAULT_TEST_RECORD_ALPHA), new MtdImageTableRecord(TestConstants.MtdImageTableRecordTestConstants.DEFAULT_TEST_RECORD_NAME, TestConstants.MtdImageTableRecordTestConstants.DEFAULT_TEST_RECORD_X_POSITION, TestConstants.MtdImageTableRecordTestConstants.DEFAULT_TEST_RECORD_Y_POSITION, TestConstants.MtdImageTableRecordTestConstants.DEFAULT_TEST_RECORD_X_EXTEND, TestConstants.MtdImageTableRecordTestConstants.DEFAULT_TEST_RECORD_Y_EXTEND, TestConstants.MtdImageTableRecordTestConstants.DEFAULT_TEST_RECORD_ALPHA) }); byte[] actual = mtdImageTable.ToBytes(); Assert.AreEqual(actual.Length, 2 * TestConstants.MtdImageTableRecordTestConstants.OBJECT_SIZE_IN_BYTE); TestUtility.AssertAreBinaryEquivalent(TestConstants.MtdImageTableTestConstants.DEFAULT_TO_BYTES, actual); }
public void PackFilesAsMegArchive_Test__CreatedMegFileIsBinaryEquivalent() { string targetDirectory = m_fileSystem.Path.Combine(TestConstants.BASE_PATH, nameof(PackFilesAsMegArchive_Test__CreatedMegFileIsBinaryEquivalent)); const string testMegFileName = "test_meg_file.meg"; IMegFileProcessService svc = new MegFileProcessService(m_fileSystem); svc.PackFilesAsMegArchive(testMegFileName, new Dictionary <string, string> { { $"DATA/XML/{TestConstants.FILE_NAME_CAMPAIGNFILES.ToUpper()}", TestConstants.FILE_PATH_CAMPAIGNFILES }, { $"DATA/XML/{TestConstants.FILE_NAME_GAMEOBJECTFILES.ToUpper()}", TestConstants.FILE_PATH_GAMEOBJECTFILES } }, targetDirectory); byte[] expected = m_fileSystem.File.ReadAllBytes(TestConstants.FILE_PATH_MEG_FILE); byte[] actual = m_fileSystem.File.ReadAllBytes(m_fileSystem.Path.Combine(targetDirectory, testMegFileName)); TestUtility.AssertAreBinaryEquivalent(expected, actual); }