public void ToODataUriString_WhenGivenODataQuery_ReturnsQuery(string query)
        {
            var q = ODataQuery.Create <Album>(query).Options.ToODataUriString();

            Console.WriteLine("Query1: " + query);
            Console.WriteLine("Query2: " + q);

            Assert.AreEqual(query, q);
        }
        public void CreateODataQuery_WhenEmptyFilterIsModifiedWithOrFirst_ReturnsQuery()
        {
            var q = ODataQuery.Create <Album>("$orderby=Id&$top=10&$skip=5");
            var m = q.FilterExpression.Or("contains(tolower(Title), 'hell')").And("contains(tolower(Title), 'rock')").GetQuery();

            Assert.AreEqual(q.Options.Top.RawValue, m.Options.Top.RawValue);
            Assert.AreEqual(q.Options.Skip.RawValue, m.Options.Skip.RawValue);
            Assert.AreEqual(q.Options.OrderBy.RawValue, m.Options.OrderBy.RawValue);
            Assert.AreEqual("contains(tolower(Title), 'hell') and contains(tolower(Title), 'rock')", m.Options.Filter.RawValue);
        }
        public void ApplyODataQuery_WhenGivenValidAlbumQueryString_ReturnsFilteredCollection()
        {
            var c = new List <Album>()
            {
                new Album()
                {
                    AlbumId = 1
                },
                new Album()
                {
                    AlbumId = 2
                }
            }.AsQueryable();
            var q = ODataQuery.Create <Album>("$filter=AlbumId eq 1");

            var p = q.ApplyTo(c);

            Assert.AreEqual(1, p.Count());
        }
        public void CreateODataQuery_WhenGivenValidQueryString_ReturnsQuery()
        {
            var q = ODataQuery.Create <Album>("$filter=Id eq 1");

            Assert.IsNotNull(q);
        }
        public void IsEmpty_WhenGivenNonEmptyQuery_ReturnsFalse(string query)
        {
            var q = ODataQuery.Create <Album>(query).Options.IsEmpty();

            Assert.IsFalse(q);
        }
        public void IsEmpty_WhenGivenEmptyQuery_ReturnsTrue()
        {
            var q = ODataQuery.Create <Album>("").Options.IsEmpty();

            Assert.IsTrue(q);
        }
Beispiel #7
0
        public async Task <IEnumerable <DomainTrack> > GetAlbumTracks(long albumId)
        {
            var tracks = await this.trackRepository.GetTracks(ODataQuery.Create <Track>($"$filter=AlbumId eq {albumId}"));

            return(this.mapper.Map <IEnumerable <DomainTrack> >(tracks));
        }