diff --git a/VECTO.sln b/VECTO.sln index 6d4ff71f27ed646a5120f913364b3a44702abb21..a27ebbaf909b63ddb6baff238ef00d3acac4ee12 100644 --- a/VECTO.sln +++ b/VECTO.sln @@ -74,7 +74,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VectoAPI", "..\VECTO_API_DE EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VECTO3GUI2020", "VECTO3GUI2020\VECTO3GUI2020.csproj", "{7E9172D4-07E3-4077-814E-7117AB2B3E22}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vecto3GUITest", "Vecto3GUITest\Vecto3GUITest.csproj", "{31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vecto3GUI2020Test", "Vecto3GUI2020Test\Vecto3GUI2020Test.csproj", "{7F4FF473-96B3-461E-9CE6-76D3B75F87CB}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -910,48 +910,48 @@ Global {7E9172D4-07E3-4077-814E-7117AB2B3E22}.ReleaseTUG|x64.Build.0 = Release|Any CPU {7E9172D4-07E3-4077-814E-7117AB2B3E22}.ReleaseTUG|x86.ActiveCfg = Release|Any CPU {7E9172D4-07E3-4077-814E-7117AB2B3E22}.ReleaseTUG|x86.Build.0 = Release|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Debug PerformanceStats|Any CPU.ActiveCfg = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Debug PerformanceStats|Any CPU.Build.0 = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Debug PerformanceStats|x64.ActiveCfg = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Debug PerformanceStats|x64.Build.0 = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Debug PerformanceStats|x86.ActiveCfg = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Debug PerformanceStats|x86.Build.0 = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Debug PerformanceTrace|Any CPU.ActiveCfg = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Debug PerformanceTrace|Any CPU.Build.0 = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Debug PerformanceTrace|x64.ActiveCfg = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Debug PerformanceTrace|x64.Build.0 = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Debug PerformanceTrace|x86.ActiveCfg = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Debug PerformanceTrace|x86.Build.0 = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Debug|x64.ActiveCfg = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Debug|x64.Build.0 = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Debug|x86.ActiveCfg = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Debug|x86.Build.0 = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.DebugTUG|Any CPU.ActiveCfg = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.DebugTUG|Any CPU.Build.0 = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.DebugTUG|x64.ActiveCfg = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.DebugTUG|x64.Build.0 = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.DebugTUG|x86.ActiveCfg = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.DebugTUG|x86.Build.0 = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Deploy|Any CPU.ActiveCfg = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Deploy|Any CPU.Build.0 = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Deploy|x64.ActiveCfg = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Deploy|x64.Build.0 = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Deploy|x86.ActiveCfg = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Deploy|x86.Build.0 = Debug|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Release|Any CPU.Build.0 = Release|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Release|x64.ActiveCfg = Release|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Release|x64.Build.0 = Release|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Release|x86.ActiveCfg = Release|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.Release|x86.Build.0 = Release|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.ReleaseTUG|Any CPU.ActiveCfg = Release|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.ReleaseTUG|Any CPU.Build.0 = Release|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.ReleaseTUG|x64.ActiveCfg = Release|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.ReleaseTUG|x64.Build.0 = Release|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.ReleaseTUG|x86.ActiveCfg = Release|Any CPU - {31248C1A-85A9-4D4C-9DDB-0D56E1599C7E}.ReleaseTUG|x86.Build.0 = Release|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Debug PerformanceStats|Any CPU.ActiveCfg = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Debug PerformanceStats|Any CPU.Build.0 = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Debug PerformanceStats|x64.ActiveCfg = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Debug PerformanceStats|x64.Build.0 = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Debug PerformanceStats|x86.ActiveCfg = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Debug PerformanceStats|x86.Build.0 = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Debug PerformanceTrace|Any CPU.ActiveCfg = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Debug PerformanceTrace|Any CPU.Build.0 = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Debug PerformanceTrace|x64.ActiveCfg = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Debug PerformanceTrace|x64.Build.0 = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Debug PerformanceTrace|x86.ActiveCfg = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Debug PerformanceTrace|x86.Build.0 = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Debug|x64.ActiveCfg = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Debug|x64.Build.0 = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Debug|x86.ActiveCfg = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Debug|x86.Build.0 = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.DebugTUG|Any CPU.ActiveCfg = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.DebugTUG|Any CPU.Build.0 = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.DebugTUG|x64.ActiveCfg = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.DebugTUG|x64.Build.0 = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.DebugTUG|x86.ActiveCfg = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.DebugTUG|x86.Build.0 = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Deploy|Any CPU.ActiveCfg = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Deploy|Any CPU.Build.0 = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Deploy|x64.ActiveCfg = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Deploy|x64.Build.0 = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Deploy|x86.ActiveCfg = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Deploy|x86.Build.0 = Debug|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Release|Any CPU.Build.0 = Release|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Release|x64.ActiveCfg = Release|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Release|x64.Build.0 = Release|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Release|x86.ActiveCfg = Release|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.Release|x86.Build.0 = Release|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.ReleaseTUG|Any CPU.ActiveCfg = Release|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.ReleaseTUG|Any CPU.Build.0 = Release|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.ReleaseTUG|x64.ActiveCfg = Release|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.ReleaseTUG|x64.Build.0 = Release|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.ReleaseTUG|x86.ActiveCfg = Release|Any CPU + {7F4FF473-96B3-461E-9CE6-76D3B75F87CB}.ReleaseTUG|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/VECTO3GUI2020/App.xaml b/VECTO3GUI2020/App.xaml index 7f48e14516f0cb0ec0ba4eaea77785c5030dcd26..b82b65b9f27c4520086b1634ee67f5893b6906a4 100644 --- a/VECTO3GUI2020/App.xaml +++ b/VECTO3GUI2020/App.xaml @@ -1,7 +1,8 @@ <Application x:Class="VECTO3GUI2020.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:local="clr-namespace:VECTO3GUI2020"> + xmlns:local="clr-namespace:VECTO3GUI2020" + ShutdownMode="OnMainWindowClose"> <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> @@ -19,4 +20,5 @@ </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> + </Application> diff --git a/VECTO3GUI2020/App.xaml.cs b/VECTO3GUI2020/App.xaml.cs index a74dff5f5731900c42404cb38ef88b35ffc23b58..eb0f63b9761845715b48454d9ea20be1d744364d 100644 --- a/VECTO3GUI2020/App.xaml.cs +++ b/VECTO3GUI2020/App.xaml.cs @@ -63,6 +63,7 @@ namespace VECTO3GUI2020 var mainwindow = container.Get<MainWindow>(); this.MainWindow = mainwindow; + Application.Current.MainWindow = mainwindow; this.MainWindow.Show(); diff --git a/VECTO3GUI2020/Helper/DialogHelper.cs b/VECTO3GUI2020/Helper/DialogHelper.cs index 1e6c7bdfe2dff2828217665b667bb9fe5f551d00..3c85504230abf8bc78bc2de5ffc85ffb567afdfb 100644 --- a/VECTO3GUI2020/Helper/DialogHelper.cs +++ b/VECTO3GUI2020/Helper/DialogHelper.cs @@ -49,12 +49,19 @@ namespace VECTO3GUI2020.Helper return OpenFilesDialog(filter, initialDirectory, true); } + public string OpenXMLFileDialog() + { + return OpenXMLFileDialog(null); + } + + + public string[] OpenXMLFilesDialog(string initialDirectory) { return OpenFilesDialog(_xmlFilter, initialDirectory); } - public string OpenXMLFileDialog(string initialDirectory = null) + public string OpenXMLFileDialog(string initialDirectory) { return OpenFilesDialog(_xmlFilter, initialDirectory, false)?[0]; } @@ -138,7 +145,9 @@ namespace VECTO3GUI2020.Helper /// </summary> /// <param name="initialDirectory">If no directory is specified the location of the assembly is used</param> /// <returns></returns> - string OpenXMLFileDialog(string initialDirectory = null); + string OpenXMLFileDialog(string initialDirectory); + + string OpenXMLFileDialog(); /// <summary> diff --git a/VECTO3GUI2020/Test.xaml b/VECTO3GUI2020/Test.xaml index d82af086ae049c3ca388983b114f54bfa791d508..d369f8afee1b7a68106314a3215b6bc5ed2e39fe 100644 --- a/VECTO3GUI2020/Test.xaml +++ b/VECTO3GUI2020/Test.xaml @@ -7,9 +7,9 @@ xmlns:customControls="clr-namespace:VECTO3GUI2020.Views.Multistage.CustomControls" xmlns:helper="clr-namespace:VECTO3GUI2020.Helper" mc:Ignorable="d" - d:DesignHeight="450" d:DesignWidth="800" Background="Pink" d:DataContext="{d:DesignInstance local:TestViewModel }"> + d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance local:TestViewModel }"> - <Grid> + <Grid Visibility="Collapsed"> <!--https://www.thomasclaudiushuber.com/2008/01/10/bind-to-methods-with-objectdataprovider/--> <StackPanel> diff --git a/VECTO3GUI2020/Util/XML/Implementation/ComponentWriter/XMLBusAuxiliariesWriter.cs b/VECTO3GUI2020/Util/XML/Implementation/ComponentWriter/XMLBusAuxiliariesWriter.cs index e1a8c3722705efb4bcd09d5e0732c1fadece1e8f..750b364be51199752c0ce1b8d6b866d7b9ab1285 100644 --- a/VECTO3GUI2020/Util/XML/Implementation/ComponentWriter/XMLBusAuxiliariesWriter.cs +++ b/VECTO3GUI2020/Util/XML/Implementation/ComponentWriter/XMLBusAuxiliariesWriter.cs @@ -97,6 +97,8 @@ namespace VECTO3GUI2020.Util.XML.Implementation.ComponentWriter hvacElement.Add(new XElement(_defaultNamespace + XMLNames.Bus_OtherHeatingTechnology, _inputData.HVACAux.OtherHeatingTechnology)); dataElement.Add(hvacElement); } + + dataElement.DescendantsAndSelf().Where(e => e.Value.IsNullOrEmpty()).Remove(); } #endregion diff --git a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/InterimStageBusVehicleViewModel_v2_8.cs b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/InterimStageBusVehicleViewModel_v2_8.cs index cbe8c616b3bb8bb164fbcc1720f58eeaf19b765c..94c35be2a1da579190f4ad3593b08e33ab92c78c 100644 --- a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/InterimStageBusVehicleViewModel_v2_8.cs +++ b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/InterimStageBusVehicleViewModel_v2_8.cs @@ -74,7 +74,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation } - class DeclarationInterimStageBusVehicleViewModel_v2_8 : ViewModelBase, IMultistageVehicleViewModel, + public class DeclarationInterimStageBusVehicleViewModel_v2_8 : ViewModelBase, IMultistageVehicleViewModel, IVehicleComponentsDeclaration, IAdvancedDriverAssistantSystemDeclarationInputData, IDataErrorInfo { @@ -121,10 +121,11 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation ConsolidatedVehicleData = consolidatedVehicleData; _multiStageViewModelFactory = multistageViewModelFactory; - MultistageAirdragViewModel = _multiStageViewModelFactory.GetMultistageAirdragViewModel(consolidatedVehicleData.Components.AirdragInputData); + MultistageAirdragViewModel = _multiStageViewModelFactory.GetMultistageAirdragViewModel(consolidatedVehicleData?.Components?.AirdragInputData); MultistageAuxiliariesViewModel = - _multiStageViewModelFactory.GetAuxiliariesViewModel(consolidatedVehicleData.Components + _multiStageViewModelFactory.GetAuxiliariesViewModel(consolidatedVehicleData?.Components? .BusAuxiliaries); + AirdragModifiedMultistageEditingEnabled = false; } public IVehicleDeclarationInputData ConsolidatedVehicleData @@ -146,6 +147,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation public void SetVehicleInputData(IVehicleDeclarationInputData vehicleInputData) { Manufacturer = vehicleInputData.Manufacturer; + Identifier = vehicleInputData.Identifier; ManufacturerAddress = vehicleInputData.ManufacturerAddress; VIN = vehicleInputData.VIN; Model = vehicleInputData.Model; @@ -170,7 +172,10 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation EcoRollTypeNullable = vehicleInputData.ADAS?.EcoRoll; PredictiveCruiseControlNullable = vehicleInputData.ADAS?.PredictiveCruiseControl; ATEcoRollReleaseLockupClutch = vehicleInputData.ADAS?.ATEcoRollReleaseLockupClutch; + AirdragModifiedMultistage = vehicleInputData.AirdragModifiedMultistage; + AirdragModifiedMultistageEditingEnabled = false; OnPropertyChanged(String.Empty); + } @@ -246,7 +251,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation public ConvertedSI ConsolidatedHeightInMm { - get { return ConsolidatedVehicleData.Height?.ConvertToMilliMeter(); } + get { return ConsolidatedVehicleData?.Height?.ConvertToMilliMeter(); } set { throw new NotImplementedException(); } } @@ -268,7 +273,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation public ConvertedSI ConsolidatedLengthInMm { - get { return ConsolidatedVehicleData.Length?.ConvertToMilliMeter(); } + get { return ConsolidatedVehicleData?.Length?.ConvertToMilliMeter(); } set { throw new NotImplementedException(); } } @@ -291,7 +296,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation public ConvertedSI ConsolidatedWidthInMm { - get { return ConsolidatedVehicleData.Width?.ConvertToMilliMeter(); } + get { return ConsolidatedVehicleData?.Width?.ConvertToMilliMeter(); } set { throw new NotImplementedException(); } } @@ -308,7 +313,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation public ConvertedSI ConsolidatedEntranceHeightInMm { - get { return ConsolidatedVehicleData.EntranceHeight?.ConvertToMilliMeter(); } + get { return ConsolidatedVehicleData?.EntranceHeight?.ConvertToMilliMeter(); } set { throw new NotImplementedException(); } } @@ -397,11 +402,19 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation public AirdragModifiedEnum ConsolidatedAirdragModifiedEnum { - get => _consolidatedVehicleData.AirdragModifiedMultistage.toAirdragModifiedEnum(); + get + { + if (_consolidatedVehicleData?.AirdragModifiedMultistage != null) { + return _consolidatedVehicleData.AirdragModifiedMultistage.toAirdragModifiedEnum(); + } else { + return AirdragModifiedEnum.UNKNOWN; + } + + } set => throw new NotImplementedException(); } - public bool? AirdragModifiedMultistage + public bool? AirdragModifiedMultistage { get => _airdragModifiedMultistage; set => SetProperty(ref _airdragModifiedMultistage, value); @@ -413,7 +426,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation get { //IF MODIFIED ONCE IT HAS TO BE SET - if (_consolidatedVehicleData.AirdragModifiedMultistage != null) { + if (_consolidatedVehicleData?.AirdragModifiedMultistage != null) { _airdragModifiedEditingEnabled = true; } return _airdragModifiedEditingEnabled; @@ -453,10 +466,9 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation #endregion - + private string _identifier; private IVehicleDeclarationInputData _consolidatedVehicleData; private VehicleDeclarationType _vehicleDeclarationType; - private IBusAuxiliariesDeclarationData _busAuxiliaries; #region implementation of IVehicleComponentsDeclaration @@ -468,7 +480,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation public IBusAuxiliariesDeclarationData BusAuxiliaries { - get => MultistageAuxiliariesViewModel; + get => MultistageAuxiliariesViewModel.HasValues ? MultistageAuxiliariesViewModel : null; } #region not implemented @@ -598,7 +610,14 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation public string Identifier { - get { throw new NotImplementedException(); } + get + { + return _identifier; + } + private set + { + SetProperty(ref _identifier, value); + } } public bool ExemptedVehicle diff --git a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/ManufacturingStageViewModel_v0_1.cs b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/ManufacturingStageViewModel_v0_1.cs index d6bbe42dc6f1402e54694128b44479e6605a707d..1153d2f2a7f8752f60ec38a2df2acef6a06bcfe1 100644 --- a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/ManufacturingStageViewModel_v0_1.cs +++ b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/ManufacturingStageViewModel_v0_1.cs @@ -80,11 +80,11 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation public ManufacturingStageViewModel_v0_1(IManufacturingStageInputData consolidatedManufacturingStageInputData, IMultiStageViewModelFactory viewModelFactory) { _viewModelFactory = viewModelFactory; - _stageCount = consolidatedManufacturingStageInputData.StageCount + 1; + _stageCount = consolidatedManufacturingStageInputData?.StageCount?? + 1; _consolidatedManufacturingStageInputData = consolidatedManufacturingStageInputData; - VehicleViewModel = (IMultistageVehicleViewModel)_viewModelFactory.GetInterimStageVehicleViewModel(consolidatedManufacturingStageInputData.Vehicle); + VehicleViewModel = (IMultistageVehicleViewModel)_viewModelFactory.GetInterimStageVehicleViewModel(consolidatedManufacturingStageInputData?.Vehicle); CurrentView = VehicleViewModel as IViewModelBase; diff --git a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageAirdragViewModel.cs b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageAirdragViewModel.cs index 3823f8e6ee37eba3c51153a74df394865a4f46fe..598a8c25b3085ade04c0c92197e38833bdf25a82 100644 --- a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageAirdragViewModel.cs +++ b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageAirdragViewModel.cs @@ -115,7 +115,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation if (!valid) { throw new VectoException("Invalid input file"); } - + //dataProviderVersion = XMLHelper.GetVersion(doc.Node); XElement airdragElement = airdragElements.First(); diff --git a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageAuxiliariesViewModel.cs b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageAuxiliariesViewModel.cs index 2451a7da2d10af5eddf773dbcdd24e5afb0d5041..786d9af7680cef897dc9d59d3d84ce26e85e712f 100644 --- a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageAuxiliariesViewModel.cs +++ b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageAuxiliariesViewModel.cs @@ -18,6 +18,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation IHVACBusAuxiliariesDeclarationData { void SetAuxiliariesInputData(IBusAuxiliariesDeclarationData componentsAuxiliaryInputData); + bool HasValues { get; } } @@ -33,7 +34,39 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation set => SetProperty(ref _consolidatedInputData, value); } - #region HVAV + public bool HasValues + { + get + { + var hasValues = false; + + + //Check if one of the Implemented properties of is not null + var HVACinterfaceProperties = typeof(IHVACBusAuxiliariesDeclarationData).GetProperties(); + + var notImplemented = new List<string>(new string[] { + nameof(IHVACBusAuxiliariesDeclarationData.AdjustableCoolantThermostat), + nameof(IHVACBusAuxiliariesDeclarationData.EngineWasteGasHeatExchanger) + }); + foreach (var propInfo in HVACinterfaceProperties) { + if (notImplemented.Contains(propInfo.Name)) continue; + hasValues = hasValues || propInfo.GetValue(this) != null; + } + + + var ElectricConsumersInterfaceProperties = typeof(IElectricConsumersDeclarationData).GetProperties(); + foreach (var propInfo in ElectricConsumersInterfaceProperties) { + hasValues = hasValues || propInfo.GetValue(this) != null; + } + + + + return hasValues; + } + } + + + #region HVAC private bool _heatPumpGroupEditingEnabled; private BusHVACSystemConfiguration? _systemConfiguration; @@ -103,6 +136,10 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation set => SetProperty(ref _otherHeatingTechnology, value); } + public bool? AdjustableCoolantThermostat => throw new NotImplementedException(); + + public bool EngineWasteGasHeatExchanger => throw new NotImplementedException(); + public bool HeatPumpGroupEditingEnabled { get => _heatPumpGroupEditingEnabled; @@ -139,6 +176,8 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation set => SetProperty(ref _heatPumpModePassengerCompartment, value); } +#endregion + #region IElectricConsumersDeclaration //LED lights private bool? _interiorLightsLed; @@ -181,46 +220,15 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation #endregion - #region Implementation of interfaces; - - private XmlNode _xmlSource; - private string _fanTechnology; - private IList<string> _steeringPumpTechnology; - private bool _smartElectrics; - private Watt _maxAlternatorPower; - private WattSecond _electricStorageCapacity; - private string _clutch; - private double _ratio; - private string _compressorSize; - private bool _smartAirCompression; - private bool _smartRegeneration; - - private ConsumerTechnology _airsuspensionControl; - private ConsumerTechnology _adBlueDosing; - private bool? _adjustableCoolantThermostat; - private bool _engineWasteGasHeatExchanger; + #region Implementation of interfaces (unused Properties); + public XmlNode XMLSource => throw new NotImplementedException(); + public string FanTechnology => throw new NotImplementedException(); - public XmlNode XMLSource - { - get => _xmlSource; - set => _xmlSource = value; - } - - public string FanTechnology - { - get => _fanTechnology; - set => _fanTechnology = value; - } - - public IList<string> SteeringPumpTechnology - { - get => _steeringPumpTechnology; - set => _steeringPumpTechnology = value; - } + public IList<string> SteeringPumpTechnology => throw new NotImplementedException(); public IElectricSupplyDeclarationData ElectricSupply { @@ -248,87 +256,6 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation - public IList<IAlternatorDeclarationInputData> Alternators - { - get => throw new NotImplementedException(); - set => throw new NotImplementedException(); - } - - public bool SmartElectrics - { - get => _smartElectrics; - set => _smartElectrics = value; - } - - public Watt MaxAlternatorPower - { - get => _maxAlternatorPower; - set => _maxAlternatorPower = value; - } - - public WattSecond ElectricStorageCapacity - { - get => _electricStorageCapacity; - set => _electricStorageCapacity = value; - } - - public string Clutch - { - get => _clutch; - set => _clutch = value; - } - - public double Ratio - { - get => _ratio; - set => _ratio = value; - } - - public string CompressorSize - { - get => _compressorSize; - set => _compressorSize = value; - } - - public bool SmartAirCompression - { - get => _smartAirCompression; - set => _smartAirCompression = value; - } - - public bool SmartRegeneration - { - get => _smartRegeneration; - set => _smartRegeneration = value; - } - - - public ConsumerTechnology AirsuspensionControl - { - get => _airsuspensionControl; - set => _airsuspensionControl = value; - } - - public ConsumerTechnology AdBlueDosing - { - get => _adBlueDosing; - set => _adBlueDosing = value; - } - - - - - public bool? AdjustableCoolantThermostat - { - get => _adjustableCoolantThermostat; - set => _adjustableCoolantThermostat = value; - } - - public bool EngineWasteGasHeatExchanger - { - get => _engineWasteGasHeatExchanger; - set => _engineWasteGasHeatExchanger = value; - } @@ -390,5 +317,38 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation ConsolidatedInputData = consolidatedAuxiliariesInputData; } + #region Implementation of IElectricSupplyDeclarationData + + public IList<IAlternatorDeclarationInputData> Alternators => throw new NotImplementedException(); + + public bool SmartElectrics => throw new NotImplementedException(); + + public Watt MaxAlternatorPower => throw new NotImplementedException(); + + public WattSecond ElectricStorageCapacity => throw new NotImplementedException(); + + #endregion + + #region Implementation of IPneumaticSupplyDeclarationData + + public string Clutch => throw new NotImplementedException(); + + public double Ratio => throw new NotImplementedException(); + + public string CompressorSize => throw new NotImplementedException(); + + public bool SmartAirCompression => throw new NotImplementedException(); + + public bool SmartRegeneration => throw new NotImplementedException(); + + #endregion + + #region Implementation of IPneumaticConsumersDeclarationData + + public ConsumerTechnology AirsuspensionControl => throw new NotImplementedException(); + + public ConsumerTechnology AdBlueDosing => throw new NotImplementedException(); + + #endregion } } \ No newline at end of file diff --git a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageJobViewModel_v0_1.cs b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageJobViewModel_v0_1.cs index 36434ea5181ea179982ae0d8107b8fc70efa8387..095048ec5b08bd8d4408768df51f424166b02ee8 100644 --- a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageJobViewModel_v0_1.cs +++ b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageJobViewModel_v0_1.cs @@ -91,7 +91,6 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation } - if (filename == null) { filename = _dialogHelper.Value.SaveToXMLDialog(Settings.Default.DefaultFilePath); if (filename == null) { @@ -130,6 +129,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation private readonly Lazy<IXMLInputDataReader> _inputDataReader; private string _vehicleInputDataFilePath = null; private readonly IMultistageDependencies _multistageDependencies; + private readonly DataSource _dataSource; public ICommand LoadVehicleDataCommand { @@ -178,7 +178,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation public MultiStageJobViewModel_v0_1(IMultistageBusInputDataProvider inputData, IMultiStageViewModelFactory vmFactory, IMultistageDependencies multistageDependencies ) { - + _dataSource = inputData.DataSource; _jobInputData = inputData.JobInputData; _vmFactory = vmFactory; _consolidateManufacturingStage = _jobInputData.ConsolidateManufacturingStage; @@ -194,7 +194,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation #region Implementation of IInputDataProvider - public DataSource DataSource => throw new NotImplementedException(); + public DataSource DataSource => _dataSource; #endregion diff --git a/VECTO3GUI2020/Views/JoblistView.xaml b/VECTO3GUI2020/Views/JoblistView.xaml index 28f00fe30aa7325c436494b861430eb880705674..1498fe07bc94389bbf6ebb408054aa68a823e5fd 100644 --- a/VECTO3GUI2020/Views/JoblistView.xaml +++ b/VECTO3GUI2020/Views/JoblistView.xaml @@ -18,13 +18,13 @@ <Border BorderBrush="Transparent" BorderThickness="1"> <Grid> <StackPanel HorizontalAlignment="Stretch"> - <Button Margin="4" HorizontalAlignment="Stretch" + <Button x:Name="button" Margin="4" HorizontalAlignment="Stretch" Style="{StaticResource MultiStageButtonStyle1}" >Simulation</Button> - <Button Margin="4" HorizontalAlignment="Stretch" + <Button x:Name="button1" Margin="4" HorizontalAlignment="Stretch" Style="{StaticResource MultiStageButtonStyle1}" Command="{Binding moveJobUp}" CommandParameter="{Binding ElementName=JobDataGrid, Path=SelectedItem}">Up</Button> - <Button Margin="4" HorizontalAlignment="Stretch" + <Button x:Name="button2" Margin="4" HorizontalAlignment="Stretch" Style="{StaticResource MultiStageButtonStyle1}" Command="{Binding moveJobDown}" CommandParameter="{Binding ElementName=JobDataGrid, Path=SelectedItem}">Down</Button> @@ -33,8 +33,8 @@ </Border> <Grid Grid.Column="1"> <Border BorderBrush="{StaticResource AccentColorButton}" BorderThickness="1"> - <StackPanel VerticalAlignment="Stretch"> - <DataGrid ItemsSource="{Binding Jobs}" + <StackPanel VerticalAlignment="Stretch"> + <DataGrid ItemsSource="{Binding Jobs}" Name="JobDataGrid" HorizontalAlignment="Stretch" IsReadOnly="True" @@ -58,39 +58,39 @@ <DataGridTextColumn Header="Type" Binding="{Binding DocumentType}" Width="1*"></DataGridTextColumn> </DataGrid.Columns> <DataGrid.RowDetailsTemplate> - <DataTemplate> - <StackPanel Orientation="Vertical"> - <Label Content="Filename"/> - <TextBlock Text="{Binding DataSource.SourceFile}" TextWrapping="Wrap" Margin="10" /> - </StackPanel> - </DataTemplate> - </DataGrid.RowDetailsTemplate> - <DataGrid.InputBindings> - <MouseBinding + <DataTemplate> + <StackPanel Orientation="Vertical"> + <Label x:Name="label" Content="Filename"/> + <TextBlock x:Name="textBlock" Text="{Binding DataSource.SourceFile}" TextWrapping="Wrap" Margin="10" /> + </StackPanel> + </DataTemplate> + </DataGrid.RowDetailsTemplate> + <DataGrid.InputBindings> + <MouseBinding MouseAction="LeftDoubleClick" Command="{Binding EditJob}" CommandParameter="{Binding ElementName=JobDataGrid, Path=SelectedItem}"></MouseBinding> - </DataGrid.InputBindings> - </DataGrid> - <Label Content="Loading . . ." Visibility="{Binding IsLoading, Converter={StaticResource BooleanToVisibilityConverter}}"/> - </StackPanel> + </DataGrid.InputBindings> + </DataGrid> + <Label x:Name="label" Content="Loading . . ." Visibility="{Binding IsLoading, Converter={StaticResource BooleanToVisibilityConverter}}"/> + </StackPanel> </Border> </Grid> <Grid Grid.Column="2"> <Border BorderBrush="Transparent" BorderThickness="1"> <StackPanel > - <Button Margin="4" HorizontalAlignment="Stretch" + <Button x:Name="button3" Margin="4" HorizontalAlignment="Stretch" Style="{StaticResource MultiStageButtonStyle1}" Command="{Binding AddJob}" Background="#FFDDDDDD"> - OpenFile</Button> - <Button Margin ="4" HorizontalAlignment="Stretch" + OpenFile</Button> + <Button x:Name="button4" Margin ="4" HorizontalAlignment="Stretch" Style="{StaticResource MultiStageButtonStyle1}" Command="{Binding EditJob}" CommandParameter="{Binding ElementName=JobDataGrid, Path=SelectedItem}">EditFile</Button> - <Button Margin="4" HorizontalAlignment="Stretch" + <Button x:Name="button5" Margin="4" HorizontalAlignment="Stretch" Style="{StaticResource MultiStageButtonStyle1}" - Command="{Binding NewManufacturingStageFile}">New Multistage File</Button> - <Button Margin="4" HorizontalAlignment="Stretch" + Command="{Binding NewManufacturingStageFile}" AutomationProperties.AutomationId="JobListViewNewManufacturingStageFileButton">New Multistage File</Button> + <Button x:Name="button6" Margin="4" HorizontalAlignment="Stretch" Style="{StaticResource MultiStageButtonStyle1}" Command="{Binding RemoveJob}" CommandParameter="{Binding ElementName=JobDataGrid, Path=SelectedItem}">DeleteFile</Button> diff --git a/VECTO3GUI2020/Views/Multistage/CustomControls/FilePicker.xaml b/VECTO3GUI2020/Views/Multistage/CustomControls/FilePicker.xaml index f32becd1ec5c3a9689289e87c7d873d630ea6e76..614ebbf578717fae433d5e08887404b7c31095a6 100644 --- a/VECTO3GUI2020/Views/Multistage/CustomControls/FilePicker.xaml +++ b/VECTO3GUI2020/Views/Multistage/CustomControls/FilePicker.xaml @@ -11,15 +11,15 @@ <RowDefinition></RowDefinition> </Grid.RowDefinitions> <Grid.ColumnDefinitions> - <ColumnDefinition></ColumnDefinition> - <ColumnDefinition Width="30px"></ColumnDefinition> - </Grid.ColumnDefinitions> - <TextBox VerticalContentAlignment="Center" Padding="4" Margin = "0 0 0 0" IsReadOnly="True" + <ColumnDefinition></ColumnDefinition> + <ColumnDefinition Width="30px"></ColumnDefinition> + </Grid.ColumnDefinitions> + <TextBox x:Name="textBox" VerticalContentAlignment="Center" Padding="4" Margin = "0 0 0 0" IsReadOnly="True" Text="{Binding Text, ElementName=filepickercustomcontrol}" HorizontalAlignment="Stretch" TextWrapping="Wrap" Style="{DynamicResource TextBoxStyle1}"/> - <Button Padding="4" Margin="4 0 0 0" Grid.Column="1" ContentTemplate="{DynamicResource AddDocumentIcon}" + <Button x:Name="button" Padding="4" Margin="4 0 0 0" Grid.Column="1" ContentTemplate="{DynamicResource AddDocumentIcon}" Command="{Binding Command, ElementName=filepickercustomcontrol}" Style="{DynamicResource FilePickerButtonStyle}"> - - </Button> - </Grid> + + </Button> + </Grid> </UserControl> diff --git a/VECTO3GUI2020/Views/Multistage/CustomControls/MultiStageParameter.xaml b/VECTO3GUI2020/Views/Multistage/CustomControls/MultiStageParameter.xaml index 74315b8a97a6b6eb2224a6819740df7a1a276afb..0ad1f2bffd0f7f2965491c5078c03998069cfdfd 100644 --- a/VECTO3GUI2020/Views/Multistage/CustomControls/MultiStageParameter.xaml +++ b/VECTO3GUI2020/Views/Multistage/CustomControls/MultiStageParameter.xaml @@ -7,8 +7,8 @@ mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" Name="MultistageParameterControl"> - - + + <Grid> <!-- _____________________________________________ Text mode ___________________________________________________________________--> @@ -23,8 +23,8 @@ <ColumnDefinition Width="1*" SharedSizeGroup="N"/> </Grid.ColumnDefinitions> - <Label Content="{Binding LabelText, ElementName=MultistageParameterControl}"></Label> - <CheckBox Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Name="CheckBox" + <Label x:Name="label" Content="{Binding LabelText, ElementName=MultistageParameterControl}"></Label> + <CheckBox Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Name="CheckBox" Visibility="{Binding ShowCheckBox, ElementName=MultistageParameterControl, Converter={StaticResource BooleanToVisibilityConverter}}" @@ -32,13 +32,13 @@ ElementName=MultistageParameterControl, Mode=TwoWay}"/> - <TextBox Grid.Column="2" VerticalAlignment="Center" Margin="2 0 2 0" IsReadOnly="True" + <TextBox x:Name="textBox" Grid.Column="2" VerticalAlignment="Center" Margin="2 0 2 0" IsReadOnly="True" Text="{Binding ElementName=MultistageParameterControl, Path=PreviousContent, Converter={StaticResource SIValueToStringConverter}}" Style="{DynamicResource TextBoxStyle1}" Visibility="{Binding Optional, ElementName=MultistageParameterControl, Converter={StaticResource BooleanToVisibilityConverter}, UpdateSourceTrigger=PropertyChanged}"/> - <TextBox Grid.Column="3" Name ="TextBoxContent" VerticalAlignment="Center" Margin="2 0 2 0" + <TextBox Grid.Column="3" Name ="TextBoxContent" VerticalAlignment="Center" Margin="2 0 2 0" Text="{Binding Content, ElementName=MultistageParameterControl, Converter={StaticResource SIValueToStringConverter}, @@ -47,10 +47,10 @@ IsReadOnly="{Binding ElementName=MultistageParameterControl, Path=EditingEnabled, Converter={StaticResource InvertBoolConverter}}" MouseDoubleClick="Control_OnMouseDoubleClick"/> - <Label Grid.Column="4" x:Name="AutoUnitLabel" + <Label Grid.Column="4" x:Name="AutoUnitLabel" Content="{Binding DummyContent, ElementName=MultistageParameterControl, Converter={StaticResource SIToUnitStringConverter}}"> - </Label> - </Grid> + </Label> + </Grid> <!--_________________________________________________ComboBoxMode____________________________________________________________________--> @@ -58,15 +58,15 @@ Path=Mode, Converter={StaticResource ParameterModeToVisibilityConverter}, ConverterParameter={x:Static local:MultistageParameterViewMode.COMBOBOX}}"> <Grid.ColumnDefinitions> - <ColumnDefinition Width="4*" SharedSizeGroup="W"/> - <ColumnDefinition Width="1*" SharedSizeGroup="N"/> - <ColumnDefinition Width="4*" SharedSizeGroup="W"/> - <ColumnDefinition Width="4*" SharedSizeGroup="W"/> - <ColumnDefinition Width="1*" SharedSizeGroup="N"/> - </Grid.ColumnDefinitions> - - <Label Content="{Binding LabelText, ElementName=MultistageParameterControl}"></Label> - <CheckBox Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Name="CheckBoxCombo" + <ColumnDefinition Width="4*" SharedSizeGroup="W"/> + <ColumnDefinition Width="1*" SharedSizeGroup="N"/> + <ColumnDefinition Width="4*" SharedSizeGroup="W"/> + <ColumnDefinition Width="4*" SharedSizeGroup="W"/> + <ColumnDefinition Width="1*" SharedSizeGroup="N"/> + </Grid.ColumnDefinitions> + + <Label x:Name="label1" Content="{Binding LabelText, ElementName=MultistageParameterControl}"></Label> + <CheckBox Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Name="CheckBoxCombo" Visibility="{Binding ShowCheckBox, ElementName=MultistageParameterControl, Converter={StaticResource BooleanToVisibilityConverter}}" @@ -74,36 +74,36 @@ ElementName=MultistageParameterControl, Mode=TwoWay}"/> - <ComboBox Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="2 0 2 0" Visibility="{Binding Optional, + <ComboBox x:Name="comboBox" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="2 0 2 0" Visibility="{Binding Optional, ElementName=MultistageParameterControl, Converter={StaticResource BooleanToVisibilityConverter}}" IsHitTestVisible="False" Focusable="False" IsEditable="False" SelectedValue="{Binding PreviousContent, Mode=TwoWay, ElementName=MultistageParameterControl}" ItemsSource="{Binding ListItems, ElementName=MultistageParameterControl}"> <ComboBox.ItemTemplate> <DataTemplate> - <TextBlock Text="{Binding Converter={StaticResource EnumConverter}}" /> + <TextBlock x:Name="textBlock" Text="{Binding Converter={StaticResource EnumConverter}}" /> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> - - <ComboBox Grid.Column="3" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="2 0 2 0" + + <ComboBox x:Name="comboBox1" Grid.Column="3" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="2 0 2 0" SelectedValue="{Binding Content, Mode=TwoWay, ElementName=MultistageParameterControl, ValidatesOnExceptions=True}" ItemsSource="{Binding ListItems, ElementName=MultistageParameterControl}" IsEnabled="{Binding EditingEnabled, ElementName=MultistageParameterControl}" IsEditable="False" MouseDoubleClick="Control_OnMouseDoubleClick"> <ComboBox.ItemTemplate> <DataTemplate> - <TextBlock Text="{Binding Converter={StaticResource EnumConverter}}" /> + <TextBlock x:Name="textBlock" Text="{Binding Converter={StaticResource EnumConverter}}" /> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> - <Label Grid.Column="4" + <Label x:Name="label2" Grid.Column="4" Content="{Binding DummyContent, ElementName=MultistageParameterControl, Converter={StaticResource SIToUnitStringConverter}}"> - </Label> - </Grid> + </Label> + </Grid> <!--_________________________________________________CheckBoxMode____________________________________________________________________--> <Grid Visibility="{Binding ElementName=MultistageParameterControl, @@ -117,7 +117,7 @@ <ColumnDefinition Width="1*" SharedSizeGroup="N"/> </Grid.ColumnDefinitions> - <Label Content="{Binding LabelText, ElementName=MultistageParameterControl}"></Label> + <Label x:Name="label3" Content="{Binding LabelText, ElementName=MultistageParameterControl}"></Label> <CheckBox Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Name="CheckBoxCheckBox" Visibility="{Binding ShowCheckBox, ElementName=MultistageParameterControl, @@ -126,16 +126,16 @@ ElementName=MultistageParameterControl, Mode=TwoWay}"/> - <CheckBox Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Center" IsChecked="{Binding ElementName=MultistageParameterControl, + <CheckBox x:Name="checkBox" Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Center" IsChecked="{Binding ElementName=MultistageParameterControl, Path=PreviousContent, Converter={StaticResource XToBoolConverter}}" IsEnabled="False"> </CheckBox> - <CheckBox Grid.Column="3" VerticalAlignment="Center" HorizontalAlignment="Center" IsEnabled="{Binding ElementName=MultistageParameterControl, + <CheckBox x:Name="checkBox1" Grid.Column="3" VerticalAlignment="Center" HorizontalAlignment="Center" IsEnabled="{Binding ElementName=MultistageParameterControl, Path=EditingEnabled}"> </CheckBox> - <Label Grid.Column="4" + <Label x:Name="label4" Grid.Column="4" Content="{Binding DummyContent, ElementName=MultistageParameterControl, Converter={StaticResource SIToUnitStringConverter}}"> </Label> </Grid> diff --git a/VECTO3GUI2020/Views/Multistage/NewMultistageFileView.xaml b/VECTO3GUI2020/Views/Multistage/NewMultistageFileView.xaml index 9bcdc5a5d8877ffb5c2ef43ab285b7625169ddc8..6a6f7ee479b7cd40db1d1e7445d6a228ebb6e86c 100644 --- a/VECTO3GUI2020/Views/Multistage/NewMultistageFileView.xaml +++ b/VECTO3GUI2020/Views/Multistage/NewMultistageFileView.xaml @@ -7,12 +7,12 @@ xmlns:implementation="clr-namespace:VECTO3GUI2020.ViewModel.MultiStage.Implementation" xmlns:customControls="clr-namespace:VECTO3GUI2020.Views.Multistage.CustomControls" mc:Ignorable="d" - d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance implementation:NewMultiStageJobViewModel }"> + d:DesignHeight="450" x:Name="NewMultistageJobView" d:DesignWidth="800" d:DataContext="{d:DesignInstance implementation:NewMultiStageJobViewModel }"> <Grid> <Grid MaxWidth="900"> <DockPanel> <Grid DockPanel.Dock="Top"> - <customControls:FilePicker Grid.Row="0" Text="{Binding VifPath}" HorizontalAlignment="Stretch" Command="{Binding AddVifFile}"/> + <customControls:FilePicker x:Name="NewMultistageFilePicker" Grid.Row="0" Text="{Binding VifPath}" HorizontalAlignment="Stretch" Command="{Binding AddVifFile}"/> </Grid> <ContentControl Grid.Row="2" Content="{Binding MultiStageJobViewModel}"/> </DockPanel> diff --git a/VECTO3GUI2020/Views/Multistage/VehicleView_v2_8.xaml b/VECTO3GUI2020/Views/Multistage/VehicleView_v2_8.xaml index 0ef8b51cad002ec06d9e79a773cd64a6876499fd..1f56bc7c46da84451c83d2a5d75f126025ea3c66 100644 --- a/VECTO3GUI2020/Views/Multistage/VehicleView_v2_8.xaml +++ b/VECTO3GUI2020/Views/Multistage/VehicleView_v2_8.xaml @@ -46,7 +46,8 @@ Content="{Binding GrossVehicleMassRating}"/> - <custom:MultiStageParameter Validation.ErrorTemplate="{StaticResource multistageParameterControlErrorTemplate}" + <custom:MultiStageParameter x:Name="AirdragModified" + Validation.ErrorTemplate="{StaticResource multistageParameterControlErrorTemplate}" EditingEnabled="{Binding AirdragModifiedMultistageEditingEnabled}" PreviousContent="{Binding ConsolidatedAirdragModifiedEnum}" Content="{Binding AirdragModifiedEnum, ValidatesOnDataErrors=True}" diff --git a/Vecto3GUI2020Test/UI/DesktopSession.cs b/Vecto3GUI2020Test/UI/DesktopSession.cs new file mode 100644 index 0000000000000000000000000000000000000000..45e09d63eca3cce890187e8beccce1157f0e5e4d --- /dev/null +++ b/Vecto3GUI2020Test/UI/DesktopSession.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using OpenQA.Selenium.Appium; +using OpenQA.Selenium.Appium.Windows; +using OpenQA.Selenium.Remote; + +namespace Vecto3GUI2020Test +{ + public class DesktopSession + { + private const string WindowsApplicationDriverUrl = "http://127.0.0.1:4723/"; + WindowsDriver<WindowsElement> desktopSession; + + public DesktopSession() + { + var appCapabilities = new AppiumOptions(); + appCapabilities.AddAdditionalCapability("app", "Root"); + appCapabilities.AddAdditionalCapability("deviceName", "WindowsPC"); + desktopSession = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities); + } + + ~DesktopSession() + { + desktopSession.Quit(); + } + + public WindowsDriver<WindowsElement> DesktopSessionElement + { + get { return desktopSession; } + } + + public WindowsElement FindElementByAbsoluteXPath(string xPath, int nTryCount = 15) + { + WindowsElement uiTarget = null; + + while (nTryCount-- > 0) { + try { + uiTarget = desktopSession.FindElementByXPath(xPath); + } catch { + } + + if (uiTarget != null) { + break; + } else { + System.Threading.Thread.Sleep(200); + } + } + + return uiTarget; + } + } +} diff --git a/Vecto3GUI2020Test/UI/UITests.cs b/Vecto3GUI2020Test/UI/UITests.cs new file mode 100644 index 0000000000000000000000000000000000000000..785fadf49d36f65a0958416fea3a2743dbc3db8b --- /dev/null +++ b/Vecto3GUI2020Test/UI/UITests.cs @@ -0,0 +1,234 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using NUnit.Framework; +using OpenQA.Selenium; +using OpenQA.Selenium.Appium.Android; +using OpenQA.Selenium.Appium.Windows; +using OpenQA.Selenium.Interactions; +using Vecto3GUI2020Test.UI; + +namespace Vecto3GUI2020Test +{/// <summary> +/// The Application under Test has to run on a Windows 10 Machine on a Desktop called "VE +/// </summary> + [TestFixture] + public class UITests : VECTO3GUI2020Session + { + [SetUp] + public void Setup() + { + Setup(TestContext.CurrentContext); + } + + [Test] + public void LoadFile() + { + LoadFileThroughUIWithDesktopSession(fileName: "vecto_multistage_consolidated_multiple_stages.xml"); + } + + [Test] + public void LoadFileAirdrag() + { + LoadFileThroughUIWithDesktopSession(fileName: "vecto_multistage_consolidated_multiple_stages_airdrag.xml"); + + } + [Test] + public void LoadFileheatPump() + { + LoadFileThroughUIWithDesktopSession(fileName: "vecto_multistage_consolidated_multiple_stages_heatPump.xml"); + + } + + [Test] + public void LoadFilehev() + { + LoadFileThroughUIWithDesktopSession(fileName: "vecto_multistage_consolidated_multiple_stages_hev.xml"); + + } + + + [Test] + public void LoadFileNGTankSystem() + { + LoadFileThroughUIWithDesktopSession(fileName: "vecto_multistage_consolidated_multiple_stages_NGTankSystem.xml"); + } + + [Test] + public void LoadFileConsolidatedOneStage() + { + LoadFileThroughUIWithDesktopSession(fileName: "vecto_multistage_consolidated_one_stage.xml"); + } + + [Test] + public void LoadFileConsolidatedTwoStages() + { + LoadFileThroughUIWithDesktopSession(fileName: "vecto_multistage_consolidated_two_stages.xml"); + } + + [Test] + public void LoadFilePrimaryVehicleOnly() + { + LoadFileThroughUIWithDesktopSession(fileName: "vecto_multistage_primary_vehicle_only.xml"); + } + + [Test] + public void LoadFilePrimaryVehicleStage_2_3() + { + LoadFileThroughUIWithDesktopSession(fileName: "vecto_multistage_consolidated_one_stage.xml"); + } + + [Test] + public void LoadFilePrimaryVehicleOnlyAndCheckFields() + { + LoadFileThroughUIWithDesktopSession(fileName: "vecto_multistage_primary_vehicle_only.xml"); + //Check vehicle fields + SelectVehicleTab(); + focusToActiveWindow(); + //var element = session.FindElementByXPath() + } + + private void LoadFileThroughUIWithDesktopSession(string fileName) + { + // LeftClick on Button "New Multistage File" at (65,28) + // LeftClick on Button "New Multistage File" at (87,25) + Console.WriteLine("LeftClick on Button \"New Multistage File\" at (87,25)"); + string xpath_LeftClickButtonNewMultist_87_25 = "/Pane[@ClassName=\"#32769\"][@Name=\"Vecto\"]/Window[@ClassName=\"Window\"][@Name=\"Vecto\"]/Custom[@ClassName=\"JobListView\"]/Button[@Name=\"New Multistage File\"][@AutomationId=\"JobListViewNewManufacturingStageFileButton\"]"; + var winElem_LeftClickButtonNewMultist_87_25 = desktopSession.FindElementByAbsoluteXPath(xpath_LeftClickButtonNewMultist_87_25); + + if (winElem_LeftClickButtonNewMultist_87_25 != null) + { + winElem_LeftClickButtonNewMultist_87_25.Click(); + } + else + { + Console.WriteLine($"Failed to find element using xpath: {xpath_LeftClickButtonNewMultist_87_25}"); + } + Assert.NotNull(winElem_LeftClickButtonNewMultist_87_25); + + // LeftDblClick on Button "" at (11,11) + Console.WriteLine("LeftDblClick on Button \"\" at (11,11)"); + string xpath_LeftDblClickButton_11_11 = "/Pane[@ClassName=\"#32769\"][@Name=\"Vecto\"]/Window[@ClassName=\"Window\"][starts-with(@Name,\"VECTO3GUI2020.ViewModel.MultiStage.Implementation.NewMultiStageJ\")]/Custom[@AutomationId=\"NewMultistageJobView\"]/Custom[@AutomationId=\"NewMultistageFilePicker\"]/Button[@AutomationId=\"button\"]"; + var winElem_LeftDblClickButton_11_11 = desktopSession.FindElementByAbsoluteXPath(xpath_LeftDblClickButton_11_11); + + if (winElem_LeftDblClickButton_11_11 != null) { + desktopSession.DesktopSessionElement.Mouse.MouseMove(winElem_LeftDblClickButton_11_11.Coordinates); + desktopSession.DesktopSessionElement.Mouse.DoubleClick(null); + } + else + { + Console.WriteLine($"Failed to find element using xpath: {xpath_LeftDblClickButton_11_11}"); + + } + Assert.NotNull(winElem_LeftDblClickButton_11_11); + + // LeftDblClick on Edit "Name" at (284,8) + Console.WriteLine("LeftDblClick on Edit \"Name\" at (284,8)"); + string xpath_LeftDblClickEditName_284_8 = $"/Pane[@ClassName=\"#32769\"][@Name=\"Vecto\"]/Window[@ClassName=\"Window\"][starts-with(@Name,\"VECTO3GUI2020.ViewModel.MultiStage.Implementation.NewMultiStageJ\")]/Window[@ClassName=\"#32770\"][@Name=\"Öffnen\"]/Pane[@ClassName=\"DUIViewWndClassName\"]/Pane[@Name=\"Shellordneransicht\"][@AutomationId=\"listview\"]/List[@ClassName=\"UIItemsView\"][@Name=\"Elementansicht\"]/ListItem[@ClassName=\"UIItem\"][@Name={fileName}]/Edit[@Name=\"Name\"][@AutomationId=\"System.ItemNameDisplay\"]"; + var winElem_LeftDblClickEditName_284_8 = desktopSession.FindElementByAbsoluteXPath(xpath_LeftDblClickEditName_284_8); + if (winElem_LeftDblClickEditName_284_8 != null) + { + desktopSession.DesktopSessionElement.Mouse.MouseMove(winElem_LeftDblClickEditName_284_8.Coordinates); + desktopSession.DesktopSessionElement.Mouse.DoubleClick(null); + } + else + { + Console.WriteLine($"Failed to find element using xpath: {xpath_LeftDblClickEditName_284_8}"); + } + Assert.NotNull(winElem_LeftDblClickEditName_284_8); + + + + SelectAirdragTab(); + SelectAuxiliariesTab(); + SelectVehicleTab(); + SelectAuxiliariesTab(); + SelectAirdragTab(); + + + + + + } + + + private void SelectVehicleTab() + { + // LeftClick on Text "Vehicle" at (13,14) + Console.WriteLine("LeftClick on Text \"Vehicle\" at (13,14)"); + string xpath_LeftClickTextVehicle_13_14 = "/Pane[@ClassName=\"#32769\"][@Name=\"Vecto\"]/Window[@ClassName=\"Window\"][starts-with(@Name,\"VECTO3GUI2020.ViewModel.MultiStage.Implementation.NewMultiStageJ\")]/Custom[@AutomationId=\"NewMultistageJobView\"]/Custom[@ClassName=\"MultiStageView\"]/Custom[@ClassName=\"ManufacturingStageView\"]/Button[@ClassName=\"Button\"][@Name=\"Vehicle\"]/Text[@ClassName=\"TextBlock\"][@Name=\"Vehicle\"]"; + var winElem_LeftClickTextVehicle_13_14 = desktopSession.FindElementByAbsoluteXPath(xpath_LeftClickTextVehicle_13_14); + if (winElem_LeftClickTextVehicle_13_14 != null) + { + winElem_LeftClickTextVehicle_13_14.Click(); + } + else + { + Console.WriteLine($"Failed to find element using xpath: {xpath_LeftClickTextVehicle_13_14}"); + } + Assert.NotNull(winElem_LeftClickTextVehicle_13_14); + } + + private void SelectAirdragTab() + { + // LeftClick on Text "Airdrag" at (21,13) + Console.WriteLine("LeftClick on Text \"Airdrag\" at (21,13)"); + string xpath_LeftClickTextAirdrag_21_13 = "/Pane[@ClassName=\"#32769\"][@Name=\"Vecto\"]/Window[@ClassName=\"Window\"][starts-with(@Name,\"VECTO3GUI2020.ViewModel.MultiStage.Implementation.NewMultiStageJ\")]/Custom[@AutomationId=\"NewMultistageJobView\"]/Custom[@ClassName=\"MultiStageView\"]/Custom[@ClassName=\"ManufacturingStageView\"]/Button[@ClassName=\"Button\"][@Name=\"Airdrag\"]/Text[@ClassName=\"TextBlock\"][@Name=\"Airdrag\"]"; + var winElem_LeftClickTextAirdrag_21_13 = desktopSession.FindElementByAbsoluteXPath(xpath_LeftClickTextAirdrag_21_13); + if (winElem_LeftClickTextAirdrag_21_13 != null) + { + winElem_LeftClickTextAirdrag_21_13.Click(); + } + else + { + Console.WriteLine($"Failed to find element using xpath: {xpath_LeftClickTextAirdrag_21_13}"); + return; + } + Assert.NotNull(winElem_LeftClickTextAirdrag_21_13); + } + + private void SelectAuxiliariesTab() + { + // LeftClick on Button "Auxiliaries" at (9,13) + Console.WriteLine("LeftClick on Button \"Auxiliaries\" at (9,13)"); + string xpath_LeftClickButtonAuxiliarie_9_13 = "/Pane[@ClassName=\"#32769\"][@Name=\"Vecto\"]/Window[@ClassName=\"Window\"][starts-with(@Name,\"VECTO3GUI2020.ViewModel.MultiStage.Implementation.NewMultiStageJ\")]/Custom[@AutomationId=\"NewMultistageJobView\"]/Custom[@ClassName=\"MultiStageView\"]/Custom[@ClassName=\"ManufacturingStageView\"]/Button[@ClassName=\"Button\"][@Name=\"Auxiliaries\"]"; + var winElem_LeftClickButtonAuxiliarie_9_13 = desktopSession.FindElementByAbsoluteXPath(xpath_LeftClickButtonAuxiliarie_9_13); + if (winElem_LeftClickButtonAuxiliarie_9_13 != null) + { + winElem_LeftClickButtonAuxiliarie_9_13.Click(); + } + else + { + Console.WriteLine($"Failed to find element using xpath: {xpath_LeftClickButtonAuxiliarie_9_13}"); + } + Assert.NotNull(winElem_LeftClickButtonAuxiliarie_9_13); + + + } + + + + + + [TearDown] + public void OneTimeTeardown() + { + TearDown(); + Thread.Sleep(1000); + } + + + + private void focusToActiveWindow() + { + session.SwitchTo().ActiveElement(); + + } + + + + } +} diff --git a/Vecto3GUI2020Test/UI/VECTO3GUI2020Session.cs b/Vecto3GUI2020Test/UI/VECTO3GUI2020Session.cs new file mode 100644 index 0000000000000000000000000000000000000000..c509ef95965474be669baf8ec5a92b06f5f60ac0 --- /dev/null +++ b/Vecto3GUI2020Test/UI/VECTO3GUI2020Session.cs @@ -0,0 +1,74 @@ +using System; +using NUnit.Framework; +using OpenQA.Selenium; +using OpenQA.Selenium.Appium.Windows; + +namespace Vecto3GUI2020Test.UI +{ + [TestFixture] + public class VECTO3GUI2020Session + { + protected const string WindowsApplicationDriverUrl = "http://127.0.0.1:4723"; + private const string NotepadAppId = @"C:\Windows\System32\notepad.exe"; + + internal static WindowsDriver<WindowsElement> session; + internal static DesktopSession desktopSession; + + public WindowsDriver<WindowsElement> DesktopSessionElement + { + get { return session; } + } + + public static void Setup(TestContext context) + { + // Launch a new instance of VECTO application + if (session == null) + { + // Create a new session to launch Notepad application + var appiumOptions = new OpenQA.Selenium.Appium.AppiumOptions(); + appiumOptions.AddAdditionalCapability("app", @"C:\Users\Harry\source\repos\vecto-dev\VECTO3GUI2020\bin\Debug\VECTO3GUI2020.exe"); + appiumOptions.AddAdditionalCapability("deviceName", "WindowsPC"); + session = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), appiumOptions); + + // Use the session to control the app + Assert.IsNotNull(session); + Assert.IsNotNull(session.SessionId); + + + // Set implicit timeout to 1.5 seconds to make element search to retry every 500 ms for at most three times + session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5); + } + + desktopSession = new DesktopSession(); + } + + + public static void TearDown() + { + // Close the application and delete the session + if (session != null) + { + session.CloseApp(); + + session = null; + } + } + + public void TestInitialize() + { + // Select all text and delete to clear the edit box + } + + protected static string SanitizeBackslashes(string input) => input.Replace("\\", Keys.Alt + Keys.NumberPad9 + Keys.NumberPad2 + Keys.Alt); + + } + + public static class SessionExtensions{ + + public static void DoubleCLick(this WindowsElement element) + { + element.Click(); + element.Click(); + } + } +} diff --git a/Vecto3GUI2020Test/Vecto3GUI2020Test.csproj b/Vecto3GUI2020Test/Vecto3GUI2020Test.csproj new file mode 100644 index 0000000000000000000000000000000000000000..b0a3b15265007fa3ea97c48a0daa1dbd2428712b --- /dev/null +++ b/Vecto3GUI2020Test/Vecto3GUI2020Test.csproj @@ -0,0 +1,95 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <TargetFramework>net48</TargetFramework> + + <IsPackable>false</IsPackable> + </PropertyGroup> + + <ItemGroup> + <Content Include="..\VectoCore\VectoCoreTest\TestData\XML\XMLReaderDeclaration\SchemaVersion2.8\vecto_vehicle-exempted_input_full-sample.xml" Link="Testdata\vecto_vehicle-exempted_input_full-sample.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="..\VectoCore\VectoCoreTest\TestData\XML\XMLReaderDeclaration\SchemaVersion2.8\vecto_vehicle-exempted_input_only_certain_entries01-sample.xml" Link="Testdata\vecto_vehicle-exempted_input_only_certain_entries01-sample.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="..\VectoCore\VectoCoreTest\TestData\XML\XMLReaderDeclaration\SchemaVersion2.8\vecto_vehicle-exempted_input_only_certain_entries02-sample.xml" Link="Testdata\vecto_vehicle-exempted_input_only_certain_entries02-sample.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="..\VectoCore\VectoCoreTest\TestData\XML\XMLReaderDeclaration\SchemaVersion2.8\vecto_vehicle-exempted_input_only_mandatory_entries.xml" Link="Testdata\vecto_vehicle-exempted_input_only_mandatory_entries.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="..\VectoCore\VectoCoreTest\TestData\XML\XMLReaderDeclaration\SchemaVersion2.8\vecto_vehicle-stage_input_full-sample.xml" Link="Testdata\vecto_vehicle-stage_input_full-sample.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="..\VectoCore\VectoCoreTest\TestData\XML\XMLReaderDeclaration\SchemaVersion2.8\vecto_vehicle-stage_input_only_certain_entries01-sample.xml" Link="Testdata\vecto_vehicle-stage_input_only_certain_entries01-sample.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="..\VectoCore\VectoCoreTest\TestData\XML\XMLReaderDeclaration\SchemaVersion2.8\vecto_vehicle-stage_input_only_certain_entries02-sample.xml" Link="Testdata\vecto_vehicle-stage_input_only_certain_entries02-sample.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="..\VectoCore\VectoCoreTest\TestData\XML\XMLReaderDeclaration\SchemaVersion2.8\vecto_vehicle-stage_input_only_component_nullable_entries.xml" Link="Testdata\vecto_vehicle-stage_input_only_component_nullable_entries.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="..\VectoCore\VectoCoreTest\TestData\XML\XMLReaderDeclaration\SchemaVersion2.8\vecto_vehicle-stage_input_only_mandatory_entries.xml" Link="Testdata\vecto_vehicle-stage_input_only_mandatory_entries.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="..\VectoCore\VectoCoreTest\TestData\XML\XMLReaderDeclaration\SchemaVersion2.8\vecto_vehicle-stage_input_only_mandatory_standard_value_airdrag.xml" Link="Testdata\vecto_vehicle-stage_input_only_mandatory_standard_value_airdrag.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="..\VectoCore\VectoCoreTest\TestData\XML\XMLReaderDeclaration\SchemaVersionMultistage.0.1\AidragComponent.xml" Link="Testdata\AidragComponent.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="..\VectoCore\VectoCoreTest\TestData\XML\XMLReaderDeclaration\SchemaVersionMultistage.0.1\AirdragLoadTestFile.xml" Link="Testdata\AirdragLoadTestFile.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="..\VectoCore\VectoCoreTest\TestData\XML\XMLReaderDeclaration\SchemaVersionMultistage.0.1\vecto_multistage_consolidated_multiple_stages.xml" Link="Testdata\vecto_multistage_consolidated_multiple_stages.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="..\VectoCore\VectoCoreTest\TestData\XML\XMLReaderDeclaration\SchemaVersionMultistage.0.1\vecto_multistage_consolidated_multiple_stages_airdrag.xml" Link="Testdata\vecto_multistage_consolidated_multiple_stages_airdrag.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="..\VectoCore\VectoCoreTest\TestData\XML\XMLReaderDeclaration\SchemaVersionMultistage.0.1\vecto_multistage_consolidated_multiple_stages_heatPump.xml" Link="Testdata\vecto_multistage_consolidated_multiple_stages_heatPump.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="..\VectoCore\VectoCoreTest\TestData\XML\XMLReaderDeclaration\SchemaVersionMultistage.0.1\vecto_multistage_consolidated_multiple_stages_hev.xml" Link="Testdata\vecto_multistage_consolidated_multiple_stages_hev.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="..\VectoCore\VectoCoreTest\TestData\XML\XMLReaderDeclaration\SchemaVersionMultistage.0.1\vecto_multistage_consolidated_multiple_stages_NGTankSystem.xml" Link="Testdata\vecto_multistage_consolidated_multiple_stages_NGTankSystem.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="..\VectoCore\VectoCoreTest\TestData\XML\XMLReaderDeclaration\SchemaVersionMultistage.0.1\vecto_multistage_consolidated_one_stage.xml" Link="Testdata\vecto_multistage_consolidated_one_stage.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="..\VectoCore\VectoCoreTest\TestData\XML\XMLReaderDeclaration\SchemaVersionMultistage.0.1\vecto_multistage_consolidated_two_stages.xml" Link="Testdata\vecto_multistage_consolidated_two_stages.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="..\VectoCore\VectoCoreTest\TestData\XML\XMLReaderDeclaration\SchemaVersionMultistage.0.1\vecto_multistage_primary_vehicle_only.xml" Link="Testdata\vecto_multistage_primary_vehicle_only.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="..\VectoCore\VectoCoreTest\TestData\XML\XMLReaderDeclaration\SchemaVersionMultistage.0.1\vecto_multistage_primary_vehicle_stage_2_3.xml" Link="Testdata\vecto_multistage_primary_vehicle_stage_2_3.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="..\VectoCore\VectoCoreTest\TestData\XML\XMLReaderDeclaration\SchemaVersionMultistage.0.1\vecto_multistage_primary_vehicle_stage_2_full.xml" Link="Testdata\vecto_multistage_primary_vehicle_stage_2_full.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="..\VectoCore\VectoCoreTest\TestData\XML\XMLReaderDeclaration\SchemaVersionMultistage.0.1\vecto_multistage_primary_vehicle_stage_2_mandatory.xml" Link="Testdata\vecto_multistage_primary_vehicle_stage_2_mandatory.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + </ItemGroup> + + <ItemGroup> + <PackageReference Include="Appium.WebDriver" Version="4.3.1" /> + <PackageReference Include="Moq" Version="4.16.1" /> + <PackageReference Include="Ninject" Version="3.3.4" /> + <PackageReference Include="NUnit" Version="3.12.0" /> + <PackageReference Include="NUnit3TestAdapter" Version="3.16.1" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" /> + </ItemGroup> + + <ItemGroup> + <ProjectReference Include="..\VECTO3GUI2020\VECTO3GUI2020.csproj" /> + <ProjectReference Include="..\VectoCore\VectoCore\VectoCore.csproj" /> + </ItemGroup> + +</Project> diff --git a/Vecto3GUI2020Test/ViewModelTests.cs b/Vecto3GUI2020Test/ViewModelTests.cs new file mode 100644 index 0000000000000000000000000000000000000000..1eb98c29b0d43190e2362836f98c7eb1720a9a3e --- /dev/null +++ b/Vecto3GUI2020Test/ViewModelTests.cs @@ -0,0 +1,295 @@ +using System; +using System.IO; +using System.Runtime.CompilerServices; +using Moq; +using Ninject; +using NUnit.Framework; +using TUGraz.VectoCommon.BusAuxiliaries; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCore; +using TUGraz.VectoCore.InputData.FileIO.XML; +using TUGraz.VectoCore.Models.SimulationComponent.Strategies; +using VECTO3GUI2020.Helper; +using VECTO3GUI2020.Ninject; +using VECTO3GUI2020.Ninject.Vehicle; +using VECTO3GUI2020.ViewModel.MultiStage.Implementation; +using VECTO3GUI2020.ViewModel.MultiStage.Interfaces; + +namespace Vecto3GUI2020Test +{ + [TestFixture] + public class ViewModelTests + { + protected IXMLInputDataReader xmlInputReader; + private IKernel _kernel; + + const string DirPath = @"Testdata\"; + + private const string consolidated_multiple_stages = "vecto_multistage_consolidated_multiple_stages.xml"; + + private const string consolidated_multiple_stages_airdrag = + "vecto_multistage_consolidated_multiple_stages_airdrag.xml"; + + private const string consolidated_one_stage = "vecto_multistage_consolidated_one_stage.xml"; + private const string primary_vehicle_only = "vecto_multistage_primary_vehicle_only.xml"; + + [SetUp] + public void OneTimeSetUp() + { + _kernel = new StandardKernel( + new VectoNinjectModule(), + new JobEditModule(), + new ComponentModule(), + new DocumentModule(), + new XMLWriterFactoryModule(), + new FactoryModule(), + new MultistageModule() + ); + xmlInputReader = _kernel.Get<IXMLInputDataReader>(); + + } + + [Test] + public void loadInputFileMultipleStage() + { + loadFile(consolidated_multiple_stages); + } + + [Test] + public void loadPrimaryAndSaveVehicleData() + { + var newMultiStageJob = loadFile(primary_vehicle_only); + var vehicle = newMultiStageJob.MultiStageJobViewModel.ManufacturingStageViewModel.Vehicle as DeclarationInterimStageBusVehicleViewModel_v2_8; + vehicle.Manufacturer = "test1"; + vehicle.ManufacturerAddress = "testAddress2"; + vehicle.VIN = "VIN123456789"; + //Remove + + var manufacturingStage = + newMultiStageJob.MultiStageJobViewModel as MultiStageJobViewModel_v0_1; + + var fileName = primary_vehicle_only.Replace(".xml", "") + "_output.xml"; + + _kernel.Rebind<IDialogHelper>().ToConstant(getMockDialogHelper(fileToSave:fileName).Object); + + manufacturingStage.SaveInputDataAsCommand.Execute(null); + + + checkFileExists(fileName); + + + + } + + + + [Test] + public void loadInputFileMultipleStageAirdrag() + { + loadFile(consolidated_multiple_stages_airdrag); + } + + [Test] + public void loadInputFileConsolidatedOneStage() + { + loadFile(consolidated_one_stage); + } + + [Test] + public void loadInputFilePrimaryOnly() + { + var vm = loadFile(primary_vehicle_only); + Assert.AreEqual(1, vm.MultiStageJobViewModel.ManufacturingStageViewModel.StageCount); + + var primaryVehicle = vm.MultiStageJobViewModel.PrimaryVehicle; + Assert.NotNull(primaryVehicle); + + var vehicleViewModel = + vm.MultiStageJobViewModel.ManufacturingStageViewModel.Vehicle as IMultistageVehicleViewModel; + Assert.NotNull(vehicleViewModel); + Assert.Null(vehicleViewModel.Manufacturer); + Assert.Null(vehicleViewModel.ManufacturerAddress); + + var vehicleViewModel_v2_8 = vehicleViewModel as DeclarationInterimStageBusVehicleViewModel_v2_8; + Assert.NotNull(vehicleViewModel_v2_8); + + Assert.Null(vehicleViewModel_v2_8.HeightInMm); + Assert.Null(vehicleViewModel_v2_8.LengthInMm); + Assert.Null(vehicleViewModel_v2_8.WidthInMm); + Assert.Null(vehicleViewModel_v2_8.EntranceHeightInMm); + + Assert.Null(vehicleViewModel_v2_8.ConsolidatedHeightInMm); + Assert.Null(vehicleViewModel_v2_8.ConsolidatedLengthInMm); + Assert.Null(vehicleViewModel_v2_8.ConsolidatedWidthInMm); + Assert.Null(vehicleViewModel_v2_8.ConsolidatedEntranceHeightInMm); + + Assert.AreEqual(vehicleViewModel_v2_8.AirdragModifiedMultistageEditingEnabled, false); + + + Assert.Null(vehicleViewModel_v2_8.BusAuxiliaries); + + } + + + + + + + [Test] + public void loadVehicleDataTest() + { + string multiplestages = ""; + multiplestages = Path.GetFullPath(DirPath + "vecto_multistage_consolidated_multiple_stages.xml"); + + var dialogMockConsolidatedMultipleStage = new Mock<IDialogHelper>(); + dialogMockConsolidatedMultipleStage.Setup(dialogHelper => dialogHelper.OpenXMLFileDialog(It.IsAny<string>())).Returns(multiplestages); + dialogMockConsolidatedMultipleStage.Setup(dialogHelper => dialogHelper.OpenXMLFileDialog()).Returns(multiplestages); + _kernel.Rebind<IDialogHelper>().ToConstant(dialogMockConsolidatedMultipleStage.Object); + + + var newMultistageJobViewModel = _kernel.Get<NewMultiStageJobViewModel>(); + newMultistageJobViewModel.AddVifFile.Execute(null); + Assert.NotNull(newMultistageJobViewModel.MultiStageJobViewModel); + + var manstageVehicleViewModel = newMultistageJobViewModel.MultiStageJobViewModel.ManufacturingStageViewModel.Vehicle as IMultistageVehicleViewModel; + Assert.NotNull(manstageVehicleViewModel); + + var auxiliariesViewModel = manstageVehicleViewModel.MultistageAuxiliariesViewModel; + Assert.NotNull(auxiliariesViewModel); + + var multiStageViewModel = + newMultistageJobViewModel.MultiStageJobViewModel as + MultiStageJobViewModel_v0_1; + Assert.NotNull(multiStageViewModel); + + var vehicleInputData = Path.GetFullPath(DirPath + "vecto_vehicle-stage_input_full-sample.xml"); + Assert.IsTrue(File.Exists(vehicleInputData)); + + var vehicleInputDataFiledialogMock = new Mock<IDialogHelper>(); + vehicleInputDataFiledialogMock.Setup(dialogHelper => dialogHelper.OpenXMLFileDialog(It.IsAny<string>())).Returns(vehicleInputData); + vehicleInputDataFiledialogMock.Setup(dialogHelper => dialogHelper.OpenXMLFileDialog()).Returns(vehicleInputData); + _kernel.Rebind<IDialogHelper>().ToConstant(vehicleInputDataFiledialogMock.Object); + + multiStageViewModel.LoadVehicleDataCommand.Execute(null); + + var vehicle = multiStageViewModel.VehicleInputData as DeclarationInterimStageBusVehicleViewModel_v2_8; + Assert.NotNull(vehicle); + + Assert.AreEqual("VEH-1234567890", vehicle.Identifier); + Assert.AreEqual("Some Manufacturer", vehicle.Manufacturer); + Assert.AreEqual("Some Manufacturer Address", vehicle.ManufacturerAddress); + Assert.AreEqual("VEH-1234567890", vehicle.VIN); + Assert.AreEqual(DateTime.Today, vehicle.Date); + Assert.AreEqual("Sample Bus Model", vehicle.Model); + Assert.AreEqual(LegislativeClass.M3, vehicle.LegislativeClass); + Assert.AreEqual(500, vehicle.CurbMassChassis.Value());//CorrectedActualMass + Assert.AreEqual(3500, vehicle.GrossVehicleMassRating.Value());//TechnicalPermissibleMaximumLadenMass + Assert.AreEqual(false, vehicle.AirdragModifiedMultistage); + Assert.AreEqual(TankSystem.Compressed, vehicle.TankSystem);//NgTankSystem + Assert.AreEqual(RegistrationClass.II_III, vehicle.RegisteredClass);//ClassBus + Assert.AreEqual(0, vehicle.NumberOfPassengersLowerDeck); + Assert.AreEqual(10, vehicle.NumberOfPassengersUpperDeck); + Assert.AreEqual(VehicleCode.CB, vehicle.VehicleCode); + Assert.AreEqual(false, vehicle.LowEntry); + Assert.AreEqual(2.5, vehicle.Height.Value());//HeightIntegratedBody + Assert.AreEqual(9.5, vehicle.Length.Value()); + Assert.AreEqual(2.5, vehicle.Width.Value()); + Assert.AreEqual(2500, vehicle.HeightInMm.Value); + Assert.AreEqual(9500, vehicle.LengthInMm.Value); + Assert.AreEqual(2500, vehicle.WidthInMm.Value); + + Assert.AreEqual(2, vehicle.EntranceHeight.Value()); + Assert.AreEqual(ConsumerTechnology.Electrically, vehicle.DoorDriveTechnology); + Assert.AreEqual(VehicleDeclarationType.interim, vehicle.VehicleDeclarationType); + + + + } + + [TearDown] + public void TearDown() + { + _kernel.Dispose(); + _kernel = null; + } + + + + + #region Helper + public bool checkFileExists(string fileName) + { + var filePath = Path.GetFullPath(DirPath + fileName); + var exists = File.Exists(filePath); + if (!exists) + { + Console.WriteLine(filePath + " not existing"); + } + + Assert.IsTrue(exists); + return exists; + } + + public NewMultiStageJobViewModel loadFile(string fileName) + { + string filePath = ""; + filePath = Path.GetFullPath(DirPath + fileName); + + var dialogMock = new Mock<IDialogHelper>(); + dialogMock.Setup(dialogHelper => dialogHelper.OpenXMLFileDialog(It.IsAny<string>())).Returns(filePath); + dialogMock.Setup(dialogHelper => dialogHelper.OpenXMLFileDialog()).Returns(filePath); + + var newMultistageJobViewModel = new NewMultiStageJobViewModel(dialogMock.Object, xmlInputReader, + _kernel.Get<IMultiStageViewModelFactory>()); + newMultistageJobViewModel.AddVifFile.Execute(null); + + Assert.NotNull(newMultistageJobViewModel.MultiStageJobViewModel); + + var manstageVehicleViewModel = newMultistageJobViewModel.MultiStageJobViewModel.ManufacturingStageViewModel.Vehicle as DeclarationInterimStageBusVehicleViewModel_v2_8; + Assert.NotNull(manstageVehicleViewModel); + + var auxiliariesViewModel = manstageVehicleViewModel.MultistageAuxiliariesViewModel; + Assert.NotNull(auxiliariesViewModel); + + + + + var airdragViewModel = (manstageVehicleViewModel as DeclarationInterimStageBusVehicleViewModel_v2_8)?.MultistageAirdragViewModel; + Assert.NotNull(airdragViewModel); + + Assert.AreEqual(filePath, newMultistageJobViewModel.VifPath); + + + + return newMultistageJobViewModel; + } + + private Mock<IDialogHelper> getMockDialogHelper(string fileToLoad = null, string fileToSave = null) + { + Mock<IDialogHelper> mockDialogHelper = null; + if (fileToLoad != null) { + var filePath = Path.GetFullPath(DirPath + fileToLoad); + + Assert.NotNull(filePath); + mockDialogHelper = new Mock<IDialogHelper>(); + mockDialogHelper.Setup(dialogHelper => dialogHelper.OpenXMLFileDialog(It.IsAny<string>())).Returns(filePath); + mockDialogHelper.Setup(dialogHelper => dialogHelper.OpenXMLFileDialog()).Returns(filePath); + } + + if (fileToSave != null) { + var filePath = Path.GetFullPath(DirPath + fileToSave); + mockDialogHelper = mockDialogHelper ?? new Mock<IDialogHelper>(); + mockDialogHelper.Setup(dialogHelper => + dialogHelper.SaveToXMLDialog(It.IsAny<string>())).Returns(filePath); + mockDialogHelper.Setup(dialogHelper => + dialogHelper.SaveToXMLDialog(null)).Returns(filePath); + } + + + return mockDialogHelper; + } +#endregion + } + +} \ No newline at end of file