/// <summary> /// test query is : /// - {type}P =in= ( manifest1, manifest2 ) /// - childP.{type}P =in= ( manifest1, manifest2 ) /// </summary> /// <param name="closure"></param> protected void OnShouldBeIn(char?closure = null) { var obj = Manifest1(); var listOfManifest = ListManifestToString(); // {type}P =in= ( manifest1, manifest2 ) var query = $"{Helper.GetJsonPropertyName(obj)}P=in={listOfManifest}"; var expected = Helper.Function <MockQuery>(query); var actual = Actual(obj); expected(actual) .Should() .BeTrue(); // childP.{type}P =in= ( manifest1, manifest2 ) var child = Actual(obj); actual = new MockQuery() { ChildP = child }; query = $"{Helper.GetChildJsonPropertyName(obj)}P=in={listOfManifest}"; expected = Helper.Function <MockQuery>(query); expected(actual) .Should() .BeTrue(); }
/// <summary> /// test query is : /// - {type}NullP =out= ( manifest1, manifest2 ) /// - childP.{type}NullP =out= ( manifest1, manifest2 ) /// </summary> protected void OnShouldBeNotInNullable() { var obj = Manifest2(); var listManifest = ListManifestToString(); var query = $"{Helper.GetJsonPropertyName(obj)}NullP=out={listManifest}"; // {type}NullP =out= ( manifest1, manifest2 ) var expected = Helper.Function <MockQuery>(query); var actual = Actual(default(T), true); expected(actual) .Should() .BeTrue(); // childP.{type}NullP =out= ( manifest1, manifest2 ) query = $"{Helper.GetChildJsonPropertyName(obj)}NullP=out={listManifest}"; expected = Helper.Function <MockQuery>(query); actual = new MockQuery() { ChildP = actual }; expected(actual) .Should() .BeTrue(); }
public void OrShouldBeOrExpressionWithGroupTest() { const string query = "(int32P<0,stringP==a),(int16NullP=is-null=true)"; var expected = Helper.Function <MockQuery>(query); var mock = new MockQuery { Int32P = -1, StringP = "a" }; Assert.True(expected(mock)); mock = new MockQuery { Int32P = -1, StringP = "a" }; Assert.True(expected(mock)); mock = new MockQuery { Int32P = 1, StringP = "a", Int16NullP = 6 }; Assert.True(expected(mock)); mock = new MockQuery { Int32P = 1, StringP = "b", Int16NullP = 6 }; Assert.True(!expected(mock)); mock = new MockQuery { Int32P = 1, StringP = "b", Int16NullP = null }; Assert.True(expected(mock)); }
public void AndSimpleTest() { const string query = "int32P<0;stringP==a"; var expected = Helper.Function <MockQuery>(query); var mock = new MockQuery { Int32P = -1, StringP = "b" }; Assert.True(!expected(mock)); mock = new MockQuery { Int32P = -1, StringP = "a" }; Assert.True(expected(mock)); mock = new MockQuery { Int32P = 0, StringP = "a" }; Assert.True(!expected(mock)); mock = new MockQuery { Int32P = 0, StringP = "b" }; Assert.True(!expected(mock)); }
public void ShouldBeOrExpression() { var query = "int32P<0,stringP==a"; var expected = Helper.Function <MockQuery>(query); var mock = new MockQuery { Int32P = -1, StringP = "b" }; Assert.True(expected(mock)); mock = new MockQuery { Int32P = -1, StringP = "a" }; Assert.True(expected(mock)); mock = new MockQuery { Int32P = 0, StringP = "a" }; Assert.True(expected(mock)); mock = new MockQuery { Int32P = 0, StringP = "b" }; Assert.True(!expected(mock)); }
protected MockQuery Actual(object obj, bool nullable = false, MockQuery child = null) { var property = typeof(MockQuery).GetProperty(obj.GetType().Name + (nullable ? "Null" : "") + "P"); var result = new MockQuery(); property?.SetValue(result, obj); if (child != null) { result.ChildP = child; } return(result); }