Example #1
0
        public void TestDdsFtexRoundtip(DdsTestCase testCase)
        {
            _output.WriteLine("Test '{0}' running", testCase.Description);

            // Setup
            SetupTestCase(testCase, _fixture.TempDdsFileDirectory);

            // Convert the DDS to FTEX
            Program.Main(new[] { testCase.DdsPath });
            // Convert the FTEX back to DDS
            Program.Main(new[] { testCase.FtexPath });

            // Assert
            byte[] expectedBuffer = testCase.Buffer;
            byte[] actualBuffer   = File.ReadAllBytes(testCase.DdsPath);

            ////for (int i = 0; i < expectedBuffer.Length; i++)
            ////{
            ////    byte expected = expectedBuffer[i];
            ////    byte actual = actualBuffer[i];
            ////    Assert.Equal(expected, actual);
            ////}

            Assert.Equal(expectedBuffer.Length, actualBuffer.Length);
            Assert.Equal(expectedBuffer, actualBuffer);

            testCase.File   = null;
            testCase.Buffer = null;

            _output.WriteLine("Test '{0}' OK", testCase.Description);
        }
Example #2
0
        private static void SetupTestCase(DdsTestCase testCase, string tempDdsFileDirectory)
        {
            var ddsFileMemoryStream = new MemoryStream();

            testCase.File = GenerateDds(testCase.Options);
            testCase.File.Write(ddsFileMemoryStream);
            byte[] ddsFileBuffer = ddsFileMemoryStream.ToArray();

            string ddsFilePath = Path.Combine(
                tempDdsFileDirectory,
                Guid.NewGuid() + ".dds");

            File.WriteAllBytes(ddsFilePath, ddsFileBuffer);

            testCase.Buffer   = ddsFileBuffer;
            testCase.DdsPath  = ddsFilePath;
            testCase.FtexPath = Path.ChangeExtension(ddsFilePath, "ftex");
        }