Exemplo n.º 1
0
        public void FirstOrDefaultWithInvalidMethod()
        {
            // Arrange
            var translator = new FirstOrDefaultTranslator(_nameChanges);
            Expression <Func <Country> > query = () => _countries.First(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);
        }
Exemplo n.º 2
0
        public void FirstOrDefaultAfterWhere()
        {
            // Arrange
            var translator = new FirstOrDefaultTranslator(_nameChanges);
            Expression <Func <Country> > query = () => _countries.Where(p => !p.IsExists).FirstOrDefault();
            var translation = new TranslationResult();

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

            // Assert
            Assert.NotNull(translation.TableQuery);
            Assert.NotNull(translation.TableQuery.FilterString);
            Assert.Equal("not IsExists", translation.TableQuery.FilterString);
        }