public void verify_ExecuteFluenceSolverCommand_returns_correct_values() { // WindowViewModel needs to be instantiated for default constructor var windowViewModel = new WindowViewModel(); var viewModel = windowViewModel.FluenceSolverVM; viewModel.ForwardSolverTypeOptionVM.SelectedValue = ForwardSolverType.PointSourceSDA; viewModel.FluenceSolutionDomainTypeOptionVM.SelectedValue = FluenceSolutionDomainType.FluenceOfRhoAndZ; var result = viewModel.GetMapData(); result.Wait(); // ExecuteForwardSolver default settings PlotViewModel plotViewModel = windowViewModel.PlotVM; Assert.AreEqual(plotViewModel.Labels.Count, 0); Assert.AreEqual(plotViewModel.Title, null); TextOutputViewModel textOutputViewModel = windowViewModel.TextOutputVM; double d1 = 0.01; int i1 = 1; double g = 0.8; double n = 1.4; var s1 = StringLookup.GetLocalizedString("Label_FluenceSolver") + StringLookup.GetLocalizedString("Label_MuA") + "=" + d1.ToString(CultureInfo.CurrentCulture) + " " + StringLookup.GetLocalizedString("Label_MuSPrime") + "=" + i1.ToString(CultureInfo.CurrentCulture) + " g=" + g.ToString(CultureInfo.CurrentCulture) + " n=" + n.ToString(CultureInfo.CurrentCulture) + "; " + StringLookup.GetLocalizedString("Label_Units") + " = 1/mm\r"; Assert.AreEqual(textOutputViewModel.Text, s1); }
void TextOutputView_Loaded(object sender, RoutedEventArgs e) { _textOutputVM = this.DataContext as TextOutputViewModel; if (_textOutputVM != null) { _textOutputVM.PropertyChanged += textOutputVM_PropertyChanged; } }
public void verify_PlotMusSpectrumCommand_returns_correct_values() { viewModel.PlotMuspSpectrumCommand.Execute(null); Assert.AreEqual(windowViewModel.PlotVM.Labels[0], "μs' spectra"); Assert.AreEqual(windowViewModel.PlotVM.Title, "μs' [mm-1] versus λ [nm]"); TextOutputViewModel textOutputViewModel = windowViewModel.TextOutputVM; Assert.AreEqual(textOutputViewModel.Text, "Plot View: plot cleared due to independent axis variable change\rPlotted μs' spectrum; wavelength range [nm]: [650, 1000]\r"); }
public void verify_ExecuteForwardSolverCommand_returns_correct_values() { // WindowViewModel needs to be instantiated for default constructor var windowViewModel = new WindowViewModel(); var viewModel = windowViewModel.ForwardSolverVM; viewModel.ForwardSolverTypeOptionVM.SelectedValue = ForwardSolverType.PointSourceSDA; viewModel.SolutionDomainTypeOptionVM.SelectedValue = SolutionDomainType.ROfRho; viewModel.ExecuteForwardSolverCommand.Execute(null); // ExecuteForwardSolver default settings PlotViewModel plotViewModel = windowViewModel.PlotVM; double d1 = 0.01; int i1 = 1; double g = 0.8; double n = 1.4; double d2 = 0.0100; double d3 = 1.0000; var s1 = StringLookup.GetLocalizedString("Label_ForwardSolver") + StringLookup.GetLocalizedString("Label_MuA") + "=" + d1.ToString(CultureInfo.CurrentCulture) + " " + StringLookup.GetLocalizedString("Label_MuSPrime") + "=" + i1.ToString(CultureInfo.CurrentCulture) + " g=" + g.ToString(CultureInfo.CurrentCulture) + " n=" + n.ToString(CultureInfo.CurrentCulture) + "; " + StringLookup.GetLocalizedString("Label_Units") + " = 1/mm\r"; var s2 = StringLookup.GetLocalizedString("Label_ROfRho") + " [mm-2] " + StringLookup.GetLocalizedString("Label_Versus") + " ρ [mm]"; var s3 = "\r" + StringLookup.GetLocalizedString("Label_ModelSDA") + "\r" + StringLookup.GetLocalizedString("Label_MuA") + "=" + d2.ToString("N4", CultureInfo.CurrentCulture) + " \r" + StringLookup.GetLocalizedString("Label_MuSPrime") + "=" + d3.ToString("N4", CultureInfo.CurrentCulture); Assert.AreEqual(plotViewModel.Labels[0], s3); Assert.AreEqual(plotViewModel.Title, s2); TextOutputViewModel textOutputViewModel = windowViewModel.TextOutputVM; Assert.AreEqual(textOutputViewModel.Text, s1); }
public void verify_default_constructor_relay_command_correctly() { var textOutputVM = new TextOutputViewModel(); Assert.IsTrue(textOutputVM.TextOutput_PostMessage != null); }
public void verify_SimulateMeasuredCommand_returns_correct_values() { // WindowViewModel needs to be instantiated for default constructor var windowViewModel = new WindowViewModel(); var viewModel = windowViewModel.InverseSolverVM; viewModel.MeasuredForwardSolverTypeOptionVM.SelectedValue = ForwardSolverType.Nurbs; viewModel.InverseForwardSolverTypeOptionVM.SelectedValue = ForwardSolverType.PointSourceSDA; viewModel.SolutionDomainTypeOptionVM.SelectedValue = SolutionDomainType.ROfRho; viewModel.AllRangeVMs[0].Start = 1.0; viewModel.AllRangeVMs[0].Stop = 10.0; viewModel.AllRangeVMs[0].Number = 10; //viewModel.AllRangeVMs<IndependentVariableAxis>. viewModel.PercentNoise = 0; // SimulateMeasuredDataCommand viewModel.SimulateMeasuredDataCommand.Execute(null); PlotViewModel plotViewModel = windowViewModel.PlotVM; double d1 = 0.01; int i1 = 1; double g = 0.8; double n = 1.4; double d2 = 0.0100; double d3 = 1.0000; double d4 = 0.0129; double d5 = 0.9255; double muaError = 28.9; double muspError = 7.45; var op1 = StringLookup.GetLocalizedString("Label_MuA") + "=" + d1.ToString(CultureInfo.CurrentCulture) + " " + StringLookup.GetLocalizedString("Label_MuSPrime") + "=" + i1.ToString(CultureInfo.CurrentCulture) + " g=" + g.ToString(CultureInfo.CurrentCulture) + " n=" + n.ToString(CultureInfo.CurrentCulture) + "; " + StringLookup.GetLocalizedString("Label_Units") + " = 1/mm \r"; var op2 = StringLookup.GetLocalizedString("Label_MuA") + "=" + d4.ToString(CultureInfo.CurrentCulture) + " " + StringLookup.GetLocalizedString("Label_MuSPrime") + "=" + d5.ToString(CultureInfo.CurrentCulture) + " g=" + g.ToString(CultureInfo.CurrentCulture) + " n=" + n.ToString(CultureInfo.CurrentCulture) + "; " + StringLookup.GetLocalizedString("Label_Units") + " = 1/mm \r"; var s2 = StringLookup.GetLocalizedString("Label_ROfRho") + " [mm-2] " + StringLookup.GetLocalizedString("Label_Versus") + " ρ [mm]"; var s3 = "\n" + StringLookup.GetLocalizedString("Label_Simulated") + "\r" + StringLookup.GetLocalizedString("Label_ModelNurbs") + "\r" + StringLookup.GetLocalizedString("Label_MuA") + "=" + d2.ToString("N4", CultureInfo.CurrentCulture) + " \r" + StringLookup.GetLocalizedString("Label_MuSPrime") + "=" + d3.ToString("N4", CultureInfo.CurrentCulture); var s4 = "\n" + StringLookup.GetLocalizedString("Label_Guess") + "\r" + StringLookup.GetLocalizedString("Label_ModelSDA") + "\r" + StringLookup.GetLocalizedString("Label_MuA") + "=" + d2.ToString("N4", CultureInfo.CurrentCulture) + " \r" + StringLookup.GetLocalizedString("Label_MuSPrime") + "=" + d3.ToString("N4", CultureInfo.CurrentCulture); var s5 = "\n" + StringLookup.GetLocalizedString("Label_Calculated") + "\r" + StringLookup.GetLocalizedString("Label_ModelNurbs") + "\r" + StringLookup.GetLocalizedString("Label_MuA") + "=" + d4.ToString("N4", CultureInfo.CurrentCulture) + " \r" + StringLookup.GetLocalizedString("Label_MuSPrime") + "=" + d5.ToString("N4", CultureInfo.CurrentCulture); var s6 = StringLookup.GetLocalizedString("Label_SimulatedMeasuredData") + op1; var s7 = StringLookup.GetLocalizedString("Label_InitialGuess") + op1; var s8 = StringLookup.GetLocalizedString("Label_InverseSolutionResults") + "\r " + StringLookup.GetLocalizedString("Label_OptimizationParameter") + "MuaMusp \r " + s7 + " " + StringLookup.GetLocalizedString("Label_Exact") + ": " + op1 + " " + StringLookup.GetLocalizedString("Label_ConvergedValues") + ": " + op2 + " " + StringLookup.GetLocalizedString("Label_PercentError") + StringLookup.GetLocalizedString("Label_MuA") + " = " + muaError.ToString(CultureInfo.CurrentCulture) + "% " + StringLookup.GetLocalizedString("Label_MuSPrime") + " = " + muspError.ToString(CultureInfo.CurrentCulture) + "% \r"; Assert.AreEqual(plotViewModel.Labels[0], s3); Assert.AreEqual(plotViewModel.Title, s2); TextOutputViewModel textOutputViewModel = windowViewModel.TextOutputVM; Assert.AreEqual(textOutputViewModel.Text, s6); // CalculateInitialGuessCommand viewModel.CalculateInitialGuessCommand.Execute(null); Assert.AreEqual(plotViewModel.Labels[1], s4); Assert.AreEqual(textOutputViewModel.Text, s6 + s7); // SolveInverseCommand viewModel.SolveInverseCommand.Execute(null); Assert.AreEqual(plotViewModel.Labels[2], s5); Assert.AreEqual(textOutputViewModel.Text, s6 + s7 + s8); }