Example #1
0
        public void CatalogSerialization()
        {
            ContentElement boxType = new ContentElement("../../../models/MergeGlTF/Workstation_Pod_SemiPrivate_Harbour - Semi 1600w x 1300d 3.glb",
                                                        new BBox3(new Vector3(-0.5, -0.5, 0), new Vector3(0.5, 0.5, 3)),
                                                        1,
                                                        new Vector3(),
                                                        new Transform(new Vector3(), Vector3.ZAxis),
                                                        BuiltInMaterials.Default,
                                                        null,
                                                        true,
                                                        Guid.NewGuid(),
                                                        "BoxyType");
            ContentElement boxType2 = new ContentElement("../../../models/MergeGlTF/Box.glb",
                                                         new BBox3(new Vector3(-1, -1, 0), new Vector3(1, 1, 2)),
                                                         1,
                                                         new Vector3(),
                                                         new Transform(new Vector3(), Vector3.YAxis),
                                                         BuiltInMaterials.Default,
                                                         null,
                                                         true,
                                                         Guid.NewGuid(),
                                                         "BoxyType");
            var str = boxType2.ToString();

            boxType.AdditionalProperties["ImportantParameter"] = "The Value";


            var testCatalog = new ContentCatalog(new List <ContentElement> {
                boxType, boxType2
            }, Guid.NewGuid(), "test");

            var savePath = "../../../models/ContentCatalog.json";
            var json     = testCatalog.ToJson();

            File.WriteAllText(savePath, json);

            var loadedCatalog = ContentCatalog.FromJson(File.ReadAllText(savePath));

            File.Delete(savePath);
            Assert.Equal(testCatalog.Id, loadedCatalog.Id);
            Assert.Equal(testCatalog.Content.Count, loadedCatalog.Content.Count);
            Assert.Equal("The Value", loadedCatalog.Content[0].AdditionalProperties["ImportantParameter"]);
        }
Example #2
0
 protected static void AssertInputable(ContentElement element)
 {
     Assert.IsTrue(element.IsEnabled, element.ToString());
 }