public void GetByteArrayReturnsCorrectlyPopulatedArrayForNegativeIncrements() { var instruction = new IncrementFrameInstruction { RedIncrement = -1, GreenIncrement = -2, BlueIncrement = -3, }; var bytes = instruction.GetReportData(0); Assert.AreEqual(0xff, bytes[1]); Assert.AreEqual(0xfe, bytes[2]); Assert.AreEqual(0xfd, bytes[3]); }
public void GetByteArrayReturnsCorrectArrayLength() { var instruction = new IncrementFrameInstruction { RedIncrement = 0x7f, GreenIncrement = -0x02, BlueIncrement = 0x00, ColorIncrementDelayMs = 0x0f, ColorIncrementCount = 0xff, LedShiftDelayMs = 0x0f, LedShiftCount = 0x03 }; var bytes = instruction.GetReportData(0); Assert.AreEqual(9, bytes.Length); }
private void ProcessIncrementFunction() { var incrementInstruction = new IncrementFrameInstruction(); var nextToken = GetNextToken(); AssertValid(nextToken, "Expected: (", x => x.Type == TokenType.StartFunction); while (nextToken.Type != TokenType.TerminateStatement) { nextToken = GetNextToken(); AssertValid(nextToken, "Expected: parameter keyword or ) or ;", x => x.Type == TokenType.Keyword || x.Type == TokenType.EndFunction || x.Type == TokenType.TerminateStatement); if (nextToken.Type == TokenType.Keyword) { switch (nextToken.RawValue) { case "addRed": incrementInstruction.RedIncrement = (sbyte)ProcessNumber(); break; case "addBlue": incrementInstruction.BlueIncrement = (sbyte)ProcessNumber(); break; case "addGreen": incrementInstruction.GreenIncrement = (sbyte)ProcessNumber(); break; case "incrementColorDelay": incrementInstruction.ColorIncrementDelayMs = (byte)ProcessNumber(); break; case "incrementColorCount": incrementInstruction.ColorIncrementCount = (byte)ProcessNumber(); break; case "rotationDirection": incrementInstruction.LedShiftType = ProcessShiftType(); break; case "rotationDelay": incrementInstruction.LedShiftDelayMs = (byte) ProcessNumber(); break; case "rotationCount": incrementInstruction.LedShiftCount = (byte) ProcessNumber(); break; default: LogError(nextToken, "unknown parameter: " + nextToken.RawValue); break; } nextToken = GetNextToken(); AssertValid(nextToken, "expected: , or )", x => x.Type == TokenType.EndParameterValue || x.Type == TokenType.EndFunction); } } _instructionContextData.Add(GetNewProgramInstruction(incrementInstruction)); }
public void SetFrameHasCorrectInstructionType() { var instruction = new IncrementFrameInstruction(); Assert.AreEqual(InstructionTypes.IncrementFrame, instruction.InstructionType); }