Exemple #1
0
    public void Null_Sets_Null_Value(Test input)
    {
        // Arrange
        var handler   = new JsonTypeHandler <Test>();
        var parameter = Substitute.For <IDbDataParameter>();

        // Act
        handler.SetValue(parameter, input);

        // Assert
        Assert.IsType <DBNull>(parameter.Value);
    }
Exemple #2
0
    public void Object_Sets_Value_As_Json()
    {
        // Arrange
        var handler   = new JsonTypeHandler <Test>();
        var parameter = Substitute.For <IDbDataParameter>();
        var v0        = Rnd.Str;
        var v1        = Rnd.Int;
        var input     = new Test {
            Foo = v0, Bar = v1
        };
        var expected = $"{{\"foo\":\"{v0}\",\"bar\":{v1},\"empty\":null}}";

        // Act
        handler.SetValue(parameter, input);

        // Assert
        Assert.Equal(expected, parameter.Value);
    }