public void GetNotExistPropWillReturnNull() { var val = new { A = 3 }; var prop = CommonMacros.GetProp(val, "A.A"); Assert.Null(prop); }
public void GetSimplePropOk() { var val = new { A = 3 }; var prop = CommonMacros.GetProp(val, "A"); Assert.NotNull(prop); }
public void CanGetNextedObjectValue() { var val = new { A = new { B = 4 } }; var getted = CommonMacros.GetPropValue(val, "A.B"); Assert.Equal(4, getted); }
public void GetNestedPropOk() { var val = new { A = new { A = 3 } }; var prop = CommonMacros.GetProp(val, "A.A"); Assert.NotNull(prop); }
public void InputNullWillBeEmpty() { string val = null; var actual = CommonMacros.Val(SdmapCompilerContext.CreateEmpty(), "", val, null); Assert.True(actual.IsSuccess); Assert.Equal(string.Empty, actual.Value); }
public void HelloWorld() { var val = "Hello World"; var actual = CommonMacros.Val(SdmapCompilerContext.CreateEmpty(), "", val, null); Assert.True(actual.IsSuccess); Assert.Equal(val, actual.Value); }
public void NotExistPropShouldFail() { var val = CommonMacros.Iif(SdmapCompilerContext.CreateEmpty(), "", new { A = new bool?() }, new object[] { "B", "true", "false" }); Assert.False(val.IsSuccess); }
public void ValueIsNotEmpty() { var val = CommonMacros.IsNotEmpty(SdmapCompilerContext.CreateEmpty(), "", new { A = DateTime.Now }, new object[] { "A", "Ok" }); Assert.True(val.IsSuccess); Assert.Equal("Ok", val.Value); }
public void EmptyNullShouldTreatFalsy() { var val = CommonMacros.Iif(SdmapCompilerContext.CreateEmpty(), "", new { A = new bool?() }, new object[] { "A", "true", "false" }); Assert.True(val.IsSuccess); Assert.Equal("false", val.Value); }
public void Smoke() { var val = CommonMacros.Iif(SdmapCompilerContext.CreateEmpty(), "", new { A = true }, new object[] { "A", "true", "false" }); Assert.True(val.IsSuccess); Assert.Equal("true", val.Value); }
public static bool PropertyExistsAndEvalToTrue(object obj, string propName) { var val = CommonMacros.GetPropValue(obj, propName); if (val is bool) { return((bool)val); } if (val is bool?) { return(((bool?)val).GetValueOrDefault()); } return(false); }
public static bool IsEmpty(object obj) { if (obj == null) { return(true); } if (obj is string) { return(string.IsNullOrEmpty((string)obj)); } if (obj is IEnumerable) { return(CommonMacros.ArrayEmpty(obj)); } return(false); }
private Result <string> CallIsNotLike(object self, string prop, string regex, string result) { return(CommonMacros.IsNotLike(SdmapCompilerContext.CreateEmpty(), "", self, new object[] { prop, regex, result })); }
private Result <string> CallIterate(object self, string joiner, string text) { return(CommonMacros.Iterate(SdmapCompilerContext.CreateEmpty(), "", self, new object[] { joiner, text })); }
public static object LoadProp(object obj, string propName) { return(CommonMacros.GetPropValue(obj, propName)); }
public void NumberEqualsNumber() { Assert.True(CommonMacros.IsEqual(3.14m, 3.14)); }
public void DateEqualsDate() { var date = new DateTime(2016, 1, 1); Assert.True(CommonMacros.IsEqual(date, DateUtil.Parse("2016/1/1").Value)); }
public void BoolEqualBool() { Assert.True(CommonMacros.IsEqual(true, true)); }
public void CanDetectNotEmptyArray() { var arr = Enumerable.Range(1, 10); Assert.False(CommonMacros.ArrayEmpty(arr)); }
private Result <string> CallEach(object self, string prop, string joiner, string text) { return(CommonMacros.Each(SdmapCompilerContext.CreateEmpty(), "", self, new object[] { prop, joiner, text })); }
public void GetNotExistPropWillNotThrow() { var val = new { A = 3 }; var prop = CommonMacros.GetProp(val, "B.C.D"); }
private Result <string> CallHasProp(object self, string prop, string result) { return(CommonMacros.HasProp(SdmapCompilerContext.CreateEmpty(), "", self, new[] { prop, result })); }