public async Task DataStream_Postgres_GetFilteredData_Test() { var stream = GetValidStream(); var connector = new PostgresqlConnector(_logger); AssertSuccessful(await connector.InitAsync(stream)); var deviceId = "DEV001"; const int rowcount = 20; for (var idx = 0; idx < rowcount; ++idx) { AssertSuccessful(await AddRecord(connector, stream, deviceId, idx, idx + 100)); } var filteredItems = new Dictionary <string, object>() { { "int1", 5 }, }; var results = await connector.GetItemsAsync(filteredItems, new Core.Models.UIMetaData.ListRequest()); Assert.AreEqual(1, results.Model.Count()); Assert.AreEqual(5, results.Model.First()["int1"]); }
public async Task DataStream_Postgres_UpdateItem_Test() { var stream = GetValidStream(); var connector = new PostgresqlConnector(_logger); AssertSuccessful(await connector.InitAsync(stream)); var deviceId = "DEV001"; AssertSuccessful(await AddRecord(connector, stream, deviceId, 100, 356)); var filteredItems = new Dictionary <string, object>() { { "deviceid", deviceId }, { "int2", 356 }, }; var results = await connector.GetItemsAsync(filteredItems, new Core.Models.UIMetaData.ListRequest()); Assert.AreEqual(1, results.Model.Count()); Assert.AreEqual(100, results.Model.First()["int1"]); var updatedItems = new Dictionary <string, object>() { { "int1", 53 }, { "dec1", 12.5 }, { "str1", 12.5 }, }; await connector.UpdateItem(updatedItems, filteredItems); results = await connector.GetItemsAsync(filteredItems, new Core.Models.UIMetaData.ListRequest()); Assert.AreEqual(1, results.Model.Count()); Assert.AreEqual(53, results.Model.First()["int1"]); }
public async Task DataStream_Postgres_GetData_Test() { var stream = GetValidStream(); var connector = new PostgresqlConnector(_logger); AssertSuccessful(await connector.InitAsync(stream)); var deviceId = "DEV001"; const int rowcount = 20; for (var idx = 0; idx < rowcount; ++idx) { AssertSuccessful(await AddRecord(connector, stream, deviceId, idx, idx + 100)); } var results = await connector.GetItemsAsync(deviceId, new Core.Models.UIMetaData.ListRequest()); Assert.AreEqual(deviceId, results.Model.First()[stream.DeviceIdFieldName].ToString()); Assert.AreEqual(rowcount, results.Model.Count()); }