Exemplo n.º 1
0
        public async Task BindToTableAndAddEntity()
        {
            var adapter = new FakeTabularConnectorAdapter();

            adapter.AddDataSet("dataset1");
            adapter.AddTable("dataset1", "table1", "Id");

            TestInput input = new TestInput
            {
                DataSet = "dataset1",
                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("BindToTableAndAddEntityFunc"), args);

                await host.StopAsync();
            }

            var entity = await adapter.GetEntityAsync <SampleEntity>("dataset1", "table1", "1");

            Assert.NotNull(entity);
            Assert.Equal(1, entity.Id);
            Assert.Equal("foo", entity.Text);
        }
Exemplo n.º 2
0
        private static JobHost CreateTestJobHost(FakeTabularConnectorAdapter adapter)
        {
            var configuration = new JobHostConfiguration
            {
                TypeLocator = new ExplicitTypeLocator(typeof(ApiHubTableBindingTests))
            };

            var connectionFactory = new FakeConnectionFactory(adapter);

            configuration.UseApiHub(new ApiHubConfiguration(connectionFactory));

            return(new JobHost(configuration));
        }
Exemplo n.º 3
0
        public async void BindToTableClientAndAddEntity()
        {
            var adapter = new FakeTabularConnectorAdapter();

            adapter.AddDataSet("default");
            adapter.AddTable("default", "table1", "Id");

            using (var host = CreateTestJobHost(adapter))
            {
                host.Start();
                host.Call(typeof(ApiHubTableBindingTests).GetMethod("BindToTableClientAndAddEntityFunc"));
                host.Stop();
            }

            var entity = await adapter.GetEntityAsync <SampleEntity>("default", "table1", "1");

            Assert.NotNull(entity);
            Assert.Equal(1, entity.Id);
            Assert.Equal("foo", entity.Text);
        }
Exemplo n.º 4
0
        public async void BindToAsyncCollectorOfJObjectAndAddEntity()
        {
            var adapter = new FakeTabularConnectorAdapter();

            adapter.AddDataSet("default");
            adapter.AddTable("default", "table1", "Id");

            using (var host = CreateTestJobHost(adapter))
            {
                host.Start();
                host.Call(typeof(ApiHubTableBindingTests).GetMethod("BindToAsyncCollectorOfJObjectAndAddEntityFunc"));
                host.Stop();
            }

            var entity = await adapter.GetEntityAsync <JObject>("default", "table1", "1");

            Assert.NotNull(entity);
            Assert.Equal(1, entity["Id"].Value <int>());
            Assert.Equal("foo", entity["Text"].Value <string>());
        }
 public FakeConnection(FakeTabularConnectorAdapter tableAdapter)
 {
     TableAdapter = tableAdapter;
 }
 public FakeConnectionFactory(FakeTabularConnectorAdapter tableAdapter) : base()
 {
     TableAdapter = tableAdapter;
 }