public async Task TestSetExecutorAsync() { // arrange var pathToLibrary = TestData.SimLibraryDirectory.FullName; var simLibrary = new SimLibrary(); simLibrary.LoadFrom(pathToLibrary); var pathToCode = Path.Combine(pathToLibrary, "InspectExec", "inspect.R"); // act using var managedImport = new ManagedImport(pathToCode, simLibrary); using var server = new RVisServer(); var client = await server.OpenChannelAsync(); managedImport.InspectAsync(client).Wait(); managedImport.SetExecutorAsync(managedImport.UnaryFunctions[0], managedImport.ScalarSets[0], client).Wait(); // assert Assert.AreEqual(managedImport.ExecutorOutput?.NColumns, 3); Assert.AreEqual(managedImport.ExecutorParameterCandidates.Count, 2); Assert.AreEqual(managedImport.ExecutorValueCandidates.Count, 2); Assert.AreEqual(managedImport.ScalarSets.Count, 1); Assert.AreEqual(managedImport.UnaryFunctions.Count, 1); Assert.AreEqual(managedImport.ValueCandidates.Count, 1); }
public ImportTmplViewModel(ManagedImport managedImport, string fileName, IAppService appService) { _managedImport = managedImport; _appService = appService; FileName = fileName; var changeParameterDescriptionUnit = ReactiveCommand.Create <IParameterCandidateViewModel>(HandleChangeParameterDescriptionUnit); ParameterCandidates = managedImport.ParameterCandidates.Map <IParameterCandidateViewModel>(pc => new ParameterCandidateViewModel( pc.IsUsed, pc.Name, pc.Value, pc.Unit, pc.Description, changeParameterDescriptionUnit ) ); UseAllParameters = ReactiveCommand.Create(HandleUseAllParameters); UseNoParameters = ReactiveCommand.Create(HandleUseNoParameters); SetIndependentVariable = ReactiveCommand.Create( HandleSetIndependentVariable, this.ObservableForProperty(vm => vm.SelectedElementCandidate, sec => sec != default) ); var changeElementDescriptionUnit = ReactiveCommand.Create <IElementCandidateViewModel>(HandleChangeElementDescriptionUnit); _elementCandidates = managedImport.ValueCandidates .Bind(vc => vc.ElementCandidates.Map <IElementCandidateViewModel>(ec => new ElementCandidateViewModel( ec.IsUsed, ec.Name, vc.Name, false, ec.Values, ec.Unit, ec.Description, changeElementDescriptionUnit ) ) ); ElementCandidates = new ObservableCollection <IElementCandidateViewModel>(_elementCandidates); UseAllOutputs = ReactiveCommand.Create(HandleUseAllOutputs); UseNoOutputs = ReactiveCommand.Create(HandleUseNoOutputs); _simulationName = managedImport.SimulationName; _simulationDescription = managedImport.SimulationDescription; OK = ReactiveCommand.Create(HandleOK); Cancel = ReactiveCommand.Create(() => DialogResult = false); }
public async Task TestInspectAsync() { // arrange var pathToLibrary = TestData.SimLibraryDirectory.FullName; var simLibrary = new SimLibrary(); simLibrary.LoadFrom(pathToLibrary); var pathToCode = Path.Combine(pathToLibrary, "InspectTmpl", "inspect.R"); // act using var managedImport = new ManagedImport(pathToCode, simLibrary); using var server = new RVisServer(); var client = await server.OpenChannelAsync(); managedImport.InspectAsync(client).Wait(); // assert Assert.AreEqual(managedImport.Scalars.Count, 2); Assert.AreEqual(managedImport.ParameterCandidates.Count, 2); Assert.AreEqual(managedImport.DataSets.Count, 3); Assert.AreEqual(managedImport.ValueCandidates.Count, 3); Assert.AreEqual(managedImport.ValueCandidates.Single(vc => vc.Name == "o").ElementCandidates.Count, 3); }
public ImportExecViewModel(ManagedImport managedImport, IAppService appService) { RequireNotNull(managedImport.ExecutorFunction); RequireNotNull(managedImport.ExecutorFormal); RequireNotNull(managedImport.ExecutorIndependentVariable); _managedImport = managedImport; _appService = appService; ExecInvocation = $"output <- {managedImport.ExecutorFunction.Symbol}({managedImport.ExecutorFormal.Symbol})"; var changeParameterDescriptionUnit = ReactiveCommand.Create <IParameterCandidateViewModel>(HandleChangeParameterDescriptionUnit); ParameterCandidates = managedImport.ExecutorParameterCandidates.Map <IParameterCandidateViewModel>(pc => new ParameterCandidateViewModel( pc.IsUsed, pc.Name, pc.Value, pc.Unit, pc.Description, changeParameterDescriptionUnit ) ); UseAllParameters = ReactiveCommand.Create(HandleUseAllParameters); UseNoParameters = ReactiveCommand.Create(HandleUseNoParameters); var changeElementDescriptionUnit = ReactiveCommand.Create <IElementCandidateViewModel>(HandleChangeElementDescriptionUnit); var ivValueCandidate = managedImport.ExecutorIndependentVariable; var ivElementCandidate = ivValueCandidate.ElementCandidates[0]; IndependentVariable = new ElementCandidateViewModel( ivElementCandidate.IsUsed, ivElementCandidate.Name, ivValueCandidate.Name, true, ivElementCandidate.Values, ivElementCandidate.Unit, ivElementCandidate.Description, changeElementDescriptionUnit ); ElementCandidates = managedImport.ExecutorValueCandidates .Bind(vc => vc.ElementCandidates.Map(ec => new ElementCandidateViewModel( ec.IsUsed, ec.Name, vc.Name, false, ec.Values, ec.Unit, ec.Description, changeElementDescriptionUnit ) ) ) .ToArr <IElementCandidateViewModel>(); UseAllOutputs = ReactiveCommand.Create(HandleUseAllOutputs); UseNoOutputs = ReactiveCommand.Create(HandleUseNoOutputs); _simulationName = managedImport.SimulationName; _simulationDescription = managedImport.SimulationDescription; OK = ReactiveCommand.Create(HandleOK); Cancel = ReactiveCommand.Create(() => DialogResult = false); }