Beispiel #1
0
 public TestData(string compressedFilePath, string assemblyPath, string expectedAssemblyPath)
 {
     CompressedFilePath   = Path.Combine(RootPath, compressedFilePath);
     AssemblyPath         = Path.Combine(RootPath, assemblyPath);
     ExpectedAssemblyPath = expectedAssemblyPath;
     RecordInfo           = FileRecordInfo.Create(compressedFilePath);
 }
Beispiel #2
0
        public void RecordFileValidation_OCATCustomFilenameWithoutMetaDataInFilename_IsValidTrue()
        {
            var fileInfo       = new FileInfo(@"TestRecordFiles\CustomFilenameWithoutMetaDataInFilename.csv");
            var fileRecordInfo = FileRecordInfo.Create(fileInfo, "testHash");

            Assert.IsTrue(fileRecordInfo.IsValid);
            Assert.IsFalse(fileRecordInfo.HasInfoHeader);
        }
Beispiel #3
0
        public void RecordFileValidation_InvalidColumnFile_IsValidFalse()
        {
            var fileInfo       = new FileInfo(@"TestRecordFiles\InvalidColumnFile.csv");
            var fileRecordInfo = FileRecordInfo.Create(fileInfo, "testHash");

            Assert.IsFalse(fileRecordInfo.IsValid);
            Assert.IsFalse(fileRecordInfo.HasInfoHeader);
        }
Beispiel #4
0
        public void RecordFileValidation_OCATStandardFile_IsValidTrue()
        {
            var fileInfo       = new FileInfo(@"TestRecordFiles\OCAT-MetroExodus.exe-2019-02-20T101522.csv");
            var fileRecordInfo = FileRecordInfo.Create(fileInfo, "testHash");

            Assert.IsTrue(fileRecordInfo.IsValid);
            Assert.IsFalse(fileRecordInfo.HasInfoHeader);
        }
        public void RecordFileValidation_ShortFile_IsValidFalse()
        {
            var fileInfo       = new FileInfo(@"TestRecordFiles\ShortFile.csv");
            var fileRecordInfo = FileRecordInfo.Create(fileInfo);

            Assert.IsFalse(fileRecordInfo.IsValid);
            Assert.IsFalse(fileRecordInfo.HasInfoHeader);
        }
 public void TestKnownResourceTypeNames()
 {
     foreach (var item in ResourceNames)
     {
         var resourceTypeName         = FileRecordInfo.GetResourceTypeName(item.Value);
         var expectedResourceTypeName = item.Key;
         Assert.AreEqual(resourceTypeName, expectedResourceTypeName);
     }
 }
 public void TestKnownPayloadTypeNames()
 {
     foreach (var item in PayloadNames)
     {
         var payloadTypeName         = FileRecordInfo.GetPayloadTypeName(item.Value);
         var expectedPayloadTypeName = item.Key;
         Assert.AreEqual(payloadTypeName, expectedPayloadTypeName);
     }
 }
 public void TestKnownVariantTypeNames()
 {
     foreach (var item in VariantNames)
     {
         var variantTypeName         = FileRecordInfo.GetVariantTypeName(item.Value);
         var expectedVariantTypeName = item.Key;
         Assert.AreEqual(variantTypeName, expectedVariantTypeName);
     }
 }
Beispiel #9
0
        public void RecordFileValidation_OCATCustomFilenameWithoutComment_IsValidTrue()
        {
            var fileInfo       = new FileInfo(@"TestRecordFiles\CustomFilenameWithoutComment.csv");
            var fileRecordInfo = FileRecordInfo.Create(fileInfo, "testHash");

            Assert.IsTrue(fileRecordInfo.IsValid);
            Assert.IsFalse(fileRecordInfo.HasInfoHeader);
            Assert.AreEqual(null, fileRecordInfo.Comment);
        }
 public void TestRecordCreationResourceNames()
 {
     foreach (var item in ResourceNames)
     {
         var filename = $"0f74af948a58a66a96f4fc282a01ebf1.{item.Key}.v9a8d4bbd19b4cd55.payload.v0.noVariants";
         var info     = FileRecordInfo.Create(filename);
         Assert.AreEqual(info.Resource, item.Value);
         Assert.IsFalse(info.IsRawImage);
     }
 }
