public async void BindToJObjectAndUpdate() { var adapter = new FakeTabularConnectorAdapterWithUpdateCount(); adapter.AddDataSet("default"); adapter.AddTable("default", "table1", "Id"); await adapter.CreateEntityAsync( "default", "table1", new JObject( new JProperty("Id", 1), new JProperty("Text", "foo"))); using (var host = CreateTestJobHost(adapter)) { await host.StartAsync(); await host.CallAsync(typeof(ApiHubTableBindingTests).GetMethod("BindToJObjectAndUpdateFunc")); await host.StopAsync(); } var entity = await adapter.GetEntityAsync <JObject>("default", "table1", "1"); Assert.NotNull(entity); Assert.Equal(1, entity["Id"].Value <int>()); Assert.Equal("bar", entity["Text"].Value <string>()); Assert.Equal(1, adapter.UpdateCount); }
public async void BindToEntityNoUpdate() { var adapter = new FakeTabularConnectorAdapterWithUpdateCount(); adapter.AddDataSet("default"); adapter.AddTable("default", "table1", "Id"); await adapter.CreateEntityAsync( "default", "table1", new SampleEntity { Id = 1, Text = "foo" }); using (var host = CreateTestJobHost(adapter)) { await host.StartAsync(); await host.CallAsync(typeof(ApiHubTableBindingTests).GetMethod("BindToEntityNoUpdateFunc")); await host.StopAsync(); } var entity = await adapter.GetEntityAsync <SampleEntity>("default", "table1", "1"); Assert.NotNull(entity); Assert.Equal(1, entity.Id); Assert.Equal("foo", entity.Text); Assert.Equal(0, adapter.UpdateCount); }
public async void BindToEntityWithBindingParameters() { var adapter = new FakeTabularConnectorAdapterWithUpdateCount(); adapter.AddDataSet("default"); adapter.AddTable("default", "table1", "Id"); await adapter.CreateEntityAsync( "default", "table1", new SampleEntity { Id = 1, Text = "foo" }); TestInput input = new TestInput { Id = 1, Table = "table1" }; var args = new Dictionary <string, object>() { { "input", JsonConvert.SerializeObject(input) } }; using (var host = CreateTestJobHost(adapter)) { await host.StartAsync(); await host.CallAsync(typeof(ApiHubTableBindingTests).GetMethod("BindToEntityWithBindingParametersFunc"), args); await host.StopAsync(); } var entity = await adapter.GetEntityAsync <SampleEntity>("default", "table1", "1"); Assert.NotNull(entity); Assert.Equal(1, entity.Id); Assert.Equal("bar", entity.Text); Assert.Equal(1, adapter.UpdateCount); }