public void TestGetMapsShouldReturnMaps() { _source.SetMaps(_maps); var result = _handler.Execute(new GetCsvFileSourceMapsQuery()); Assert.That(result, Contains.Item(_map)); }
public void TestGetSetMapsShouldGetSetMaps() { var map = new SourceMap(); var maps = new List <SourceMap> { map }; _source.SetMaps(maps); var result = _source.GetMaps(); Assert.That(result, Contains.Item(map)); }
public void SetUp() { _column = new ColumnBuilder() .WithId(0) .WithIndex(1) .WithName("Test") .WithDataType(typeof(string)) .WithSemanticType(SemanticType.Measure) .Build(); _dataTable = new DataTableBuilder() .WithColumn(new DataColumn()) .WithRow("Field 1") .Build(); _value = new List <Row>(); _map = new SourceMapBuilder() .WithIndex(_column.Index) .WithName(_column.Name) .WithDataType(_column.DataType) .WithSemanticType(_column.SemanticType) .Build(); _source = new CsvFileSource(); _source.SetMaps(new List <SourceMap> { _map }); _mockSourceRepository = new Mock <ISourceRepository>(); _mockSourceRepository.Setup(p => p.GetSource <CsvFileSource>()) .Returns(_source); _mockEventBus = new Mock <IEventBus>(); _mockStateService = new Mock <IApplicationStateService>(); _mockDataContext = new Mock <IDataContext>(); _mockDataAdapter = new Mock <ICsvFileDataAdapter>(); _mockDataAdapter.Setup(p => p.GetTable(_source)) .Returns(_dataTable); _mockConverterFactory = new Mock <IDataTypeConverterFactory>(); _mockConverterFactory.Setup(p => p.Create(typeof(string), _column.DataType)) .Returns(new PassThroughConverter()); _mockLoaderFactory = new Mock <IDataLoaderFactory>(); _mockLoaderFactory.Setup(p => p.Create(_column.DataType, _source.FilePath)) .Returns(new FakeDataLoader()); _mockColumnFactory = new Mock <IColumnFactory>(); _mockColumnFactory.Setup(p => p.Create(_column.Index + 1, _column.Index, _column.Name, _column.DataType, _column.SemanticType, It.IsAny <List <object> >())) .Returns(_column); _mockColumnRepository = new Mock <IColumnRepository>(); _mockRowRepository = new Mock <IRowRepository>(); _mockRowRepository.Setup(p => p.GetAll()) .Returns(_value); _mockRowRepository.Setup(p => p.Add(It.IsAny <Row>())) .Callback <Row>(p => _value.Add(p)); _handler = new ImportCsvFileSourceCommandHandler( _mockSourceRepository.Object, _mockEventBus.Object, _mockStateService.Object, _mockDataContext.Object, _mockDataAdapter.Object, _mockConverterFactory.Object, _mockLoaderFactory.Object, _mockColumnFactory.Object, _mockColumnRepository.Object, _mockRowRepository.Object); }