Beispiel #11
0
        public void RecordFileValidation_PresentMonTestOutputFile_IsValidTrue()
        {
            var fileInfo       = new FileInfo(@"TestRecordFiles\PresentMonTestOutputFilename.csv");
            var fileRecordInfo = FileRecordInfo.Create(fileInfo, "testHash");

            Assert.IsTrue(fileRecordInfo.IsValid);
            Assert.IsFalse(fileRecordInfo.HasInfoHeader);

            Assert.AreEqual("FarCryNewDawn.exe", fileRecordInfo.GameName);
            Assert.AreEqual("FarCryNewDawn.exe", fileRecordInfo.ProcessName);
        }
Beispiel #12
0
        public void InitFromPath(string filePath)
        {
            Name = Path.GetFileName(filePath);

            var fileInfo = FileRecordInfo.Create(Name);

            Version = fileInfo?.VersionHash ?? string.Empty;
            Hash    = fileInfo?.Hash ?? string.Empty;

            using (var fileStream = File.OpenRead(filePath))
            {
                LoadFromStream(fileStream, Hash);
            }
        }
        public void TestDownloadResourceAsynsUnknown()
        {
            var mockClient = new MockHttpClientProvider();

            mockClient.ClientActionQueue.Enqueue(new MockHttpClientProvider.ClientAction()
            {
                ExpectedAddress = null,
                ReturnedValue   = ExpectedResult,
                ThrownException = null
            });

            var result = FileRecordInfo.DownloadResourceAsync(ResourceId, FileRecordInfo.ResourceType.Unknown, PayloadType, VariantType, mockClient).Result;

            Assert.AreEqual(null, result);
        }
