Exemplo n.º 1
0
        public void ShouldCallStoredProcAsync()
        {
            // Arrange
            IDatabaseApi            databaseApi = CreateDatabaseApi();
            IStoreProcParamsBuilder builder     =
                new StoreProcParamsBuilder()
                .WithOutParam <string>("bar")
                .WithOutParam <int>("foo");

            StoredProcParam[] parameters = builder.Build();

            // Act
            ProcResponse result = databaseApi.CallStoredProcAsync <ProcResponse>("foo", "dataset", parameters).Result;

            // Assert
            result.Foo.ShouldBe(123);
            result.Bar.ShouldBe("test");
            result.Dataset.Count.ShouldBe(2);
            result.Dataset.Any(x => x.FirstName == "Selena").ShouldBe(true);

            Should.Throw <ArgumentNullException>(() => databaseApi.CallStoredProcAsync(null, parameters));
            Should.Throw <ArgumentNullException>(() => databaseApi.CallStoredProcAsync <ProcResponse>(null, parameters));
            Should.Throw <ArgumentNullException>(() => databaseApi.CallStoredProcAsync <ProcResponse>(null, "dataset", parameters));
            Should.Throw <ArgumentNullException>(() => databaseApi.CallStoredProcAsync <ProcResponse>("foo", null, parameters));
        }
        public void ShouldThrowIfNameIsNull()
        {
            // Arrange
            IStoreProcParamsBuilder builder = new StoreProcParamsBuilder();

            // Act & Assert
            Should.Throw<ArgumentNullException>(() => builder.WithOutParam<bool>(null, 100));
            Should.Throw<ArgumentNullException>(() => builder.WithInParam<bool>(null, true));
            Should.Throw<ArgumentNullException>(() => builder.WithInOutParam<bool>(null, true, 100));
        }
Exemplo n.º 3
0
        public void ShouldThrowIfNameIsNull()
        {
            // Arrange
            IStoreProcParamsBuilder builder = new StoreProcParamsBuilder();

            // Act & Assert
            Should.Throw <ArgumentNullException>(() => builder.WithOutParam <bool>(null, 100));
            Should.Throw <ArgumentNullException>(() => builder.WithInParam <bool>(null, true));
            Should.Throw <ArgumentNullException>(() => builder.WithInOutParam <bool>(null, true, 100));
        }
        public void ShouldBuildWithInParam()
        {
            // Arrange
            IStoreProcParamsBuilder builder = new StoreProcParamsBuilder();

            // Act
            builder.WithInParam("name", 123);

            // Assert
            StoredProcParam param = builder.Build().First();
            param.Name.ShouldBe("name");
            param.Type.ShouldBe("integer");
            param.ParamType.ShouldBe("IN");
            param.Value.ShouldBe("123");
        }
Exemplo n.º 5
0
        public void ShouldBuildWithInParam()
        {
            // Arrange
            IStoreProcParamsBuilder builder = new StoreProcParamsBuilder();

            // Act
            builder.WithInParam("name", 123);

            // Assert
            StoredProcParam param = builder.Build().First();

            param.name.ShouldBe("name");
            param.type.ShouldBe("integer");
            param.param_type.ShouldBe("IN");
            param.value.ShouldBe("123");
        }
        public void ShouldBuildWithOutParam()
        {
            // Arrange
            IStoreProcParamsBuilder builder = new StoreProcParamsBuilder();

            // Act
            builder.WithOutParam<bool>("name", 100);

            // Assert
            StoredProcParam param = builder.Build().First();
            param.Name.ShouldBe("name");
            param.Type.ShouldBe("boolean");
            param.ParamType.ShouldBe("OUT");
            param.Value.ShouldBe(null);
            param.Length.ShouldBe(100);
        }
        public void ShouldBuildWithInOutParam()
        {
            // Arrange
            IStoreProcParamsBuilder builder = new StoreProcParamsBuilder();

            // Act
            builder.WithInOutParam("name", "value", 100);

            // Assert
            StoredProcParam param = builder.Build().First();
            param.Name.ShouldBe("name");
            param.Type.ShouldBe("string");
            param.ParamType.ShouldBe("INOUT");
            param.Value.ShouldBe("value");
            param.Length.ShouldBe(100);
        }
