public bool SetSourceFile(string path) { _dataSourceFile = _importerDataPresenter.SetDataSource(path); if (_dataSourceFile == null) { return(false); } _sourceFilePresenter.SetFilePath(path); _columnMappingPresenter.ValidateMapping(); _configuration.FileName = path; return(true); }
protected override void Context() { _dataImporterSettings = new DataImporterSettings(); base.Context(); _mapper = A.Fake <IDataSetToDataRepositoryMapper>(); var cache = new Cache <string, IDataSet>(); var dataSet = new DataSet(); dataSet.AddData(new List <ParsedDataSet>() { new ParsedDataSet(new List <string>(), A.Fake <DataSheet>(), new List <UnformattedRow>(), new Dictionary <ExtendedColumn, IList <SimulationPoint> >()) }); _dataSource = A.Fake <IDataSource>(); A.CallTo(() => _dataSource.DataSets).Returns(cache); cache.Add("sheet1", dataSet); var dataRepository = new DataRepository { Name = "name" }; dataRepository.ExtendedProperties.Add(new ExtendedProperty <string>() { Name = "Molecule", Value = "Molecule1" }); dataRepository.ExtendedProperties.Add(new ExtendedProperty <string>() { Name = "Mol weight", Value = 22.0.ToString() }); var dataColumn = new BaseGrid("Time", A.Fake <IDimension>()); var dataInfo = new DataInfo(ColumnOrigins.Undefined); dataColumn.DataInfo = dataInfo; dataRepository.Add(dataColumn); var moleculeDataColumn = new DataColumn("Measurement", A.Fake <IDimension>(), dataColumn); dataColumn.DataInfo = dataInfo; dataRepository.Add(moleculeDataColumn); A.CallTo(() => _mapper.ConvertImportDataSet(A <ImportedDataSet> .Ignored)).Returns(new DataSetToDataRepositoryMappingResult(dataRepository)); var moleculeMetaDataCategory = createMetaDataCategory <string>("Molecule", isMandatory: true); moleculeMetaDataCategory.IsListOfValuesFixed = true; moleculeMetaDataCategory.DefaultValue = "Molecule1"; moleculeMetaDataCategory.ListOfValues.Add("Molecule1", 6.0.ToString()); moleculeMetaDataCategory.ShouldListOfValuesBeIncluded = true; moleculeMetaDataCategory.SelectDefaultValue = true; _metaDataCategories = new List <MetaDataCategory>() { moleculeMetaDataCategory, createMetaDataCategory <string>("Mol weight", isMandatory: false) }; var dataFormat = A.Fake <IDataFormat>(); A.CallTo(() => dataFormat.Parameters).Returns(new List <DataFormatParameter>()); _dataSourceFile = A.Fake <IDataSourceFile>(); A.CallTo(() => _dataSourceFile.Format).Returns(dataFormat); _importerDataPresenter = A.Fake <IImporterDataPresenter>(); A.CallTo(() => _importerDataPresenter.SetDataSource(A <string> .Ignored)).Returns(_dataSourceFile); _importerView = A.Fake <IImporterView>(); _importer = A.Fake <IImporter>(); _nanPresenter = A.Fake <INanPresenter>(); _importConfirmationPresenter = A.Fake <IImportConfirmationPresenter>(); _columnMappingPresenter = A.Fake <IColumnMappingPresenter>(); _sourceFilePresenter = A.Fake <ISourceFilePresenter>(); _dialogCreator = A.Fake <IDialogCreator>(); _pkmlPeristor = A.Fake <IPKMLPersistor>(); sut = new ImporterPresenterForTest( _importerView, _mapper, _importer, _nanPresenter, _importerDataPresenter, _importConfirmationPresenter, _columnMappingPresenter, _sourceFilePresenter, _dialogCreator, _pkmlPeristor, _dataSource); _importerConfiguration = A.Fake <ImporterConfiguration>(); sut.LoadConfiguration(_importerConfiguration, ""); sut.SetSettings(_metaDataCategories, new ColumnInfoCache(), _dataImporterSettings); }