Beispiel #14
0
        public void FileRecordInfo_OCATStandardFile_CorrectSystemInfo()
        {
            var fileInfo       = new FileInfo(@"TestRecordFiles\OCAT-MetroExodus.exe-2019-02-20T101522.csv");
            var fileRecordInfo = FileRecordInfo.Create(fileInfo, "testHash");

            Assert.AreEqual("MetroExodus.exe", fileRecordInfo.GameName);
            Assert.AreEqual("MetroExodus.exe", fileRecordInfo.ProcessName);

            Assert.AreEqual("Micro-Star International Co. Ltd. MPG Z390 GAMING PRO CARBON (MS-7B17)", fileRecordInfo.MotherboardName);
            Assert.AreEqual("Windows 10 Pro 1809 (OS Build 17763.1.amd64fre.rs5_release.180914-1434)", fileRecordInfo.OsVersion);

            Assert.AreEqual("Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz", fileRecordInfo.ProcessorName);
            Assert.AreEqual("GeForce RTX 2080 Ti", fileRecordInfo.GraphicCardName);
            Assert.AreEqual("32 GB DDR4 3200 MT/s", fileRecordInfo.SystemRamInfo);
            Assert.AreEqual("Test", fileRecordInfo.Comment);
        }
        public void TestDownloadResourceAsyncException()
        {
            var mockClient = new MockHttpClientProvider();

            mockClient.ClientActionQueue.Enqueue(new MockHttpClientProvider.ClientAction()
            {
                ExpectedAddress = $"http://sansar-asset-production.s3-us-west-2.amazonaws.com/{AssetName}",
                ReturnedValue   = ExpectedResult,
                ThrownException = new Exception()
            });

            Assert.Throws <AggregateException>(() =>
            {
                var result = FileRecordInfo.DownloadResourceAsync(ResourceId, ResourceType, PayloadType, VariantType, mockClient).Result;
            });
        }
        public void TestDownloadResourceAsyncAllVersions()
        {
            var mockClient = new MockHttpClientProvider();

            mockClient.ClientActionQueue.Enqueue(new MockHttpClientProvider.ClientAction()
            {
                ExpectedAddress = $"http://sansar-asset-production.s3-us-west-2.amazonaws.com/{AssetName}",
                ReturnedValue   = ExpectedResult,
                ThrownException = null
            });

            var result = FileRecordInfo.DownloadResourceAsync(ResourceId, ResourceType, PayloadType, VariantType, mockClient).Result;

            Assert.AreEqual(ExpectedResult, result.Bytes);
            Assert.AreEqual(AssetName, result.Name);
            Assert.AreEqual(AssetVersion, result.Version);
        }
        public void TestRecordCreationVariantTypes()
        {
            var resourceNames = new Dictionary <string, VariantType>
            {
                ["noVariants"] = VariantType.NoVariants,
                ["server"]     = VariantType.Server,
                ["pcClient"]   = VariantType.PcClient,
                ["unknown"]    = VariantType.Unknown
            };

            foreach (var item in resourceNames)
            {
                var filename = $"0f74af948a58a66a96f4fc282a01ebf1.Texture-Resource.v9a8d4bbd19b4cd55.payload.v0.{item.Key}";
                var info     = FileRecordInfo.Create(filename);
                Assert.AreEqual(info.Variant, item.Value);
                Assert.IsFalse(info.IsRawImage);
            }
        }
        public void TestRecordCreationPayloadTypes()
        {
            var resourceNames = new Dictionary <string, PayloadType>
            {
                ["payload"]      = PayloadType.Payload,
                ["manifest"]     = PayloadType.Manifest,
                ["debug"]        = PayloadType.Debug,
                ["capabilities"] = PayloadType.Capabilities,
                ["null"]         = PayloadType.Null,
                ["unknown"]      = PayloadType.Unknown,
            };

            foreach (var item in resourceNames)
            {
                var filename = $"0f74af948a58a66a96f4fc282a01ebf1.Texture-Resource.v9a8d4bbd19b4cd55.{item.Key}.v0.noVariants";
                var info     = FileRecordInfo.Create(filename);
                Assert.AreEqual(info.Payload, item.Value);
                Assert.IsFalse(info.IsRawImage);
            }
        }
        public void TestResourceFilename_Versionhash()
        {
            var hash                 = "0f74af948a58a66a96f4fc282a01ebf1";
            var resourceType         = "Texture-Resource";
            var versionHash          = "9a8d4bbd19b4cd55";
            var payloadType          = "payload";
            var unknownVersionNumber = 0;
            var variants             = "noVariants";

            var info = FileRecordInfo.Create($"{hash}.{resourceType}.v{versionHash}.{payloadType}.v{unknownVersionNumber}.{variants}");

            Assert.NotNull(info);
            Assert.AreEqual(info.Hash, hash);
            Assert.AreEqual(info.ImagePath, null);
            Assert.AreEqual(info.IsRawImage, false);
            Assert.AreEqual(info.Resource, ResourceType.TextureResource);
            Assert.AreEqual(info.Variant, VariantType.NoVariants);
            Assert.AreEqual(info.Payload, PayloadType.Payload);
            Assert.AreEqual(info.VersionHash, versionHash);
            Assert.AreEqual(info.UnknownVersionNumber, unknownVersionNumber);
        }
        protected override void CustomFileExport(ExportParameters exportParameters)
        {
            if (exportParameters.FileExtension == ".fbx")
            {
                var downloadManifestResult = FileRecordInfo.DownloadResourceAsync(
                    exportParameters.FileRecord.Info.Hash,
                    FileRecordInfo.ResourceType.GeometryResourceImport,
                    FileRecordInfo.PayloadType.Manifest,
                    FileRecordInfo.VariantType.NoVariants,
                    new LibSanBag.Providers.HttpClientProvider()
                    ).Result;

                var manifest = ManifestResource.Create();
                manifest.InitFromRawDecompressed(downloadManifestResult.Bytes);
                var sourceGeometryEntry = manifest.Entries.Find(n => n.Name.Contains("Canonical"));
                if (sourceGeometryEntry == default(ManifestResource.ManifestEntry))
                {
                    throw new Exception("Canonical resource not found in import manifest");
                }

                var downloadGeometryResult = FileRecordInfo.DownloadResourceAsync(
                    sourceGeometryEntry.HashString,
                    FileRecordInfo.ResourceType.GeometryResourceCanonical,
                    FileRecordInfo.PayloadType.Payload,
                    FileRecordInfo.VariantType.NoVariants,
                    new LibSanBag.Providers.HttpClientProvider()
                    ).Result;

                var geometryCanonical = GeometryResourceCanonical.Create(downloadGeometryResult.Version);
                geometryCanonical.InitFromRawCompressed(downloadGeometryResult.Bytes);

                var outputName = Path.GetFileName(sourceGeometryEntry.HashString + sourceGeometryEntry.Name + ".fbx");
                File.WriteAllBytes(
                    Path.Combine(exportParameters.OutputDirectory, outputName),
                    geometryCanonical.Resource.Bytes
                    );
            }
        }
