WHEN_I_want_to_create_new_default_instance_THEN_it_should_be_configured_in_production() { ConfigurationManager.AppSettings["streamdata:secretkey"] = "abc"; var client = StreamdataClient <FakeObject> .WithDefaultConfiguration(); Check.That(client.Configuration.Mode).IsEqualTo(StreamdataConfigurationMode.PRODUCTION); }
WHEN_I_create_new_instance_THEN_ensure_default_engine_is_defined() { ConfigurationManager.AppSettings["streamdata:secretkey"] = "abc"; var client = StreamdataClient <FakeObject> .WithDefaultConfiguration(); var type = client.Configuration.EngineType.Item1; Check.That(type).IsEqualTo(typeof(EventSourceServerSentEngine)); }
WHEN_client_starts_THEN_it_should_order_engine_to_start() { var client = StreamdataClient <StockMarketOrders> .WithDefaultConfiguration(); StockMarketOrders orders = null; int counter = 0; var testApiUrl = "http://stockmarket.streamdata.io/prices"; client.OnData(o => orders = o); client.OnPatch(p => counter++); client.Start(testApiUrl); var expectedUrl = $"{StreamdataOfficialUrls.PRODUCTION}/{testApiUrl}?X-Sd-Token={client.Configuration.SecretKey}"; Check.That(client.ListenUrl).IsEqualTo(expectedUrl); //we wait 10s, after this time, we should already //have some first data and at least, one update Thread.Sleep(10 * 1000); Check.That(orders).IsNotNull(); Check.That(counter).IsGreaterThan(0); }