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
Select Git revision
  • 114a8212e8df0ffcf4c5f76b3f54610476403eff
  • amdm2/main default
  • doc-fixes
  • amdm3/develop
  • vehmetrics
  • feature/generic_vehicles_tests
  • trailer-stable
  • trailer
  • pubcode
  • bugfix/CodeEU-547_MaxICEOffTimespan
  • ci
  • stable protected
  • bugfix/CodeEU-235_Tyre_XML-type_VIF
  • revert-f849ae0c
  • Project_VECTO_FD_II/FMI/AMTShiftStratgy
  • Project_VECTO_FD_II/FMI/HybridController
  • feature/CodeEU-51_Extend-ADC-lossmap-declaration-mode
  • tug-dev
  • develop
  • hm_feature/vecto-40-add-nuget
  • tug-stable
  • Release/v4.1.0.3392-RC
  • Release/v4.0.3.3330
  • Release/v4.0.2.3275
  • Release/v4.0.2.3273
  • Release/v0.11.1.3228-DEV
  • Project_VECTO_FD_II/FMI/HybridController
  • Project_VECTO_FD_II/FMI/AMTShiftStrategy
  • Release/v4.0.1.3217
  • Release/v4.0.0.3211
  • Release/v0.11.0.3193-DEV
  • Release/v4.0.0.3161-RC
  • Release/v4.0.0.3106-RC
  • Release/v3.3.15.3102
  • Release/v4.0.0.3078-RC
  • Release/v3.3.15.3073-RC
  • test-tag
  • Release/v3.3.14.3011
  • Build/v0.7.10.2996
  • v0.7.5b0+2524.multistep
  • Release/v3.3.14.2981-RC
41 results

ViewModelTestBase.cs

Blame
  • Forked from VECTO / VECTO Sim
    5424 commits behind the upstream repository.
    Harald MARTINI's avatar
    Harald Martini authored
    Save file only if its valid in MultistageJobViewModel_v0_1
    
    MultistageAirdragView
    
    Added Ignore Attributes to UI Tests that are using WinappDriver desktop session.
    
    Added VIF Testclass
    114a8212
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    ViewModelTestBase.cs 4.00 KiB
    using System;
    using System.IO;
    using Moq;
    using Ninject;
    using NUnit.Framework;
    using TUGraz.VectoCore;
    using TUGraz.VectoCore.InputData.FileIO.XML;
    using VECTO3GUI2020.Helper;
    using VECTO3GUI2020.Ninject;
    using VECTO3GUI2020.Ninject.Vehicle;
    using VECTO3GUI2020.ViewModel.MultiStage.Implementation;
    using VECTO3GUI2020.ViewModel.MultiStage.Interfaces;
    
    namespace Vecto3GUI2020Test
    {
    	public class ViewModelTestBase
    	{
    		protected const string DirPath = @"Testdata\";
    		protected const string consolidated_multiple_stages = "vecto_multistage_consolidated_multiple_stages.xml";
    
    		protected const string consolidated_multiple_stages_airdrag =
    			"vecto_multistage_consolidated_multiple_stages_airdrag.xml";
    
    		protected const string consolidated_one_stage = "vecto_multistage_consolidated_one_stage.xml";
    		protected const string primary_vehicle_only = "vecto_multistage_primary_vehicle_only.xml";
    
    		protected IXMLInputDataReader xmlInputReader;
    		protected IKernel _kernel;
    
    		[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>();
    			
    		}
    
    		[TearDown]
    		public void TearDown()
    		{
    			_kernel.Dispose();
    			_kernel = null;
    		}
    
    		public bool checkFileExists(string fileName)
    		{
    			var filePath = Path.GetFullPath(DirPath + fileName);
    			var exists = File.Exists(filePath);
    			if (exists)
    			{
    				Console.WriteLine(filePath + @" exists");
    			} else {
    				Console.WriteLine(filePath + @" not existing");
    			}
    
    			return exists;
    		}
    
    		public void deleteFile(string fileName)
    		{
    			var filePath = Path.GetFullPath(DirPath + fileName);
    			File.Delete(fileName);
    		}
    
    		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;
    		}
    
    		protected 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;
    		}
    	}
    }