DrawingTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  DeltaEngine.Platforms TestWithMocksOrVisually
    DeltaEngine.Graphics.Tests DrawingTests

Namespace: DeltaEngine.Graphics.Tests
Assembly: DeltaEngine.Graphics.Tests (in DeltaEngine.Graphics.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class DrawingTests : TestWithMocksOrVisually

The DrawingTests type exposes the following members.

Constructors

  NameDescription
Public methodDrawingTests
Initializes a new instance of the DrawingTests class
Top
Methods

  NameDescription
Protected methodAdvanceTimeAndUpdateEntities (Inherited from TestWithMocksOrVisually.)
Public methodDrawEmptyLine
Public methodDrawRedLine
Public methodIncreaseNumberOfLinesOverTime
Public methodInitializeResolver (Inherited from TestWithMocksOrVisually.)
Public methodLineMaterialShouldNotUseDiffuseMap
Protected methodRegisterMock T  (Inherited from TestWithMocksOrVisually.)
Protected methodResolve T  (Inherited from TestWithMocksOrVisually.)
Protected methodRunAfterFirstFrame (Inherited from TestWithMocksOrVisually.)
Public methodRunTestAndDisposeResolverWhenDone (Inherited from TestWithMocksOrVisually.)
Public methodShowYellowLineFullscreen
Public methodTestViewportPixelSize
Public methodWrapLinesRandomly
Via Lerp we can do fun things like update all lines to new positions each update tick and the drawing will interpolate between them. Here we use just 2 update ticks per second. View code on GitHub
Top
Properties

  NameDescription
Protected propertyIsMockResolver (Inherited from TestWithMocksOrVisually.)
Top
Examples

[Test, ApproveFirstFrameScreenshot]
public void DrawRedLine()
{
    new Line(Vector2D.Zero, new Vector2D(1280, 720), Color.Red);
    RunAfterFirstFrame(
        () => Assert.AreEqual(2, Resolve<Drawing>().NumberOfDynamicVerticesDrawnThisFrame));
}
[Test]
public void IncreaseNumberOfLinesOverTime()
{
    new LineAdder(Vector2D.Zero, new Vector2D(100, 80), Color.Red);
}
/// <summary> 
/// Via Lerp we can do fun things like update all lines to new positions each update tick and 
/// the drawing will interpolate between them. Here we use just 2 update ticks per second. 
/// </summary>
[Test]
public void WrapLinesRandomly()
{
    EntitiesRunner.Current.ChangeUpdateTimeStep(0.5f);
    new RandomLines(100);
}
[Test, ApproveFirstFrameScreenshot]
public void ShowYellowLineFullscreen()
{
    var settings = Resolve<Settings>();
    settings.StartInFullscreen = true;
    settings.Resolution = new Size(1920, 1080);
    new Line(Vector2D.Zero, settings.Resolution, Color.Yellow);
    settings.StartInFullscreen = false;
    settings.Resolution = Settings.DefaultResolution;
}
[Test, CloseAfterFirstFrame]
public void LineMaterialShouldNotUseDiffuseMap()
{
    var drawing = Resolve<Drawing>();
    var shader = ContentLoader.Create<Shader>(
        new ShaderCreationData(ShaderFlags.Position2DTextured));
    var image = ContentLoader.Create<Image>(new ImageCreationData(Size.One));
    var generatedMaterial = new Material(shader, image);
    Assert.Throws<Drawing.LineMaterialShouldNotUseDiffuseMap>(
        () => drawing.AddLines(generatedMaterial, new VertexPosition2DColor[4]));
}
[Test, CloseAfterFirstFrame]
public void TestViewportPixelSize()
{
    var drawing = Resolve<Drawing>();
    var window = Resolve<Window>();
    window.ViewportPixelSize = new Size(800, 600);
    Assert.AreEqual(new Size(800, 600), drawing.ViewportPixelSize);
}
[Test, CloseAfterFirstFrame]
public void DrawEmptyLine()
{
    var line = new Line(Vector2D.Zero, Vector2D.Zero, Color.White);
    line.Set(new VertexPosition2DColor[0]);
}
See Also