Beispiel #21
0
        public void TestToStringWorks()
        {
            using (var inStream = File.OpenRead(SingleFileBagPath))
            {
                var files = Bag.Read(inStream).ToList();
                using (var outStream = new MemoryStream())
                {
                    files[0].Info = null;

                    Assert.DoesNotThrow(() =>
                    {
                        files[0].ToString();
                    });

                    files[0].Info = FileRecordInfo.Create($"0f74af948a58a66a96f4fc282a01ebf1.Texture-Resource.v9a8d4bbd19b4cd55.payload.v0.noVariants");

                    Assert.DoesNotThrow(() =>
                    {
                        files[0].ToString();
                    });
                }
            }
        }
Beispiel #22
0
        public void RecordFileValidation_CapFrameXFileWithHeader_IsValidTrue()
        {
            var fileInfo       = new FileInfo(@"TestRecordFiles\CapFrameXFileWithHeader.csv");
            var fileRecordInfo = FileRecordInfo.Create(fileInfo, "testHash");

            Assert.IsTrue(fileRecordInfo.IsValid);
            Assert.IsTrue(fileRecordInfo.HasInfoHeader);
            Assert.AreEqual("re2.exe", fileRecordInfo.GameName);
            Assert.AreEqual("Resident Evil 2 Remake", fileRecordInfo.ProcessName);
            Assert.AreEqual("2019-03-30", fileRecordInfo.CreationDate);
            Assert.AreEqual("12:01:36", fileRecordInfo.CreationTime);
            Assert.AreEqual("ASUSTeK COMPUTER INC. ROG MAXIMUS XI HERO", fileRecordInfo.MotherboardName);
            Assert.AreEqual("Windows OS", fileRecordInfo.OsVersion);
            Assert.AreEqual("Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz", fileRecordInfo.ProcessorName);
            Assert.AreEqual("NVIDIA GeForce RTX 2080 Ti", fileRecordInfo.GraphicCardName);
            Assert.AreEqual("32 GB 3800 MT/s", fileRecordInfo.SystemRamInfo);
            Assert.AreEqual("bla", fileRecordInfo.BaseDriverVersion);
            Assert.AreEqual("bla", fileRecordInfo.DriverPackage);
            Assert.AreEqual("1", fileRecordInfo.NumberGPUs);
            Assert.AreEqual("1920", fileRecordInfo.GPUCoreClock);
            Assert.AreEqual("7000", fileRecordInfo.GPUMemoryClock);
            Assert.AreEqual("11278", fileRecordInfo.GPUMemory);
            Assert.AreEqual("Test", fileRecordInfo.Comment);
        }
        public void TestUnknownFilename()
        {
            var info = FileRecordInfo.Create("HelloWorld.txt");

            Assert.AreEqual(info, null);
        }
        public void TestEmptyFilename()
        {
            var info = FileRecordInfo.Create("");

            Assert.AreEqual(info, null);
        }
Beispiel #25
0
 public TestData(string compressedFilePath, string expectedContentPath)
 {
     CompressedFilePath   = Path.Combine(RootPath, compressedFilePath);
     ExpectedContentBytes = File.ReadAllBytes(Path.Combine(RootPath, expectedContentPath));
     RecordInfo           = FileRecordInfo.Create(compressedFilePath);
 }
Beispiel #26
0
 public TestData(string compressedFilePath, string expectedFileName)
 {
     CompressedFilePath = Path.Combine(RootPath, compressedFilePath);
     RecordInfo         = FileRecordInfo.Create(compressedFilePath);
     ExpectedFileName   = expectedFileName;
 }
Beispiel #27
0
 public TestData(string compressedFilePath, string jsonFilePath)
 {
     JsonFilePath       = jsonFilePath;
     CompressedFilePath = Path.Combine(RootPath, compressedFilePath);
     RecordInfo         = FileRecordInfo.Create(compressedFilePath);
 }
        public void TestImageFilename()
        {
            var info = FileRecordInfo.Create("0f74af948a58a66a96f4fc282a01ebf1.HelloWorld.png");

            Assert.IsTrue(info.IsRawImage);
        }