Пример #1
0
        public void StoredProcedureUnitTests()
        {
            using var connector = CreateConnector();
            var createCommand = connector.Command("create table Items (ItemId integer primary key, Name text not null);");

            createCommand.CommandType.Should().Be(CommandType.Text);
            createCommand.Execute().Should().Be(0);
            connector.Command("insert into Items (Name) values (@item1);", ("item1", "one")).CommandType.Should().Be(CommandType.Text);

            var storedProcedureCommand = connector.StoredProcedure("values (1);");

            storedProcedureCommand.CommandType.Should().Be(CommandType.StoredProcedure);
            Invoking(() => storedProcedureCommand.Execute()).Should().Throw <ArgumentException>("CommandType must be Text. (Parameter 'value')");
            connector.StoredProcedure("values (@two);", ("two", 2)).CommandType.Should().Be(CommandType.StoredProcedure);
        }