public void TestODataIifContainsNullableWithoutRightConvert() { // Arrange. var testProvider = new TestLcsQueryProvider <FullTypesMainAgregator>(); var rightValue = (bool?)true; new Query <FullTypesMainAgregator>(testProvider) .Where(o => (o.PoleString == null ? null : (bool?)o.PoleString.Contains("test")) == rightValue) .ToArray(); Expression queryExpression = testProvider.InnerExpression; var expected = new LoadingCustomizationStruct(null) { LimitFunction = this.ldef.GetFunction( this.ldef.funcLike, new VariableDef(this.ldef.StringType, Information.ExtractPropertyPath <FullTypesMainAgregator>(x => x.PoleString)), "%test%") }; // Act. LoadingCustomizationStruct actual = LinqToLcs.GetLcs(queryExpression, FullTypesMainAgregator.Views.FullView); // Assert. Assert.True(Equals(expected, actual)); }
public void TestEnumLinqToLcsWithVariable() { // Arrange. var testProvider = new TestLcsQueryProvider <FullTypesMainAgregator>(); PoleEnum poleEnum = PoleEnum.Attribute1; var predicate1 = (Expression <Func <FullTypesMainAgregator, bool> >)(o => o.PoleEnum == poleEnum); new Query <FullTypesMainAgregator>(testProvider).Where(predicate1).ToArray(); Expression queryExpression = testProvider.InnerExpression; var expected = new LoadingCustomizationStruct(null) { LimitFunction = ldef.GetFunction( ldef.funcEQ, new VariableDef(ldef.StringType, Information.ExtractPropertyPath <FullTypesMainAgregator>(x => x.PoleEnum)), EnumCaption.GetCaptionFor(PoleEnum.Attribute1)) }; // Act. LoadingCustomizationStruct actual = LinqToLcs.GetLcs(queryExpression, FullTypesMainAgregator.Views.FullView); // Assert. Assert.True(Equals(expected, actual)); }
public void TestEnumLinqToLcsWithoutVariable() { var exception = Xunit.Record.Exception(() => { // Arrange. var testProvider = new TestLcsQueryProvider <FullTypesMainAgregator>(); var predicate1 = (Expression <Func <FullTypesMainAgregator, bool> >)(o => o.PoleEnum == PoleEnum.Attribute1); new Query <FullTypesMainAgregator>(testProvider).Where(predicate1).ToArray(); Expression queryExpression = testProvider.InnerExpression; var expected = new LoadingCustomizationStruct(null) { LimitFunction = ldef.GetFunction( ldef.funcEQ, new VariableDef(ldef.StringType, Information.ExtractPropertyPath <FullTypesMainAgregator>(x => x.PoleEnum)), EnumCaption.GetCaptionFor(PoleEnum.Attribute1)) }; // Act. // При компиляции в VS2013 или VS2015 ServicePack 1 данная строка вызовет NotSupportedException. LoadingCustomizationStruct actual = LinqToLcs.GetLcs(queryExpression, FullTypesMainAgregator.Views.FullView); // Assert. Assert.True(Equals(expected, actual)); }); Assert.IsType(typeof(NotSupportedException), exception); }
public void TestSystemEnumLinqToLcsWithoutVariable() { var exception = Xunit.Record.Exception(() => { // Arrange. var testProvider = new TestLcsQueryProvider <TestClassWithEnum>(); var predicate1 = (Expression <Func <TestClassWithEnum, bool> >)(o => o.PoleEnum == DayOfWeek.Saturday); new Query <TestClassWithEnum>(testProvider).Where(predicate1).ToArray(); Expression queryExpression = testProvider.InnerExpression; // Act. LoadingCustomizationStruct actual = LinqToLcs.GetLcs(queryExpression, TestClassWithEnum.GetView()); }); Assert.IsType(typeof(FunctionalLanguageDef.NotFoundFunctionParametersException), exception); }