Exemple #1
0
        public void Should_ReturnIncludeQueryWithCorrectPath_IfIncludeCollection()
        {
            var includeAggregator = new IncludeAggregator <Book>();
            var includeQuery      = includeAggregator.Include(o => o.Author.Friends);

            Assert.Contains(includeQuery.Paths, path => path == $"{nameof(Book.Author)}.{nameof(Person.Friends)}");
        }
Exemple #2
0
        public void IncludeAggregator_AddEmptyStringInConstructor_ReturnsStringEmpty()
        {
            var expectedString    = string.Empty;
            var includeAggregator = new IncludeAggregator(null);

            Assert.Equal(expectedString, includeAggregator.IncludeString);
        }
Exemple #3
0
        public void Should_ReturnIncludeQueryWithCorrectPath_IfIncludeObject()
        {
            var includeAggregator = new IncludeAggregator <Person>();
            var includeQuery      = includeAggregator.Include(p => p.FavouriteBook.Author);

            Assert.Contains(includeQuery.Paths, path => path == $"{nameof(Person.FavouriteBook)}.{nameof(Book.Author)}");
        }
Exemple #4
0
        public void IncludeAggregator_AddPropertyNameInConstructor_ReturnsCorrectIncludeString()
        {
            var expectedString    = nameof(Company);
            var includeAggregator = new IncludeAggregator(expectedString);

            Assert.Equal(expectedString, includeAggregator.IncludeString);
        }
        public void ReturnsEmptyEmpty_GivenEmptyStringInConstructor()
        {
            var expectedString    = string.Empty;
            var includeAggregator = new IncludeAggregator(null);

            includeAggregator.IncludeString.Should().Be(expectedString);
        }
        public void ReturnsCorrectPath_GivenClassNameInConstructor()
        {
            var expectedString    = nameof(Company);
            var includeAggregator = new IncludeAggregator(expectedString);

            includeAggregator.IncludeString.Should().Be(expectedString);
        }
Exemple #7
0
        public void Should_ReturnIncludeQueryWithCorrectPath_IfIncludeSimpleType()
        {
            var includeAggregator = new IncludeAggregator <Person>();

            // There may be ORM libraries where including a simple type makes sense.
            var includeQuery = includeAggregator.Include(p => p.Age);

            Assert.Contains(includeQuery.Paths, path => path == nameof(Person.Age));
        }
Exemple #8
0
        public void Should_ReturnIncludeQueryWithCorrectPath_IfIncludeFunction()
        {
            var includeAggregator = new IncludeAggregator <Person>();

            // This include does not make much sense, but it should at least do not modify the paths.
            var includeQuery = includeAggregator.Include(p => p.FavouriteBook.GetNumberOfSales());

            Assert.Contains(includeQuery.Paths, path => path == nameof(Person.FavouriteBook));
        }
Exemple #9
0
        public void Include_Function_ReturnsIncludeQueryWithCorrectPath()
        {
            var includeAggregator = new IncludeAggregator <Person>();

            // This include does not make much sense, but it should at least not modify the paths.
            var includeQuery = includeAggregator.Include(p => p.FavouriteBook.GetNumberOfSales());

            // The resulting paths should not include number of sales.
            Assert.DoesNotContain(includeQuery.Paths, path => path == nameof(Book.GetNumberOfSales));
        }
Exemple #10
0
        public void IncludeAggregator_AddNavigationPropertyName_ReturnsCorrectIncludeString()
        {
            var expectedString = $"{nameof(Company)}.{nameof(Company.Stores)}.{nameof(Store.Products)}";

            var includeAggregator = new IncludeAggregator(nameof(Company));

            includeAggregator.AddNavigationPropertyName(nameof(Company.Stores));
            includeAggregator.AddNavigationPropertyName(nameof(Store.Products));

            Assert.Equal(expectedString, includeAggregator.IncludeString);
        }
        public void ReturnsCorrectPath_GivenPropertyNamesAndClassNameInConstructor()
        {
            var expectedString = $"{nameof(Company)}.{nameof(Company.Stores)}.{nameof(Store.Products)}";

            var includeAggregator = new IncludeAggregator(nameof(Company));

            includeAggregator.AddNavigationPropertyName(nameof(Company.Stores));
            includeAggregator.AddNavigationPropertyName(nameof(Store.Products));

            includeAggregator.IncludeString.Should().Be(expectedString);
        }