CommandTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  DeltaEngine.Tests.Commands CommandTests

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

public class CommandTests

The CommandTests type exposes the following members.

Constructors

  NameDescription
Public methodCommandTests
Initializes a new instance of the CommandTests class
Top
Methods

  NameDescription
Public methodCommandIsNotPausable
Public methodCommandNameMustBeRegisteredToCreateANewCommand
Public methodCommandWithDragAction
Public methodCommandWithDragActionMock
Public methodCommandWithPositionAction
Public methodCommandWithPositionctionMock
Public methodCommandWithZoomAction
Public methodCommandWithZoomActionMock
Public methodCreateCommandWithManualTrigger
Public methodInitializeResolver
Public methodInvokeOnTrigger
Public methodRegisterCommandWithSeveralTriggers
Public methodRegisteringSameCommandTwiceOverwritesIt
Public methodRunTestAndDisposeResolverWhenDone
Public methodUnableToRegisterCommandWithoutNameOrTriggers
Top
Examples

[Test]
public void CreateCommandWithManualTrigger()
{
    customTrigger = new MockTrigger();
    new Command(() => pos += Time.Delta).Add(customTrigger);
    InvokingTriggerWithoutRunningEntitiesDoesNotCauseAction();
    InvokingTriggerOnceWithMultipleRunsOnlyCausesOneAction();
}
[Test]
public void CommandIsNotPausable()
{
    Assert.IsFalse(new Command(() => { }).IsPauseable);
}
[Test]
public void UnableToRegisterCommandWithoutNameOrTriggers()
{
    Assert.Throws<ArgumentNullException>(() => Command.Register("", null));
    Assert.Throws<Command.UnableToRegisterCommandWithoutTriggers>(
        () => Command.Register("a", null));
}
[Test]
public void RegisteringSameCommandTwiceOverwritesIt()
{
    var exitTrigger = new MockTrigger();
    Command.Register("Exit", exitTrigger);
    Command.Register("Exit", exitTrigger);
}
[Test]
public void CommandNameMustBeRegisteredToCreateANewCommand()
{
    Assert.Throws<Command.CommandNameWasNotRegistered>(
        () => new Command("UnregisteredCommand", (Action)null));
}
[Test]
public void CommandWithPositionAction()
{
    var trigger = new MockMovementTrigger();
    var commandName = RegisterCommand(trigger);
    new Command(commandName, delegate(Vector2D point) { actionPerformed = true; });
[Test]
public void CommandWithDragAction()
{
    var trigger = new MockDragTrigger();
    var commandName = RegisterCommand(trigger);
    new Command(commandName, delegate(Vector2D point, Vector2D dims, bool test)
        { actionPerformed = true; });
    AssertActionPerformed(trigger);
}
[Test]
public void CommandWithZoomAction()
{
    var trigger = new MockZoomTrigger();
    var commandName = RegisterCommand(trigger);
    new Command(commandName, delegate(float zoom) { actionPerformed = true; });
[Test]
public void CommandWithPositionctionMock()
{
    var trigger = new MockTrigger();
    var commandName = RegisterCommand(trigger);
    new Command(commandName, delegate(Vector2D point) { actionPerformed = true; });
[Test]
public void CommandWithDragActionMock()
{
    var trigger = new MockTrigger();
    var commandName = RegisterCommand(trigger);
    new Command(commandName, delegate(Vector2D point, Vector2D dims, bool test)
        { actionPerformed = true; });
    AssertActionPerformed(trigger);
}
[Test]
public void CommandWithZoomActionMock()
{
    var trigger = new MockTrigger();
    const string CommandName = "PositionActionCommand";
    Command.Register(CommandName, trigger);
    actionPerformed = false;
    new Command(CommandName, delegate(float zoom) { actionPerformed = true; });
[Test]
public void RegisterCommandWithSeveralTriggers()
{
    const string CommandName = "CommandWithSeveralTriggers";
    var trigger1 = new MockTrigger();
    var trigger2 = new MockTrigger();
    Command.Register(CommandName, trigger1, trigger2);
    var command = new Command(CommandName, (Action)null);
    Assert.AreEqual(2, command.GetTriggers().Count);
}
[Test]
public void InvokeOnTrigger()
{
    customTrigger = new MockTrigger();
    customTrigger.Invoked = () => { customTrigger.UpdatePriority = Priority.Normal; };
    customTrigger.Invoke();
    Assert.AreEqual(customTrigger.UpdatePriority, Priority.Normal);
    Assert.IsFalse(customTrigger.IsPauseable);
}
See Also