public void TestAddPropertyToViewDinamicView() { View view = Utils.GetDefaultView(typeof(Кошка)); UtilsLcs.AddPropertyToView(view, "НесуществующееСвойство", true); Assert.Equal(Utils.GetDefaultView(typeof(Кошка)).Properties.Count() + 1, view.Properties.Count()); }
public void TestAddPropertyToViewNotDinamicView() { View view = Utils.GetDefaultView(typeof(Кошка)); UtilsLcs.AddPropertyToView(view, КличкаName, false); UtilsLcs.AddPropertyToView(view, "Порода.ТипПороды", false); Assert.Equal(Utils.GetDefaultView(typeof(Кошка)).Properties.Count(), view.Properties.Count()); }
public void TestAddPropertyToViewDinamicViewAndAgregetor() { View view = Utils.GetDefaultView(typeof(Перелом)); Assert.False(view.Properties.Where(x => x.Name == ЛапаName).Any()); UtilsLcs.AddPropertyToView(view, "НесуществующееСвойство", true); Assert.Equal(Utils.GetDefaultView(typeof(Перелом)).Properties.Count() + 2, view.Properties.Count()); Assert.True(view.Properties.Where(x => x.Name == ЛапаName).Any()); }
public void TestAddPropertyToViewUncorrectPropertyName2() { var exception = Xunit.Record.Exception(() => { UtilsLcs.AddPropertyToView(new View(), string.Empty, false); }); Assert.IsType(typeof(ArgumentNullException), exception); }
public void TestSupportedSqlLike() { Assert.Equal(@"abc", UtilsLcs.ConvertSqlToRegex(@"*abc*")); Assert.Equal(@"abc$", UtilsLcs.ConvertSqlToRegex(@"*abc")); Assert.Equal(@"^abc", UtilsLcs.ConvertSqlToRegex(@"abc*")); Assert.Equal(@"^abc$", UtilsLcs.ConvertSqlToRegex(@"abc")); Assert.Equal(@"^abc\{\}\?\+\(\)\[\]\|\^\$$", UtilsLcs.ConvertSqlToRegex(@"abc{}?+()[]|^$")); Assert.Equal(@"a.b.*c", UtilsLcs.ConvertSqlToRegex(@"*a_b*c*")); }
public void TestCheckRegexTooDifficult4() { var exception = Xunit.Record.Exception(() => { UtilsLcs.MinimalRegexCheck("abd+c"); }); Assert.IsType(typeof(NotSupportedRegexException), exception); }
public void TestNotSupportedSqlLike2() { var exception = Xunit.Record.Exception(() => { UtilsLcs.MinimalSqlCheck(@"*ab\\c*"); }); Assert.IsType(typeof(NotSupportedException), exception); }
public void TestCheckNotValidRegex() { var exception = Xunit.Record.Exception(() => { UtilsLcs.MinimalRegexCheck("[["); }); Assert.IsType(typeof(NotSupportedRegexException), exception); }
public void TestAddPropertyToViewNotDinamicViewWithError2() { var exception = Xunit.Record.Exception(() => { View view = Utils.GetDefaultView(typeof(Кошка)); UtilsLcs.AddPropertyToView(view, "Порода.НесуществующееСвойство", false); }); Assert.IsType(typeof(ArgumentException), exception); }
public void TestCheckRegex() { UtilsLcs.MinimalRegexCheck("abc"); UtilsLcs.MinimalRegexCheck("^abc$"); UtilsLcs.MinimalRegexCheck("^ab.c$"); UtilsLcs.MinimalRegexCheck("^ab.*c$"); //UtilsLcs.MinimalRegexCheck(@"^ab\\.*c$"); // TODO: временно экранирование снимается полностью. //UtilsLcs.MinimalRegexCheck(@"^ab\\d.*c$"); //UtilsLcs.MinimalRegexCheck(@"^ab\\d\$.*c$"); //UtilsLcs.MinimalRegexCheck(@"^ab\\d\^.*c$"); }
public void TestQueryCompilation() { Assert.Equal("prefixpostfix", UtilsLcs.TryExecuteBinaryOberation(ExpressionType.Add, "postfix", "prefix")); Assert.Equal(null, UtilsLcs.TryExecuteBinaryOberation(ExpressionType.Multiply, "postfix", "prefix")); Assert.Equal(3, UtilsLcs.TryExecuteBinaryOberation(ExpressionType.Add, 1, 2)); Assert.Equal(1, UtilsLcs.TryExecuteBinaryOberation(ExpressionType.Subtract, 1, 2)); Assert.Equal(2, UtilsLcs.TryExecuteBinaryOberation(ExpressionType.Multiply, 1, 2)); Assert.Equal(2, UtilsLcs.TryExecuteBinaryOberation(ExpressionType.Divide, 1, 2)); Assert.Equal(null, UtilsLcs.TryExecuteBinaryOberation(ExpressionType.Add, new VariableDef(ldef.StringType, "OperationType"), "123")); }
public void TestFromRegexToSql() { Assert.Equal(@"*abc*", UtilsLcs.ConvertRegexToSql(@"abc")); Assert.Equal(@"abc*", UtilsLcs.ConvertRegexToSql(@"^abc")); Assert.Equal(@"*abc", UtilsLcs.ConvertRegexToSql(@"abc$")); Assert.Equal(@"abc", UtilsLcs.ConvertRegexToSql(@"^abc$")); Assert.Equal(@"abc$*", UtilsLcs.ConvertRegexToSql(@"^abc\$")); // Assert.Equal(@"abc\$*", UtilsLcs.ConvertRegexToSql(@"^abc\\\$")); //TODO: временно экранирование снимается со всех символов Assert.Equal(@"*ab*c*", UtilsLcs.ConvertRegexToSql(@"ab.*c")); Assert.Equal(@"*ab_c*", UtilsLcs.ConvertRegexToSql(@"ab.c")); Assert.Equal(@"*ab.c*", UtilsLcs.ConvertRegexToSql(@"ab\.c")); // Assert.Equal(@"*ab_c*", UtilsLcs.ConvertRegexToSql(@"ab_c")); //TODO: временно экранирование снимается со всех символов // Assert.Equal(@"*ab*c*", UtilsLcs.ConvertRegexToSql(@"ab\*c")); //TODO: временно экранирование снимается со всех символов Assert.Equal(@"*ab[c*", UtilsLcs.ConvertRegexToSql(@"ab\[c")); //TODO: временно экранирование снимается со всех символов Assert.Equal(@"*ab]c*", UtilsLcs.ConvertRegexToSql(@"ab\]c")); //TODO: временно экранирование снимается со всех символов }
public void GetLcsTestBooleanFalseFunction() { var testProvider = new TestLcsQueryProvider <Кошка>(); // ReSharper disable NegativeEqualityExpression new Query <Кошка>(testProvider).Where(o => false).ToList(); // ReSharper restore NegativeEqualityExpression Expression queryExpression = testProvider.InnerExpression; var lf = UtilsLcs.GetFalseFunc(); var expected = new LoadingCustomizationStruct(null) { LimitFunction = lf }; LoadingCustomizationStruct actual = LinqToLcs.GetLcs(queryExpression, Utils.GetDefaultView(typeof(Кошка))); Assert.True(Equals(expected, actual)); }
/// <summary> /// Проверяем правильность перевода из шаблона для funcLike в шаблон для Regex и наоборот (в результате должно получиться то же, что и ушло на вход). /// </summary> /// <param name="testString"> Исходная и в то же время результирующая строка. </param> private void CheckFromSQLToRegexAndBack(string testString) { Assert.Equal(testString, UtilsLcs.ConvertRegexToSql(UtilsLcs.ConvertSqlToRegex(testString))); }