Translate() public method

public Translate ( MethodCallExpression method, ITranslationResult result ) : void
method System.Linq.Expressions.MethodCallExpression
result ITranslationResult
return void
Beispiel #1
0
        public void TakeWithInvalidMethod()
        {
            // Arrange
            var translator = new TakeTranslator();
            IQueryable<Country> query = GetQueryable().Where(p => p.Name == string.Empty);
            var translation = new TranslationResult();

            // Act
            Assert.Throws<ArgumentOutOfRangeException>(() => translator.Translate((MethodCallExpression) query.Expression, translation));

            // Assert
            Assert.NotNull(translation.TableQuery);
            Assert.Null(translation.TableQuery.TakeCount);
        }
Beispiel #2
0
        public void TakeOneEntityTest()
        {
            // Arrange
            const int count = 435435;
            IQueryable<Country> query = GetQueryable().Take(count);
            var translator = new TakeTranslator();
            var translation = new TranslationResult();

            // Act
            translator.Translate((MethodCallExpression) query.Expression, translation);

            // Assert
            Assert.NotNull(translation.TableQuery);
            Assert.NotNull(translation.TableQuery.TakeCount);
            Assert.Equal(count, translation.TableQuery.TakeCount);
        }
Beispiel #3
0
        public void TakeOneEntityAfterWhereMethodTest()
        {
            // Arrange
            const int count = 555;
            IQueryable<Country> query = GetQueryable()
                .Where(p => p.Continent == "Europe").Take(count);
            var translator = new TakeTranslator();
            var translation = new TranslationResult();

            // Act
            translator.Translate((MethodCallExpression) query.Expression, translation);

            // Assert
            Assert.NotNull(translation.TableQuery);
            Assert.NotNull(translation.TableQuery.TakeCount);
            Assert.Equal(count, translation.TableQuery.TakeCount);
        }