Exemplo n.º 1
0
    public void Build_Throws_When_TableName_Is_Missing()
    {
        // Arrange
        var input = new InsertCommandBuilder();

        // Act & Assert
        input.Invoking(x => x.Build())
        .Should().Throw <InvalidOperationException>()
        .WithMessage("table name is missing");
    }
Exemplo n.º 2
0
    public void Build_Throws_When_FieldValues_Are_Empty()
    {
        // Arrange
        var input = new InsertCommandBuilder().Into("MyTable").AddFieldNames("Field1", "Field2", "Field3");

        // Act & Assert
        input.Invoking(x => x.Build())
        .Should().Throw <InvalidOperationException>()
        .WithMessage("field values are missing");
    }
Exemplo n.º 3
0
    public void Build_Throws_When_FieldNames_And_FieldValues_Count_Are_Not_Equal()
    {
        // Arrange
        var input = new InsertCommandBuilder().Into("MyTable")
                    .AddFieldNames(new[] { "Field1", "Field2", "Field3" }.AsEnumerable())
                    .AddFieldValues(new[] { "Value1", "Value2" }.AsEnumerable());

        // Act & Assert
        input.Invoking(x => x.Build())
        .Should().Throw <InvalidOperationException>()
        .WithMessage("field name count should be equal to field value count");
    }
Exemplo n.º 4
0
    public void Can_Clear_Builder()
    {
        // Arrange
        var input = new InsertCommandBuilder().Into("MyTable")
                    .AddFieldNames("Field1", "Field2", "Field3")
                    .AddFieldValues("@Field1", "@Field2", "@Field3")
                    .AppendParameters(new { Field1 = "Value1", Field2 = "Value2", Field3 = "Value3" });

        // Act
        input.Clear();

        // Assert
        input.Invoking(x => x.Build())
        .Should().Throw <InvalidOperationException>()
        .WithMessage("table name is missing");
    }