public void GetVertexList() { var tr = new TestRenderable(); // // Basic Effect Test // var BasicEffectVerts = tr.GetVertexList(EffectsGlobals.BasicEffectName); Assert.IsNotNull(BasicEffectVerts, "BasicEffectVerts list should not be null"); Assert.IsTrue(BasicEffectVerts.Length > 0, "BasicEffectsVerts list should not be empty"); Assert.IsInstanceOfType(BasicEffectVerts.ToArray()[0], typeof(OutsideSimulator.Effects.BasicEffect.BasicEffectVertex), "produces basic vertex type for basic effect"); // // Menu Effect Test // try { var MenuEffectVerts = tr.GetVertexList(EffectsGlobals.MenuEffectName); Assert.Fail("Exception should be thrown when attempting to retrieve menu vertices on a TestObject"); } catch (CannotResolveVerticesException crve) { Assert.AreEqual(EffectsGlobals.MenuEffectName, crve.EffectName, "EffectName given should be MenuEffect when failed on MenuEffect"); Assert.AreEqual("TestRenderable", crve.RenderableName); } // // Arbirary String Effect Test // try { var MenuEffectVerts = tr.GetVertexList("ArbitraryEffect"); Assert.Fail("Exception should be thrown when attempting to retrieve menu vertices on a TestObject"); } catch (CannotResolveVerticesException crve) { Assert.AreEqual("ArbitraryEffect", crve.EffectName); Assert.AreEqual("TestRenderable", crve.RenderableName); } }
/// <summary> /// Serialize into an XML element the IRenderable /// </summary> /// <param name="toSave">The renderable to save</param> /// <returns>An XML string (self-contained)</returns> public static XElement Serialize(IRenderable toSave) { if (toSave == null) { return(null); } else if (toSave is SandTextureTerrain) { TerrainRenderable tr = toSave as TerrainRenderable; XElement ts = new XElement("SandTerrainRenderable", new XElement("width", tr.Width), new XElement("depth", tr.Depth), new XElement("xSubdivisions", tr.XSubdivisions), new XElement("zSubdivisions", tr.ZSubdivisions)); return(ts); } else if (toSave is TerrainRenderable) { TerrainRenderable tr = toSave as TerrainRenderable; XElement ts = new XElement("TerrainRenderable", new XElement("width", tr.Width), new XElement("depth", tr.Depth), new XElement("xSubdivisions", tr.XSubdivisions), new XElement("zSubdivisions", tr.ZSubdivisions)); return(ts); } else if (toSave is MetalWoodTextureDecorator) { MetalWoodTextureDecorator tr = toSave as MetalWoodTextureDecorator; XElement ts = new XElement("MetalWoodTextureCrate"); return(ts); } else if (toSave is TestRenderable) { TestRenderable tr = toSave as TestRenderable; XElement ts = new XElement("TestRenderable"); return(ts); } else if (toSave is SharpRockDecorator) { SharpRockDecorator tr = toSave as SharpRockDecorator; XElement ts = new XElement("SharpRockRenderable"); return(ts); } else if (toSave is RockRenderable) { return(new XElement("RockRenderable")); } else if (toSave is BenchRenderable) { return(new XElement("BenchRenderable")); } else if (toSave is PalmTreeRenderable) { return(new XElement("PalmTreeRenderable")); } else if (toSave is TreeRenderable) { return(new XElement("TreeRenderable")); } else if (toSave is TableRenderable) { return(new XElement("TableRenderable")); } else { throw new InvalidOperationException("Cannot serialize - did not recognize renderable type"); } }
public MetalWoodTextureDecorator(TestRenderable BaseRenderable) : base() { Base = BaseRenderable; }
public void CreateTestRenderable() { var tr = new TestRenderable(); Assert.IsNotNull(tr, "is not null"); }
public void Serialization() { var tr = new TestRenderable(); var tr2 = RenderableFactory.Deserialize(RenderableFactory.Serialize(tr).ToString()); Assert.IsInstanceOfType(tr2, typeof(TestRenderable), "Deserialized result should be an instance of TestRenderable"); }