ShaderWithFormatTests ClassDelta Engine Documentation
Inheritance Hierarchy

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

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

public class ShaderWithFormatTests : TestWithMocksOrVisually

The ShaderWithFormatTests type exposes the following members.

Constructors

  NameDescription
Public methodShaderWithFormatTests
Initializes a new instance of the ShaderWithFormatTests class
Top
Methods

  NameDescription
Protected methodAdvanceTimeAndUpdateEntities (Inherited from TestWithMocksOrVisually.)
Public methodAllowDynamicCreationViaCreationData
Public methodCreateColoredFogShader
Public methodCreateTextureLightMapShader
Public methodCreationOfShaderWithInvalidShaderCodeMustFail
Public methodInitializeResolver (Inherited from TestWithMocksOrVisually.)
Public methodInvalidShaderFlagsThrowsException
Public methodInvalidVertexAndPixelCode
Public methodInvalidVertexFormat
Protected methodRegisterMock T  (Inherited from TestWithMocksOrVisually.)
Protected methodResolve T  (Inherited from TestWithMocksOrVisually.)
Protected methodRunAfterFirstFrame (Inherited from TestWithMocksOrVisually.)
Public methodRunTestAndDisposeResolverWhenDone (Inherited from TestWithMocksOrVisually.)
Top
Properties

  NameDescription
Protected propertyIsMockResolver (Inherited from TestWithMocksOrVisually.)
Top
Examples

[Test, CloseAfterFirstFrame]
public void InvalidVertexFormat()
{
    var invalidData = new ShaderWithFormatCreationData(ShaderFlags.None, "", "", "", "", null);
    Assert.Throws<ShaderWithFormat.InvalidVertexFormat>(
        () => ContentLoader.Create<Shader>(invalidData));
    var emptyFormat = new ShaderWithFormatCreationData(ShaderFlags.None, "", "", "", "",
        new VertexFormat(new VertexElement[0]));
    Assert.Throws<ShaderWithFormat.InvalidVertexFormat>(
        () => ContentLoader.Create<Shader>(emptyFormat));
}
[Test, CloseAfterFirstFrame]
public void InvalidVertexAndPixelCode()
{
    var data = new ShaderWithFormatCreationData(ShaderFlags.None, "", "", "", "",
        VertexFormat.Position2DColor);
    Assert.Throws<ShaderWithFormat.NoShaderCodeSpecifiedForOpenGLAndDirectX>(
        () => ContentLoader.Create<Shader>(data));
}
[Test, CloseAfterFirstFrame]
public void AllowDynamicCreationViaCreationData()
{
    var data = new ShaderWithFormatCreationData(ShaderFlags.None, "AnyData", "AnyData",
        "AnyData", "AnyData", VertexFormat.Position2DColor);
    var shader = ContentLoader.Create<NoDataShaderWithFormat>(data);
    Assert.DoesNotThrow(() => shader.ReloadCreationData(data));
}
[Test, CloseAfterFirstFrame]
public void InvalidShaderFlagsThrowsException()
{
    Assert.Throws<ShaderWithFormat.ShaderFlagsNotSupported>(
        () => new InvalidShaderWithFormat(Resolve<Device>()));
}
[Test, CloseAfterFirstFrame]
public void CreationOfShaderWithInvalidShaderCodeMustFail()
{
    var creationData = new ShaderWithFormatCreationData(ShaderFlags.Colored, "BadGLVertexCode",
        "BadGLFragmentCode", "BadDX11Code", "BadDX9Code", VertexFormat.Position3DColor);
    AssertShaderCreationException(creationData);
    creationData = new ShaderWithFormatCreationData(ShaderFlags.Colored, "AnyData",
        "BadGLFragmentCode", "BadDX11Code", "BadDX9Code", VertexFormat.Position3DColor);
    AssertShaderCreationException(creationData);
    creationData = new ShaderWithFormatCreationData(ShaderFlags.Colored, "AnyData", "AnyData",
        "BadDX11Code", "BadDX9Code", VertexFormat.Position3DColor);
    AssertShaderCreationException(creationData);
    creationData = new ShaderWithFormatCreationData(ShaderFlags.Colored, "AnyData", "AnyData",
        "AnyData", "BadDX9Code", VertexFormat.Position3DColor);
    AssertShaderCreationException(creationData);
}
[Test, CloseAfterFirstFrame]
public void CreateTextureLightMapShader()
{
    var shader = new TextureLightMapShaderWithFormat(Resolve<Device>());
    Assert.IsTrue(shader.Format.HasLightmap);
    Assert.IsTrue(shader.Format.HasUV);
}
[Test, CloseAfterFirstFrame]
public void CreateColoredFogShader()
{
    var shader = new ColoredFogShaderWithFormat(Resolve<Device>());
    Assert.IsTrue(shader.Format.HasColor);
    Assert.IsTrue(shader.Format.Is3D);
}
See Also