Example #1
0
    public void GetPlaceHolder_Ok()
    {
        var ph = Utility.GetPlaceHolder(typeof(Foo), "Name");

        Assert.Equal("不可为空", ph);

        // 动态类型
        ph = Utility.GetPlaceHolder(DynamicObjectHelper.CreateDynamicType(), "Name");
        Assert.Null(ph);
    }
Example #2
0
    public void CreateType_Ok()
    {
        // 创建动态类型基类是 DynamicObject
        var instanceType = DynamicObjectHelper.CreateDynamicType();

        Assert.NotNull(instanceType);
        Assert.Equal(typeof(DynamicObject), instanceType.BaseType);

        // 创建动态类型实例
        var instance = DynamicObjectHelper.CreateDynamicObject();

        Assert.NotNull(instance);

        var properties = instance.GetType().GetProperties().Select(p => p.Name);

        Assert.Contains(nameof(DynamicObject.DynamicObjectPrimaryKey), properties);

        // Utility
        var v = Utility.GetPropertyValue(instance, "Name");

        Assert.Null(v);
    }