Ejemplo n.º 1
0
        public void FirstAfterWhere()
        {
            // Arrange
            var translator = new FirstTranslator(_nameChanges);
            Expression <Func <Country> > query = () => _countries.Where(p => !p.IsExists).First();
            var translation = new TranslationResult();

            // Act && Assert
            translator.Translate((MethodCallExpression)query.Body, translation);

            Assert.NotNull(translation.TableQuery);
            Assert.NotNull(translation.TableQuery.FilterString);
            Assert.Equal("not IsExists", translation.TableQuery.FilterString);
        }
Ejemplo n.º 2
0
        public void FirstWithInvalidMethod()
        {
            // Arrange
            var translator = new FirstTranslator(_nameChanges);
            Expression <Func <Country> > query = () => _countries.FirstOrDefault(p => !p.IsExists);
            var translation = new TranslationResult();

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

            // Assert
            Assert.NotNull(translation.TableQuery);
            Assert.Null(translation.TableQuery.FilterString);
            Assert.Null(translation.PostProcessing);
        }