Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit e6e9f43b authored by Harald Martini's avatar Harald Martini
Browse files

Airdrag modified is set to true when component is loaded,

Airdrag modified is set to false when component is removed,
Airdrag component is removed when airdrag modified is set to false
parent 7325f76f
Branches
Tags
No related merge requests found
......@@ -218,3 +218,4 @@ Documentation/VehiclesReleaseComparisonDeclarationMode/tmp/
/VectoCore/VectoCoreTest/TestData/XML/XMLReaderDeclaration/test.VIF_Report_5.xml
/VectoCore/VectoCoreTest/TestData/XML/XMLReaderDeclaration/tests.xml
/VectoCore/VectoCoreTest/TestData/XML/XMLReaderDeclaration/finalGroup41.VIF_Report_4.xml
/VectoCore/VectoCoreTest/TestData/XML/XMLReaderDeclaration/output
......@@ -77,10 +77,12 @@ namespace VECTO3GUI2020.Helper
Action<MultistageParameterViewModel> propertyChangedCallback = null,
params ResourceManager[] resourceManagers)
{
_propertyName = propertyName;
PreviousContent = previousContent;
_propertyChangedCallback = propertyChangedCallback;
_parentViewModel = parentViewModel;
//_parentViewModel.PropertyChanged += ParentViewModelPropertyChanged;
_propertyInfo = parentViewModel.GetType().GetProperty(propertyName);
_viewMode = viewMode;
......@@ -110,6 +112,20 @@ namespace VECTO3GUI2020.Helper
CurrentContent = _propertyInfo.GetValue(parentViewModel);
}
private void ParentViewModelPropertyChanged(object sender, PropertyChangedEventArgs e)
{
Debug.Assert((IViewModelBase)sender == _parentViewModel);
if (e.PropertyName != _propertyName) {
return;
}
var valueFromParent = _propertyInfo.GetValue(sender);
if (valueFromParent != CurrentContent) {
CurrentContent = valueFromParent;
}
}
private object CreateDummyContent()
{
var type = _type;
......@@ -278,6 +294,7 @@ namespace VECTO3GUI2020.Helper
_propertyInfo.SetValue(_parentViewModel, _currentContent);
_propertyChangedCallback?.Invoke(this);
};
OnPropertyChanged(nameof(CurrentContent));
}
}
......
namespace VECTO3GUI2020.ViewModel.Interfaces.Common
using System.ComponentModel;
namespace VECTO3GUI2020.ViewModel.Interfaces.Common
{
public interface IViewModelBase
public interface IViewModelBase : INotifyPropertyChanged
{
string Title { get; set; }
}
......
......@@ -614,11 +614,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation
{
get
{
if (AirdragModifiedMultistageEditingEnabled) {
return _airdragModifiedMultistage.toAirdragModifiedEnum();
} else {
return null;
}
}
set
{
......@@ -626,13 +622,13 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation
var newVal = value?.toNullableBool();
if (prevVal != newVal) {
AirdragModifiedMultistage = value?.toNullableBool();
}
if (_parameterViewModels.ContainsKey(nameof(AirdragModifiedEnum)))
{
_parameterViewModels[nameof(AirdragModifiedEnum)].CurrentContent = value;
}
}
}
}
public AIRDRAGMODIFIED? ConsolidatedAirdragModifiedEnum
{
......@@ -654,6 +650,9 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation
set
{
if (SetProperty(ref _airdragModifiedMultistage, value)) {
if(value == false){
MultistageAirdragViewModel.AirDragViewModel = null;
}
AirdragModifiedEnum = value.toAirdragModifiedEnum();
};
}
......
......@@ -120,7 +120,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation
}
internal bool LoadAirdragFile(string fileName)
public bool LoadAirdragFile(string fileName)
{
var success = true;
var errorStringBuilder = new StringBuilder();
......
......@@ -10,5 +10,6 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Interfaces
IAirDragViewModel AirDragViewModel { get; set; }
void SetAirdragInputData(IAirdragDeclarationInputData airdragInputData);
bool LoadAirdragFile(string fileName);
}
}
\ No newline at end of file
......@@ -211,11 +211,12 @@ namespace Vecto3GUI2020Test
Assert.IsNull(vehicleViewModel_v2_8.AirdragModifiedMultistage);
Assert.IsNull(vehicleViewModel_v2_8.ConsolidatedAirdragModifiedEnum);
Assert.IsNull(vehicleViewModel_v2_8.AirdragModifiedEnum);
Assert.IsTrue(vehicleViewModel_v2_8.AirdragModifiedEnum == AIRDRAGMODIFIED.UNKNOWN || vehicleViewModel_v2_8.AirdragModifiedEnum == null);
Assert.AreEqual(vehicleViewModel_v2_8.AirdragModifiedMultistageEditingEnabled, false);
Assert.Null(vehicleViewModel_v2_8.BusAuxiliaries);
......@@ -294,6 +295,8 @@ namespace Vecto3GUI2020Test
Assert.AreEqual(500, vehicleViewModel.CurbMassChassis.Value());//CorrectedActualMass
Assert.AreEqual(3500, vehicleViewModel.GrossVehicleMassRating.Value());//TechnicalPermissibleMaximumLadenMass
Assert.AreEqual(false, vehicleViewModel.AirdragModifiedMultistage);
Assert.AreEqual(AIRDRAGMODIFIED.FALSE, vehicleViewModel.AirdragModifiedEnum);
Assert.AreEqual(AIRDRAGMODIFIED.FALSE, vehicleViewModel.ParameterViewModels[nameof(vehicleViewModel.AirdragModifiedEnum)].CurrentContent);
Assert.AreEqual(TankSystem.Compressed, vehicleViewModel.TankSystem);//NgTankSystem
Assert.AreEqual(RegistrationClass.II_III, vehicleViewModel.RegisteredClass);//ClassBus
Assert.AreEqual(1, vehicleViewModel.NumberPassengerSeatsLowerDeck);
......
......@@ -57,11 +57,11 @@ namespace Vecto3GUI2020Test.ViewModelTests
Assert.IsTrue(auxVm.HeatPumpGroupEditingEnabled);
auxVm.HeatPumpGroupEditingEnabled = false;
auxVm.ParameterViewModels[nameof(auxVm.HeatPumpModeDriverCompartment)].CurrentContent =
auxVm.ParameterViewModels[nameof(auxVm.HeatPumpTypeDriverCompartment)].CurrentContent =
HeatPumpType.R_744;
Assert.IsTrue(auxVm.HeatPumpGroupEditingEnabled);
auxVm.ParameterViewModels[nameof(auxVm.HeatPumpModeDriverCompartment)].CurrentContent =
auxVm.ParameterViewModels[nameof(auxVm.HeatPumpTypeDriverCompartment)].CurrentContent =
HeatPumpType.none;
......
......@@ -8,6 +8,7 @@ using NUnit.Framework;
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCommon.Utils;
using VECTO3GUI2020.Annotations;
using VECTO3GUI2020.ViewModel.Implementation.JobEdit.Vehicle.Components;
using VECTO3GUI2020.ViewModel.MultiStage.Implementation;
namespace Vecto3GUI2020Test.ViewModelTests
......@@ -71,6 +72,8 @@ namespace Vecto3GUI2020Test.ViewModelTests
vehicleVM.AirdragModifiedMultistageEditingEnabled = true;
Assert.IsFalse(vehicleVM.AirdragModifiedMultistageEditingEnabled);
Assert.IsNull(vehicleVM.AirdragModifiedMultistage);
//Set Mandatory Fields
vehicleVM.Manufacturer = "testManufacturer";
vehicleVM.ManufacturerAddress = "Address";
......@@ -95,7 +98,6 @@ namespace Vecto3GUI2020Test.ViewModelTests
//try to disable AirdragModified
secondStageVehicleVM.AirdragModifiedMultistageEditingEnabled = false;
Assert.IsTrue(secondStageVehicleVM.AirdragModifiedMultistageEditingEnabled);
}
/// <summary>
/// no airdrag component set in VIF => AirdragModifiedMultistage is disabled
......@@ -139,6 +141,42 @@ namespace Vecto3GUI2020Test.ViewModelTests
}
[Test]
public void airdragModifiedSetToTrueWhenComponentIsLoaded()
{
var vm = loadFile(consolidated_multiple_stages_airdrag);
var vehicleViewModel = vm.MultiStageJobViewModel.ManufacturingStageViewModel.VehicleViewModel as DeclarationInterimStageBusVehicleViewModel_v2_8;
Assert.IsNull(vehicleViewModel.AirdragModifiedMultistage);
//Load airdrag file
var airdragLoaded = vehicleViewModel.MultistageAirdragViewModel.LoadAirdragFile(GetFullPath(airdragComponent));
Assert.IsTrue(airdragLoaded, "Airdrag file was not loaded");
//Airdrag modified set to true if a component is loaded and the field is mandatory
Assert.IsTrue(vehicleViewModel.AirdragModifiedMultistage);
Assert.IsTrue(vehicleViewModel.AirdragModifiedMultistageMandatory);
Assert.AreEqual(
AIRDRAGMODIFIED.TRUE,
vehicleViewModel.ParameterViewModels[nameof(vehicleViewModel.AirdragModifiedEnum)].CurrentContent);
//Airdrag modified set to false if the component is removed
vehicleViewModel.MultistageAirdragViewModel.AirDragViewModel = null;
Assert.IsFalse(vehicleViewModel.AirdragModifiedMultistage);
//AirdragComponent is removed when airdragmodified is set to false;
//Load airdrag file
airdragLoaded = vehicleViewModel.MultistageAirdragViewModel.LoadAirdragFile(GetFullPath(airdragComponent));
Assert.IsTrue(airdragLoaded, "Airdrag file was not loaded");
vehicleViewModel.AirdragModifiedMultistage = false;
Assert.IsNull(vehicleViewModel.MultistageAirdragViewModel.AirDragViewModel);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment