public void GetStateStoreExist() { var source = new CancellationTokenSource(); var config = new StreamConfig <StringSerDes, StringSerDes>(); config.ApplicationId = "test-config"; var topicConfiguration = config.Clone(); topicConfiguration.ApplicationId = $"test-driver-{config.ApplicationId}"; var builder = new StreamBuilder(); builder.Table <string, string>("test", InMemory <string, string> .As("store")); var driver = new ClusterInMemoryTopologyDriver("client", builder.Build().Builder, config, topicConfiguration, TimeSpan.FromSeconds(1), source.Token); driver.StartDriver(); var input = driver.CreateInputTopic("test", new StringSerDes(), new StringSerDes()); var store = driver.GetStateStore <string, string>("store"); Assert.IsNotNull(store); Assert.IsInstanceOf <MockReadOnlyKeyValueStore <string, string> >(store); input.PipeInput("coucou", "1"); Thread.Sleep(100); Assert.AreEqual(1, ((MockReadOnlyKeyValueStore <string, string>)store).All().Count()); Assert.AreEqual("1", ((MockReadOnlyKeyValueStore <string, string>)store).Get("coucou")); source.Cancel(); driver.Dispose(); }
public void GetStateStoreNotExist() { var source = new CancellationTokenSource(); var config = new StreamConfig <StringSerDes, StringSerDes>(); config.ApplicationId = "test-config"; var topicConfiguration = config.Clone(); topicConfiguration.ApplicationId = $"test-driver-{config.ApplicationId}"; var builder = new StreamBuilder(); builder.Stream <string, string>("test").To("test2"); var driver = new ClusterInMemoryTopologyDriver("client", builder.Build().Builder, config, topicConfiguration, source.Token); driver.StartDriver(); driver.CreateInputTopic("test", new StringSerDes(), new StringSerDes()); var store = driver.GetStateStore <string, string>("store"); Assert.IsNull(store); source.Cancel(); driver.Dispose(); }