Ejemplo n.º 1
0
        public static void AttachToCurrentTest(this Schema2.ModelRoot model, string fileName)
        {
            // find the output path for the current test
            fileName = TestContext.CurrentContext.GetAttachmentPath(fileName, true);

            if (fileName.ToLower().EndsWith(".glb"))
            {
                model.SaveGLB(fileName);
            }
            else if (fileName.ToLower().EndsWith(".gltf"))
            {
                model.Save(fileName, new Schema2.WriteSettings {
                    JsonIndented = true
                });
            }
            else if (fileName.ToLower().EndsWith(".obj"))
            {
                fileName = fileName.Replace(" ", "_");
                Schema2.Schema2Toolkit.SaveAsWavefront(model, fileName);
            }

            // Attach the saved file to the current test
            TestContext.AddTestAttachment(fileName);

            if (fileName.ToLower().EndsWith(".obj"))
            {
                return;
            }

            var report = gltf_validator.ValidateFile(fileName);

            if (report == null)
            {
                return;
            }

            if (report.HasErrors || report.HasWarnings)
            {
                TestContext.WriteLine(report.ToString());
            }

            Assert.IsFalse(report.HasErrors);
        }
Ejemplo n.º 2
0
        public static void AttachToCurrentTest(this Schema2.ModelRoot model, string fileName)
        {
            // find the output path for the current test
            fileName = NUnit.Framework.TestContext.CurrentContext.GetAttachmentPath(fileName, true);

            if (fileName.ToLower().EndsWith(".glb"))
            {
                model.SaveGLB(fileName);
            }
            else if (fileName.ToLower().EndsWith(".gltf"))
            {
                model.SaveGLTF(fileName, Newtonsoft.Json.Formatting.Indented);
            }
            else if (fileName.ToLower().EndsWith(".obj"))
            {
                Schema2.Schema2Toolkit.SaveAsWavefront(model, fileName);
            }

            // Attach the saved file to the current test
            NUnit.Framework.TestContext.AddTestAttachment(fileName);
        }
Ejemplo n.º 3
0
        public static void AttachToCurrentTest(this Schema2.ModelRoot model, string fileName)
        {
            // find the output path for the current test
            fileName = TestContext.CurrentContext.GetAttachmentPath(fileName, true);

            if (fileName.ToLower().EndsWith(".glb"))
            {
                model.SaveGLB(fileName);
            }
            else if (fileName.ToLower().EndsWith(".gltf"))
            {
                model.Save(fileName, new Schema2.WriteSettings {
                    JsonIndented = true
                });
            }
            else if (fileName.ToLower().EndsWith(".obj"))
            {
                fileName = fileName.Replace(" ", "_");
                Schema2.Schema2Toolkit.SaveAsWavefront(model, fileName);
            }

            // Attach the saved file to the current test
            TestContext.AddTestAttachment(fileName);
        }
Ejemplo n.º 4
0
        public static string AttachToCurrentTest(this Schema2.ModelRoot model, string fileName, WriteSettings settings = null)
        {
            // find the output path for the current test
            fileName = TestContext.CurrentContext.GetAttachmentPath(fileName, true);

            if (fileName.ToLower().EndsWith(".glb"))
            {
                model.SaveGLB(fileName, settings);
            }
            else if (fileName.ToLower().EndsWith(".gltf"))
            {
                if (settings == null)
                {
                    settings = new WriteSettings {
                        JsonIndented = true
                    }
                }
                ;

                model.Save(fileName, settings);
            }
            else if (fileName.ToLower().EndsWith(".obj"))
            {
                fileName = fileName.Replace(" ", "_");
                Schema2.Schema2Toolkit.SaveAsWavefront(model, fileName);
            }
            else if (fileName.ToLower().EndsWith(".plotly"))
            {
                fileName = fileName.Replace(".plotly", ".html");

                var html = model.DefaultScene
                           .ToPlotly()
                           .ToHtml();

                System.IO.File.WriteAllText(fileName, html);
            }

            // Attach the saved file to the current test
            TestContext.AddTestAttachment(fileName);

            if (fileName.ToLower().EndsWith(".obj"))
            {
                return(fileName);
            }

            var report = gltf_validator.ValidateFile(fileName);

            if (report == null)
            {
                return(fileName);
            }

            if (report.HasErrors || report.HasWarnings)
            {
                TestContext.WriteLine(report.ToString());
            }

            Assert.IsFalse(report.HasErrors);

            return(fileName);
        }
    }