Namespace: DeltaEngine.Rendering2D.Tests
Assembly: DeltaEngine.Rendering2D.Tests (in DeltaEngine.Rendering2D.Tests.dll) Version: 1.1.1.0 (1.1.1)
Assembly: DeltaEngine.Rendering2D.Tests (in DeltaEngine.Rendering2D.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax
Examples
[Test] public void SaveAndLoadFromMemoryStream() { var entity = new Entity2D(Rectangle.HalfCentered); entity.OnDraw<MockDrawBehavior>(); Assert.AreEqual(0, entity.NumberOfComponents); var data = BinaryDataExtensions.SaveToMemoryStream(entity); byte[] savedBytes = data.ToArray(); int bytesForName = "Entity2D".Length + 1; const int VersionNumberBytes = 4; int componentBytes = 1 + "Rectangle".Length + 1 + 16 + "IsVisible".Length + 1 + 1 + 2; const int BehaviorBytes = 27; Assert.AreEqual(bytesForName + VersionNumberBytes + componentBytes + BehaviorBytes, savedBytes.Length); var loadedEntity = data.CreateFromMemoryStream() as Entity2D; Assert.AreEqual(0, loadedEntity.NumberOfComponents); Assert.IsTrue(loadedEntity.IsActive); Assert.AreEqual(Rectangle.HalfCentered, loadedEntity.DrawArea); Assert.AreEqual(1, loadedEntity.GetDrawBehaviors().Count); Assert.AreEqual("MockDrawBehavior", loadedEntity.GetDrawBehaviors()[0].GetShortNameOrFullNameIfNotFound()); }
See Also