Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions IPX800cs.Test/Commands/Builders/CommandFactoryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ public static void AssertCommandAreEqual(Command expected, Command actual)
Assert.Equal(expected.ContentType, actual.ContentType);
Assert.Equal(expected.QueryString, actual.QueryString);
}

private static void AssertOutputIsNotAltered(Output original, Output copy)
{
Assert.Equal(copy.Type, original.Type);
Assert.Equal(copy.State, original.State);
Assert.Equal(copy.Number, original.Number);
}

#region GetInputCommand

Expand Down Expand Up @@ -151,8 +158,10 @@ public void GivenUnsupportedAnalogInput_CreateGetAnalogInputsCommand_ThrowsExcep
[MemberData(nameof(IPX800V5HttpCommandFactoryTestCases.SupportedGetOutputTestCases), MemberType = typeof(IPX800V5HttpCommandFactoryTestCases))]
public void GivenSupportedOutput_CreateGetOutputCommand_ReturnsMatchingCommand(Output output, Command expectedCommand, ICommandFactory commandFactory)
{
var outputCopy = new Output { Type = output.Type, State = output.State, Number = output.Number };
var command = commandFactory.CreateGetOutputCommand(output);
AssertCommandAreEqual(expectedCommand, command);
AssertOutputIsNotAltered(output, outputCopy);
}

[Theory]
Expand All @@ -179,9 +188,9 @@ public void GivenUnsupportedOutput_CreateGetOutputCommand_ThrowsException(Output
[MemberData(nameof(IPX800V4HttpCommandFactoryTestCases.SupportedGetOutputsTestCases), MemberType = typeof(IPX800V4HttpCommandFactoryTestCases))]
[MemberData(nameof(IPX800V4M2MCommandFactoryTestCases.SupportedGetOutputsTestCases), MemberType = typeof(IPX800V4M2MCommandFactoryTestCases))]
[MemberData(nameof(IPX800V5HttpCommandFactoryTestCases.SupportedGetOutputsTestCases), MemberType = typeof(IPX800V5HttpCommandFactoryTestCases))]
public void GivenSupportedOutput_CreateGetOutputsCommand_ReturnsMatchingCommand(OutputType inputType, Command expectedCommand, ICommandFactory commandFactory)
public void GivenSupportedOutput_CreateGetOutputsCommand_ReturnsMatchingCommand(OutputType outputType, Command expectedCommand, ICommandFactory commandFactory)
{
var command = commandFactory.CreateGetOutputsCommand(inputType);
var command = commandFactory.CreateGetOutputsCommand(outputType);
AssertCommandAreEqual(expectedCommand, command);
}

Expand Down Expand Up @@ -212,8 +221,10 @@ public void GivenUnsupportedOutput_CreateGetOutputsCommand_ThrowsException(Outpu
[MemberData(nameof(IPX800V5HttpCommandFactoryTestCases.SupportedSetOutputTestCases), MemberType = typeof(IPX800V5HttpCommandFactoryTestCases))]
public void GivenSupportedOutput_CreateSetOutputCommand_ReturnsMatchingCommand(Output output, Command expectedCommand, ICommandFactory commandFactory)
{
var outputCopy = new Output { Type = output.Type, State = output.State, Number = output.Number };
var command = commandFactory.CreateSetOutputCommand(output);
AssertCommandAreEqual(expectedCommand, command);
AssertOutputIsNotAltered(output, outputCopy);
}

[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public Command BuildCommandString(Output output)
{
if (output.Type == OutputType.DelayedOutput)
{
return Command.CreateGet($"{IPX800V3HttpCommandStrings.SetOutputDelayed}={--output.Number}");
return Command.CreateGet($"{IPX800V3HttpCommandStrings.SetOutputDelayed}={output.Number-1}");
}
else
{
Expand Down
Loading