private static void DoBody(DataModel dataModel, Action<List<object>> dataLineAction) { var lineList = new List<object>(); for (var dataEntryIndex = 0; dataEntryIndex < dataModel.DataEntriesCount; dataEntryIndex++) { for (var argumentIndex = 0; argumentIndex < dataModel.NumberOfArguments; argumentIndex++) { var value = dataModel.GetMachineArgument(argumentIndex, dataEntryIndex); lineList.Add(value); } for (var functionIndex = 0; functionIndex < dataModel.NumberOfFunctions; functionIndex++) { var value = dataModel.GetMachineFunction(functionIndex, dataEntryIndex); lineList.Add(value); } for (var argumentIndex = 0; argumentIndex < dataModel.NumberOfArguments; argumentIndex++) { var value = dataModel.GetHumanArgument(argumentIndex, dataEntryIndex); lineList.Add(value); } for (var functionIndex = 0; functionIndex < dataModel.NumberOfFunctions; functionIndex++) { var value = dataModel.GetHumanFunction(functionIndex, dataEntryIndex); lineList.Add(value); } dataLineAction(lineList); lineList.Clear(); } }
public void LoadData_TwoQwordFunctions_TwoDataEntries() { var dataPropertiesDto = new FullDataPropertiesDto( new CoreDataPropertiesDto(0, 2, DataType.Byte, DataType.Qword, ArithmeticType.Integer)); var model = new DataModel(string.Empty, dataPropertiesDto, mathService); var data = new byte[] { 0x42, 0x35, 0xAB, 0xCD, 0x01, 0x23, 0x45, 0x67, 0x89, 0x9A, 0xBC, 0xDE, 0xFF, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00, 0x01, 0x02 }; using (var stream = new MemoryStream(data)) { dataService.LoadData(stream, model); } Assert.That(model.DataEntriesCount, Is.EqualTo(2)); Assert.That(model.GetMachineFunction(0, 0), Is.EqualTo("67452301CDAB3542")); Assert.That(model.GetMachineFunction(1, 0), Is.EqualTo("221100FFDEBC9A89")); Assert.That(model.GetMachineFunction(0, 1), Is.EqualTo("AA99887766554433")); Assert.That(model.GetMachineFunction(1, 1), Is.EqualTo("020100FFEEDDCCBB")); }
public void LoadData_TwoDwordFunctions_TwoDataEntries() { var dataPropertiesDto = new FullDataPropertiesDto( new CoreDataPropertiesDto(0, 2, DataType.Byte, DataType.Dword, ArithmeticType.Integer)); var model = new DataModel(string.Empty, dataPropertiesDto, mathService); var data = new byte[] {0x42, 0x54, 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xFF, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55}; using (var stream = new MemoryStream(data)) { dataService.LoadData(stream, model); } Assert.That(model.DataEntriesCount, Is.EqualTo(2)); Assert.That(model.GetMachineFunction(0, 0), Is.EqualTo("34125442")); Assert.That(model.GetMachineFunction(1, 0), Is.EqualTo("BC9A7856")); Assert.That(model.GetMachineFunction(0, 1), Is.EqualTo("1100FFDE")); Assert.That(model.GetMachineFunction(1, 1), Is.EqualTo("55443322")); }
public void LoadData_TwoWordFunctions_OneDataEntry() { var dataPropertiesDto = new FullDataPropertiesDto( new CoreDataPropertiesDto(0, 2, DataType.Byte, DataType.Word, ArithmeticType.Integer)); var model = new DataModel(string.Empty, dataPropertiesDto, mathService); var data = new byte[] {0x42, 0x54, 0x12, 0x34}; using (var stream = new MemoryStream(data)) { dataService.LoadData(stream, model); } Assert.That(model.DataEntriesCount, Is.EqualTo(1)); Assert.That(model.GetMachineFunction(0, 0), Is.EqualTo("5442")); Assert.That(model.GetMachineFunction(1, 0), Is.EqualTo("3412")); }
public void LoadData_OneQwordFunction_OneDataEntry() { var dataPropertiesDto = new FullDataPropertiesDto( new CoreDataPropertiesDto(0, 1, DataType.Byte, DataType.Qword, ArithmeticType.Integer)); var model = new DataModel(string.Empty, dataPropertiesDto, mathService); var data = new byte[] {0x42, 0x35, 0xAB, 0xCD, 0xEF, 0xFF, 0x11, 0x22}; using (var stream = new MemoryStream(data)) { dataService.LoadData(stream, model); } Assert.That(model.DataEntriesCount, Is.EqualTo(1)); Assert.That(model.GetMachineFunction(0, 0), Is.EqualTo("2211FFEFCDAB3542")); }
public void LoadData_OneDwordFunction_TwoDataEntries() { var dataPropertiesDto = new FullDataPropertiesDto( new CoreDataPropertiesDto(0, 1, DataType.Byte, DataType.Dword, ArithmeticType.Integer)); var model = new DataModel(string.Empty, dataPropertiesDto, mathService); var data = new byte[] {0x42, 0x35, 0xAB, 0xCD, 0x01, 0x23, 0x45, 0x67}; using (var stream = new MemoryStream(data)) { dataService.LoadData(stream, model); } Assert.That(model.DataEntriesCount, Is.EqualTo(2)); Assert.That(model.GetMachineFunction(0, 0), Is.EqualTo("CDAB3542")); Assert.That(model.GetMachineFunction(0, 1), Is.EqualTo("67452301")); }