From dccfe8356706f1bb4e037fffd3c09f0dcb95f509 Mon Sep 17 00:00:00 2001 From: mandrolic Date: Wed, 22 Dec 2010 22:30:17 +0000 Subject: [PATCH] Configurator.Net: Fix boolean values, stable mode vm tests git-svn-id: https://arducopter.googlecode.com/svn/trunk@1233 f9c3cf11-9bcb-44bc-f272-b75c42450872 --- .../PresentationModels/MonitorVm.cs | 6 +++- .../Test/StableModeConfigVmTest.cs | 32 ++++++++++++------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/Configurator/Configurator.Net/PresentationModels/MonitorVm.cs b/Configurator/Configurator.Net/PresentationModels/MonitorVm.cs index 709b00a715..c415aa5bf3 100644 --- a/Configurator/Configurator.Net/PresentationModels/MonitorVm.cs +++ b/Configurator/Configurator.Net/PresentationModels/MonitorVm.cs @@ -149,7 +149,11 @@ namespace ArducopterConfigurator for (int i = 0; i < PropsInUpdateOrder.Length; i++) { var prop = this.GetType().GetProperty(PropsInUpdateOrder[i]); - strings[i] = prop.GetValue(this, null).ToString(); + + if (prop.PropertyType == typeof(bool)) + strings[i] = ((bool) prop.GetValue(this, null)) ? "1" : "0"; + else + strings[i] = prop.GetValue(this, null).ToString(); } diff --git a/Configurator/Configurator.Net/Test/StableModeConfigVmTest.cs b/Configurator/Configurator.Net/Test/StableModeConfigVmTest.cs index e9f7c3411d..87ec44e32e 100644 --- a/Configurator/Configurator.Net/Test/StableModeConfigVmTest.cs +++ b/Configurator/Configurator.Net/Test/StableModeConfigVmTest.cs @@ -45,22 +45,30 @@ namespace ArducopterConfiguratorTest Assert.AreEqual("A5;6;7;1;2;3;8;9;10;4;1", _fakeComms.SentItems[0]); } + + [Test] public void UpdateStringReceivedPopulatesValuesCorrectly() { - _fakeComms.FireLineRecieve("B5;6;7;1;2;3;8;9;10;4;1"); + _vm.Activate(); + _fakeComms.FireLineRecieve(sampleLineOfData); + + Assert.AreEqual(1.95f, _vm.RollP); + Assert.AreEqual(0.1f, _vm.RollI); + Assert.AreEqual(0.2f, _vm.RollD); + + Assert.AreEqual(1.95f, _vm.PitchP); + Assert.AreEqual(0.3f, _vm.PitchI); + Assert.AreEqual(0.4f, _vm.PitchD); + + Assert.AreEqual(3.2f, _vm.YawP); + Assert.AreEqual(0.5f, _vm.YawI); + Assert.AreEqual(0.6f, _vm.YawD); + + Assert.AreEqual(0.32f, _vm.KPrate); + + Assert.AreEqual(true, _vm.MagnetometerEnable); - Assert.AreEqual(1.0f, _vm.PitchP); - Assert.AreEqual(2f, _vm.PitchI); - Assert.AreEqual(3f, _vm.PitchD); - Assert.AreEqual(5f, _vm.RollP); - Assert.AreEqual(6f, _vm.RollI); - Assert.AreEqual(7f, _vm.RollD); - Assert.AreEqual(8f, _vm.YawP); - Assert.AreEqual(9f, _vm.YawI); - Assert.AreEqual(10f, _vm.YawD); - Assert.AreEqual(1f, _vm.MagnetometerEnable); - Assert.AreEqual(4f, _vm.KPrate); } } } \ No newline at end of file