public void UpdateReceivedJSONObject(BluetoothDeviceConnection conection, JSONDataSource dataSource) { // TODO: enlever ça ou l'implémenter. //_DataHistory.Add(dataSource); if (dataSource is IMU) { IMU = dataSource as IMU; } else if (dataSource is PID) { PID = dataSource as PID; } else if (dataSource is sensors) { Sensors = dataSource as sensors; } else if (dataSource is radio) { Radio = dataSource as radio; } else if (dataSource is rawEcho) { RawEcho = dataSource as rawEcho; } }
public async Task ShouldReturnOkBothServices() { IOptions <AppSettingsModel> settings = Options.Create(TestHelper.GetApplicationConfiguration()); var httpClientFactoryMock = await TestHelper.GetMockHttpClientFactoryAsync(settings); var dataSource = new JSONDataSource(settings); var genericService = new GenericService(dataSource); var developersService = new DevelopersService(dataSource, httpClientFactoryMock, settings); var controller = new DevelopersController(genericService, developersService); var data = await controller.GetAllAsync(); Assert.NotEmpty(data); data = await controller.GetSkilledAsync(); Assert.NotEmpty(data); foreach (var dev in data) { Assert.True(dev.Skills.Count() >= 1); Assert.Contains(dev.Skills, s => s.Level >= 8); Assert.True(dev.Skills.Select(s => s.Type).Distinct().Count() == 1); } }
public async Task ShouldReadJsonFile() { IOptions <AppSettingsModel> settings = Options.Create(TestHelper.GetApplicationConfiguration()); var dataSource = new JSONDataSource(settings); var data = await dataSource.GetAllAsync(); Assert.True(data != null); }
public static void ParseData(List <KeyValuePair <string, string> > values, ref SqlBuilderColumnSelection requestedCols, ref SqlBuilderColumnSelection workingSelCols, ref SqlBuilderColumnSelection distinctSelCols, ref OrderBy orderBy, ref KeylessVirtualTable table) { foreach (KeyValuePair <string, string> value in values) { switch (value.Key) { case "SelectColumns": JSONDataSource jsonDS = JsonConvert.DeserializeObject <JSONDataSource>(value.Value); ConstructDataSourceObjectFromPostRequest(jsonDS, ref requestedCols, ref workingSelCols, ref distinctSelCols, ref orderBy, ref table); break; } } }
public async Task ShouldGetData() { IOptions <AppSettingsModel> settings = Options.Create(TestHelper.GetApplicationConfiguration()); var httpClientFactoryMock = await TestHelper.GetMockHttpClientFactoryAsync(settings); var dataSource = new JSONDataSource(settings); var service = new DevelopersService(dataSource, httpClientFactoryMock, settings); var data = await service.GetAllAsync(); Assert.NotEmpty(data); data = await service.GetSkilledAsync(); Assert.NotEmpty(data); }
public static void ConstructDataSourceObjectFromPostRequest(JSONDataSource jsonDS, ref SqlBuilderColumnSelection requestedCols, ref SqlBuilderColumnSelection workingSelCols, ref SqlBuilderColumnSelection distinctSelCols, ref OrderBy orderBy, ref KeylessVirtualTable table) { DataSource ds = new DataSource(); ds.Initialize(jsonDS.Name, DatabaseObjects.GetTableObject(jsonDS.Table), jsonDS.PageSize, jsonDS.PageIndex, jsonDS.GenerateTotal); if ((jsonDS.JSelectItems != null)) { foreach (JDataSourceSelectItem jsonSItem in jsonDS.JSelectItems) { ds.AddSelectItem(ConstructSelectItemFromPostRequest(jsonSItem)); } } requestedCols = new SqlBuilderColumnSelection(jsonDS.ExpandForeignKeyColumns, jsonDS.IsDistinct); workingSelCols = new SqlBuilderColumnSelection(jsonDS.ExpandForeignKeyColumns, jsonDS.IsDistinct); distinctSelCols = new SqlBuilderColumnSelection(jsonDS.ExpandForeignKeyColumns, jsonDS.IsDistinct); List <BaseColumn> columnsList = null; if (jsonDS.isTotalRecordArray) { columnsList = ds.CreateColumnSelectionsForTotal(ref requestedCols, ref workingSelCols, ref distinctSelCols); } else { columnsList = ds.CreateColumnSelections(ref requestedCols, ref workingSelCols, ref distinctSelCols); } table = ds.CreateVirtualTable(columnsList.ToArray()); if ((jsonDS.JOrderByList != null)) { foreach (JOrderBy jsonOrderBy in jsonDS.JOrderByList) { ds.AddAggregateOrderBy(jsonOrderBy.ColumnName, OrderByItem.ToOrderDir(jsonOrderBy.OrderDirection)); } } ds.UpdateOrderBy(columnsList); orderBy = ds.OrderBy; }