Exemplo n.º 8
0
        public void ShouldBuildWithOutParam()
        {
            // Arrange
            IStoreProcParamsBuilder builder = new StoreProcParamsBuilder();

            // Act
            builder.WithOutParam <bool>("name", 100);

            // Assert
            StoredProcParam param = builder.Build().First();

            param.name.ShouldBe("name");
            param.type.ShouldBe("boolean");
            param.param_type.ShouldBe("OUT");
            param.value.ShouldBe(null);
            param.length.ShouldBe(100);
        }
Exemplo n.º 9
0
        public void ShouldBuildWithInOutParam()
        {
            // Arrange
            IStoreProcParamsBuilder builder = new StoreProcParamsBuilder();

            // Act
            builder.WithInOutParam("name", "value", 100);

            // Assert
            StoredProcParam param = builder.Build().First();

            param.name.ShouldBe("name");
            param.type.ShouldBe("string");
            param.param_type.ShouldBe("INOUT");
            param.value.ShouldBe("value");
            param.length.ShouldBe(100);
        }
Exemplo n.º 10
0
        public void ShouldCallStoredFuncAsync()
        {
            // Arrange
            IDatabaseApi            databaseApi = CreateDatabaseApi();
            IStoreProcParamsBuilder builder     =
                new StoreProcParamsBuilder()
                .WithOutParam <string>("bar")
                .WithOutParam <int>("foo");

            StoredProcParam[] parameters = builder.Build();

            // Act
            ProcResponse result = databaseApi.CallStoredFuncAsync <ProcResponse>("foo", "dataset", parameters).Result;

            // Assert
            result.foo.ShouldBe(123);
            result.bar.ShouldBe("test");
            result.dataset.Count.ShouldBe(2);
            result.dataset.Any(x => x.first_name == "Selena").ShouldBe(true);
        }
Exemplo n.º 11
0
        public void ShouldCallStoredFuncAsync()
        {
            // Arrange
            IDatabaseApi databaseApi = CreateDatabaseApi();
            IStoreProcParamsBuilder builder =
                new StoreProcParamsBuilder()
                    .WithOutParam<string>("bar")
                    .WithOutParam<int>("foo");
            StoredProcParam[] parameters = builder.Build();

            // Act
            ProcResponse result = databaseApi.CallStoredFuncAsync<ProcResponse>("foo", "dataset", parameters).Result;

            // Assert
            result.foo.ShouldBe(123);
            result.bar.ShouldBe("test");
            result.dataset.Count.ShouldBe(2);
            result.dataset.Any(x => x.first_name == "Selena").ShouldBe(true);
        }
Exemplo n.º 12
0
        public void ShouldCallStoredFuncAsync()
        {
            // Arrange
            IDatabaseApi databaseApi = CreateDatabaseApi();
            IStoreProcParamsBuilder builder =
                new StoreProcParamsBuilder()
                    .WithOutParam<string>("bar")
                    .WithOutParam<int>("foo");
            StoredProcParam[] parameters = builder.Build();

            // Act
            ProcResponse result = databaseApi.CallStoredFuncAsync<ProcResponse>("foo", "dataset", parameters).Result;

            // Assert
            result.Foo.ShouldBe(123);
            result.Bar.ShouldBe("test");
            result.Dataset.Count.ShouldBe(2);
            result.Dataset.Any(x => x.FirstName == "Selena").ShouldBe(true);

            Should.Throw<ArgumentNullException>(() => databaseApi.CallStoredFuncAsync<ProcResponse>(null, parameters));
            Should.Throw<ArgumentNullException>(() => databaseApi.CallStoredFuncAsync<ProcResponse>(null, "dataset", parameters));
            Should.Throw<ArgumentNullException>(() => databaseApi.CallStoredFuncAsync<ProcResponse>("foo", null, parameters));
        }