public void GetByteArrayReturnsCorrectArrayLength() { var instruction = new SetFrameInstruction { Color = { Red = 0xff, Green = 0x00, Blue = 0x10 }, Leds = { LedRawBits = 0xaa55 }, MillisecondsHold = 0xbb66, }; var bytes = instruction.GetReportData(0); Assert.AreEqual(9, bytes.Length); }
public void GetByteArrayReturnsCorrectlyPopulatedArray() { var instruction = new SetFrameInstruction { Color = { Red = 0xff, Green = 0x00, Blue = 0x10 }, Leds = { LedRawBits = 0xaa55 }, MillisecondsHold = 0xbb66, }; var bytes = instruction.GetReportData(0); Assert.AreEqual(0x00, bytes[0]); Assert.AreEqual(0xff, bytes[1]); Assert.AreEqual(0x00, bytes[2]); Assert.AreEqual(0x10, bytes[3]); Assert.AreEqual(0x55, bytes[4]); Assert.AreEqual(0xaa, bytes[5]); Assert.AreEqual(0x66, bytes[6]); Assert.AreEqual(0xbb, bytes[7]); Assert.AreEqual(0x00, bytes[8]); }
private void ProcessSetFunction() { var setInstruction = new SetFrameInstruction(); 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 "color": setInstruction.Color = ProcessColor(); break; case "duration": setInstruction.MillisecondsHold = (ushort)ProcessNumber(); break; case "ledsOn": setInstruction.Leds = ProcessLedStateArray(); 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(setInstruction)); }
public void SetFrameHasCorrectInstructionType() { var instruction = new SetFrameInstruction(); Assert.AreEqual(InstructionTypes.SetFrame, instruction.InstructionType); }