Ejemplo n.º 1
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(Ascending.GetHashCode() ^ (Labels != null ? Labels.GetHashCode() : 0) ^ FilterType.GetHashCode() ^ Open.GetHashCode() ^ Since.GetHashCode() ^ SortType.GetHashCode());
     }
 }
Ejemplo n.º 2
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(Ascending.GetHashCode() ^ (Labels != null ? Labels.GetHashCode() : 0) ^ Open.GetHashCode() ^ Since.GetHashCode() ^ SortType.GetHashCode() ^ (Mentioned != null ? Mentioned.GetHashCode() : 0) ^ (Creator != null ? Creator.GetHashCode() : 0) ^ (Assignee != null ? Assignee.GetHashCode() : 0) ^ (Milestone != null ? Milestone.GetHashCode() : 0));
     }
 }
Ejemplo n.º 3
0
        public async Task pagination_returns_correct_number_of_items()
        {
            const int page     = 1;
            const int pageSize = 20;

            var companies =
                await _realDbFixture.QueryAsync(ctx =>
                                                ctx.Persons
                                                .TakeSortedPage(
                                                    Ascending <Person, Guid> .By(x => x.Id),
                                                    Pagination.Set(page, pageSize))
                                                .ToListAsync());

            companies.Count.ShouldBe(pageSize);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Returns a <see cref="string"/> which represents the object instance.
        /// </summary>
        /// <returns>CAML-like string.</returns>
        public override string ToString()
        {
            switch (FieldRef.Type)
            {
            case FieldRefType.Key:
                return($"<FieldRef Name='ID' Ascending='{Ascending.ToString().ToUpper()}' />");

            case FieldRefType.ContentTypeId:
                return($"<FieldRef Name='ContentTypeId' Ascending='{Ascending.ToString().ToUpper()}' />");

            case FieldRefType.KnownMember:
                var memberRef = (MemberRefModel)FieldRef;
                return($"<FieldRef Name='{memberRef.Member.Name}' Ascending='{Ascending.ToString().ToUpper()}' />");
            }
            return($"<InvalidFieldRef Name='' Ascending='{Ascending.ToString().ToUpper()}' />");
        }
Ejemplo n.º 5
0
        public async Task running_out_of_pages_range_doesnt_causes_rising_exception()
        {
            var totalItems = await _realDbFixture.QueryAsync(ctx => ctx.Persons.CountAsync());

            const int pageSize = 50;
            var       lastPage = totalItems / pageSize;

            var companies = await _realDbFixture.QueryAsync(ctx =>
                                                            ctx.Persons
                                                            .TakeSortedPage(Ascending <Person, Guid> .By(x => x.Id),
                                                                            Pagination.Set(lastPage + 2, pageSize))
                                                            .ToListAsync());

            companies.ShouldNotBeNull();
            companies.ShouldBeEmpty();
        }
Ejemplo n.º 6
0
        public async Task paginating_empty_set_returns_empty_list()
        {
            const int pageSize = 20;
            const int page     = 1;

            var companies =
                await _realDbFixture.QueryAsync(ctx =>
                                                ctx.Persons
                                                .Where(x => x.Id == Guid.Empty) // will always return no entities
                                                .TakeSortedPage(
                                                    Ascending <Person, Guid> .By(x => x.Id),
                                                    Pagination.Set(page, pageSize))
                                                .ToListAsync());

            companies.ShouldNotBeNull();
            companies.ShouldBeEmpty();
        }
Ejemplo n.º 7
0
        public static void CreateOrdering(object sender, object selectedItem)
        {
            if (selectedItem is OrderingCollectionViewModel orderingCollectionViewModel)
            {
                CreateOrdering(sender, orderingCollectionViewModel.Parent);
                return;
            }

            if (!(selectedItem is GroupViewModel entityGroupViewModel))
            {
                return;
            }

            var button = (Button)sender;

            var type = (string)button.CommandParameter;

            OrderByBase entity;

            switch (type)
            {
            case nameof(Ascending):
                entity = Ascending.New("Property");
                break;

            case nameof(Descending):
                entity = Descending.New("Property");
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            entityGroupViewModel.Element.Ordering.Add(entity);
            var viewModelCollection = entityGroupViewModel.Children.OfType <OrderingCollectionViewModel>().First();

            var viewModel = new OrderingViewModel(entity, viewModelCollection);

            viewModelCollection.Children.Add(viewModel);

            entityGroupViewModel.IsExpanded = true;
            viewModelCollection.IsExpanded  = true;
            viewModel.IsSelected            = true;
            viewModel.IsExpanded            = true;
        }
Ejemplo n.º 8
0
        public async Task pagination_returns_items_in_correct_order_ascending()
        {
            const int page     = 1;
            const int pageSize = 5;

            var sorting = Ascending <Person, DateTime> .By(c => c.BirthDate);

            var pagination = Pagination.Set(page, pageSize);

            var customers =
                await _realDbFixture.QueryAsync(ctx => ctx.Persons
                                                .TakeSortedPage(sorting, pagination)
                                                .ToListAsync());

            IsOrderedAscending(
                items: customers.Select(x => x.BirthDate.Ticks),
                compare: LongsComparer,
                equal: LongsEquals).ShouldBeTrue();
        }
Ejemplo n.º 9
0
        public async Task should_not_fail()
        {
            const int    page       = 1;
            const int    pageSize   = 5;
            const string columnName = "BirthDate";

            var sorting = Ascending <Person> .By(columnName);

            var pagination = Pagination.Set(page, pageSize);

            var customers = await _realDbFixture.QueryAsync(
                ctx => ctx.Persons
                .TakeSortedPage(sorting, pagination)
                .ToListAsync());

            customers
            .Select(c => c.BirthDate.Ticks)
            .Aggregate(Math.Min)
            .ShouldBe(customers.First().BirthDate.Ticks);
        }
Ejemplo n.º 10
0
        public async Task pagination_called_twice_returns_the_same_set()
        {
            // Arrange
            const int page     = 1;
            const int pageSize = 20;

            IQueryable <Person> GetCustomers(Context ctx) =>
            ctx.Persons
            .TakeSortedPage(Ascending <Person, Guid> .By(x => x.Id),
                            Pagination.Set(page, pageSize));

            // Act
            var ls1 = await _realDbFixture.QueryAsync(ctx => GetCustomers(ctx).ToListAsync());

            var ls2 = await _realDbFixture.QueryAsync(ctx => GetCustomers(ctx).ToListAsync());

            // Assert
            // Length equality
            ls1.Count.ShouldBeSameAs(ls2);
        }
Ejemplo n.º 11
0
        public override XmlNode Serialize(XmlNode nodParent)
        {
            XmlNode nodMask = base.Serialize(nodParent);

            nodMask.AppendChild(nodParent.OwnerDocument.CreateElement("DirectionField")).InnerText = DirectionField;

            if (!string.IsNullOrEmpty(LabelField))
            {
                nodMask.AppendChild(nodParent.OwnerDocument.CreateElement("LabelField")).InnerText = LabelField;
            }

            if (!string.IsNullOrEmpty(DistanceField))
            {
                nodMask.AppendChild(nodParent.OwnerDocument.CreateElement("DistanceField")).InnerText = LabelField;
            }

            nodMask.AppendChild(nodParent.OwnerDocument.CreateElement("Ascending")).InnerText = Ascending.ToString();

            return(nodMask);
        }
Ejemplo n.º 12
0
 public String ToString(String separator)
 {
     return(IdFolder.ToString() + separator + Type.ToString() + separator + ItemsOrderBy.ToString() + separator + Ascending.ToString()
            + separator + (String.IsNullOrEmpty(IdentifierPath) ? "": IdentifierPath.ToString()) + separator + Repository.ToString(separator));
 }