Example #1
0
        public async Task DisposeAsync_ServiceProviderIsNull_ContextWasDisposed()
        {
            //Arrange
            var context = new TestableDbProvider <string>(TestParameters.KsqlDBUrl);

            //Act
            await context.DisposeAsync().ConfigureAwait(false);

            //Assert
            context.IsDisposed.Should().BeTrue();
        }
Example #2
0
        public void CreateStreamSet_CalledMultipleTimes_KSqlQueryGeneratorBuildKSqlWasNotCalled()
        {
            //Arrange
            var context = new TestableDbProvider <string>(TestParameters.KsqlDBUrl);

            //Act
            var subscription = context.CreateQueryStream <string>().Subscribe(_ => {});

            //Assert
            context.KSqlQueryGenerator.Verify(c => c.BuildKSql(It.IsAny <Expression>(), It.IsAny <QueryContext>()), Times.Once);
        }
Example #3
0
        public void CreateStreamSet_Subscribe_KSqldbProvidersRunWasCalled()
        {
            //Arrange
            var context = new TestableDbProvider <string>(TestParameters.KsqlDBUrl);

            //Act
            var streamSet = context.CreateQueryStream <string>().Subscribe(_ => {});

            //Assert
            streamSet.Should().NotBeNull();
            context.KSqldbProviderMock.Verify(c => c.Run <string>(It.IsAny <object>(), It.IsAny <CancellationToken>()), Times.Once);
        }
Example #4
0
        public void CreateStreamSet_Subscribe_KSqlQueryGenerator()
        {
            //Arrange
            var contextOptions = new KSqlDBContextOptions(TestParameters.KsqlDBUrl);

            contextOptions.QueryStreamParameters["auto.offset.reset"] = "latest";

            var context = new TestableDbProvider <string>(contextOptions);

            //Act
            var subscription = context.CreateQueryStream <string>().Subscribe(_ => {}, e => {});

            //Assert
            context.KSqldbProviderMock.Verify(c => c.Run <string>(It.Is <QueryStreamParameters>(parameters => parameters["auto.offset.reset"] == "latest"), It.IsAny <CancellationToken>()), Times.Once);
        }
        public async Task CreateQuery_RawKSQL_ReturnAsyncEnumerable()
        {
            //Arrange
            string ksql = @"SELECT * FROM tweetsTest EMIT CHANGES LIMIT 2;";

            QueryParameters queryParameters = new QueryParameters
            {
                Sql = ksql,
                [QueryParameters.AutoOffsetResetPropertyName] = "earliest",
            };

            var context = new TestableDbProvider <string>(TestParameters.KsqlDBUrl);

            //Act
            var source = context.CreateQuery <string>(queryParameters);

            //Assert
            source.Should().NotBeNull();
        }