コード例 #1
0
        public async Task User_Should_Have_Been_Following_One_User()
        {
            User followerUser = new User((Nickname)"user11", (FullName)"test11 user11", Password.Create("password").Value, (Email)"*****@*****.**", "bio11");
            User followedUser = new User((Nickname)"user12", (FullName)"test12 user12", Password.Create("password").Value, (Email)"*****@*****.**", "bio12");

            FollowModel[] result;

            using (var session = _testFixture.OpenSession(_output))
            {
                await session.SaveAsync(followedUser);

                followerUser.Follow(followedUser);
                await session.SaveAsync(followerUser);
            }

            var followingQuery = new FollowingQuery(followerUser.Nickname);

            using (var session = _testFixture.OpenSession(_output))
            {
                var sut = new FollowingQueryHandler(session, Log.Logger);
                result = await sut.Handle(followingQuery, default);
            }

            result.Count().Should().Be(1);
        }
コード例 #2
0
        private string GetInsertionFollowerLine(FollowingQuery follower)
        {
            var isFollowing = follower.IsFollowing ? 1 : 0;

            return
                ($"EXECUTE [dbo].[addFollowBot] {follower.UserId}, {follower.FollowingId}, {follower.VisitsCount}, {isFollowing}, '{follower.FollowingDate:u}', '{follower.LastVisitDate:u}'");
        }
コード例 #3
0
        public async Task <IActionResult> Following(string id)
        {
            ViewBag.Message = $"Users followed by {id}";
            var query        = new FollowingQuery(id);
            var followedList = await _dispatcher.Send(query);

            return(PartialView("_UserListPartial", followedList));
        }
コード例 #4
0
 private FollowingQuery(FollowingQuery other) : base(other) {
     this.input    = Clone(other.input);
     this.iterator = Clone(other.iterator);
 }
コード例 #5
0
ファイル: QueryBuilder.cs プロジェクト: gitter-badger/corefx
        private Query ProcessAxis(Axis root, Flags flags, out Props props)
        {
            Query result = null;
            if (root.Prefix.Length > 0)
            {
                _needContext = true;
            }
            _firstInput = null;
            Query qyInput;
            {
                if (root.Input != null)
                {
                    Flags inputFlags = Flags.None;
                    if ((flags & Flags.PosFilter) == 0)
                    {
                        Axis input = root.Input as Axis;
                        if (input != null)
                        {
                            if (
                                root.TypeOfAxis == Axis.AxisType.Child &&
                                input.TypeOfAxis == Axis.AxisType.DescendantOrSelf && input.NodeType == XPathNodeType.All
                            )
                            {
                                Query qyGrandInput;
                                if (input.Input != null)
                                {
                                    qyGrandInput = ProcessNode(input.Input, Flags.SmartDesc, out props);
                                }
                                else
                                {
                                    qyGrandInput = new ContextQuery();
                                    props = Props.None;
                                }
                                result = new DescendantQuery(qyGrandInput, root.Name, root.Prefix, root.NodeType, false, input.AbbrAxis);
                                if ((props & Props.NonFlat) != 0)
                                {
                                    result = new DocumentOrderQuery(result);
                                }
                                props |= Props.NonFlat;
                                return result;
                            }
                        }
                        if (root.TypeOfAxis == Axis.AxisType.Descendant || root.TypeOfAxis == Axis.AxisType.DescendantOrSelf)
                        {
                            inputFlags |= Flags.SmartDesc;
                        }
                    }

                    qyInput = ProcessNode(root.Input, inputFlags, out props);
                }
                else
                {
                    qyInput = new ContextQuery();
                    props = Props.None;
                }
            }

            switch (root.TypeOfAxis)
            {
                case Axis.AxisType.Ancestor:
                    result = new XPathAncestorQuery(qyInput, root.Name, root.Prefix, root.NodeType, false);
                    props |= Props.NonFlat;
                    break;
                case Axis.AxisType.AncestorOrSelf:
                    result = new XPathAncestorQuery(qyInput, root.Name, root.Prefix, root.NodeType, true);
                    props |= Props.NonFlat;
                    break;
                case Axis.AxisType.Child:
                    if ((props & Props.NonFlat) != 0)
                    {
                        result = new CacheChildrenQuery(qyInput, root.Name, root.Prefix, root.NodeType);
                    }
                    else
                    {
                        result = new ChildrenQuery(qyInput, root.Name, root.Prefix, root.NodeType);
                    }
                    break;
                case Axis.AxisType.Parent:
                    result = new ParentQuery(qyInput, root.Name, root.Prefix, root.NodeType);
                    break;
                case Axis.AxisType.Descendant:
                    if ((flags & Flags.SmartDesc) != 0)
                    {
                        result = new DescendantOverDescendantQuery(qyInput, false, root.Name, root.Prefix, root.NodeType, /*abbrAxis:*/false);
                    }
                    else
                    {
                        result = new DescendantQuery(qyInput, root.Name, root.Prefix, root.NodeType, false, /*abbrAxis:*/false);
                        if ((props & Props.NonFlat) != 0)
                        {
                            result = new DocumentOrderQuery(result);
                        }
                    }
                    props |= Props.NonFlat;
                    break;
                case Axis.AxisType.DescendantOrSelf:
                    if ((flags & Flags.SmartDesc) != 0)
                    {
                        result = new DescendantOverDescendantQuery(qyInput, true, root.Name, root.Prefix, root.NodeType, root.AbbrAxis);
                    }
                    else
                    {
                        result = new DescendantQuery(qyInput, root.Name, root.Prefix, root.NodeType, true, root.AbbrAxis);
                        if ((props & Props.NonFlat) != 0)
                        {
                            result = new DocumentOrderQuery(result);
                        }
                    }
                    props |= Props.NonFlat;
                    break;
                case Axis.AxisType.Preceding:
                    result = new PrecedingQuery(qyInput, root.Name, root.Prefix, root.NodeType);
                    props |= Props.NonFlat;
                    break;
                case Axis.AxisType.Following:
                    result = new FollowingQuery(qyInput, root.Name, root.Prefix, root.NodeType);
                    props |= Props.NonFlat;
                    break;
                case Axis.AxisType.FollowingSibling:
                    result = new FollSiblingQuery(qyInput, root.Name, root.Prefix, root.NodeType);
                    if ((props & Props.NonFlat) != 0)
                    {
                        result = new DocumentOrderQuery(result);
                    }
                    break;
                case Axis.AxisType.PrecedingSibling:
                    result = new PreSiblingQuery(qyInput, root.Name, root.Prefix, root.NodeType);
                    break;
                case Axis.AxisType.Attribute:
                    result = new AttributeQuery(qyInput, root.Name, root.Prefix, root.NodeType);
                    break;
                case Axis.AxisType.Self:
                    result = new XPathSelfQuery(qyInput, root.Name, root.Prefix, root.NodeType);
                    break;
                case Axis.AxisType.Namespace:
                    if ((root.NodeType == XPathNodeType.All || root.NodeType == XPathNodeType.Element || root.NodeType == XPathNodeType.Attribute) && root.Prefix.Length == 0)
                    {
                        result = new NamespaceQuery(qyInput, root.Name, root.Prefix, root.NodeType);
                    }
                    else
                    {
                        result = new EmptyQuery();
                    }
                    break;
                default:
                    throw XPathException.Create(SR.Xp_NotSupported, _query);
            }

            return result;
        }
コード例 #6
0
 private FollowingQuery(FollowingQuery other) : base(other)
 {
     _input = Clone(other._input);
     _iterator = Clone(other._iterator);
 }
コード例 #7
0
        private Query ProcessAxis(Axis root, Flags flags, out Props props)
        {
            Query qyParent = null;
            Query query2;
            if (root.Prefix.Length > 0)
            {
                this.needContext = true;
            }
            this.firstInput = null;
            if (root.Input != null)
            {
                Flags none = Flags.None;
                if ((flags & Flags.PosFilter) == Flags.None)
                {
                    Axis input = root.Input as Axis;
                    if (((input != null) && (root.TypeOfAxis == Axis.AxisType.Child)) && ((input.TypeOfAxis == Axis.AxisType.DescendantOrSelf) && (input.NodeType == XPathNodeType.All)))
                    {
                        Query query3;
                        if (input.Input != null)
                        {
                            query3 = this.ProcessNode(input.Input, Flags.SmartDesc, out props);
                        }
                        else
                        {
                            query3 = new ContextQuery();
                            props = Props.None;
                        }
                        qyParent = new DescendantQuery(query3, root.Name, root.Prefix, root.NodeType, false, input.AbbrAxis);
                        if ((props & Props.NonFlat) != Props.None)
                        {
                            qyParent = new DocumentOrderQuery(qyParent);
                        }
                        props |= Props.NonFlat;
                        return qyParent;
                    }
                    if ((root.TypeOfAxis == Axis.AxisType.Descendant) || (root.TypeOfAxis == Axis.AxisType.DescendantOrSelf))
                    {
                        none |= Flags.SmartDesc;
                    }
                }
                query2 = this.ProcessNode(root.Input, none, out props);
            }
            else
            {
                query2 = new ContextQuery();
                props = Props.None;
            }
            switch (root.TypeOfAxis)
            {
                case Axis.AxisType.Ancestor:
                    qyParent = new XPathAncestorQuery(query2, root.Name, root.Prefix, root.NodeType, false);
                    props |= Props.NonFlat;
                    return qyParent;

                case Axis.AxisType.AncestorOrSelf:
                    qyParent = new XPathAncestorQuery(query2, root.Name, root.Prefix, root.NodeType, true);
                    props |= Props.NonFlat;
                    return qyParent;

                case Axis.AxisType.Attribute:
                    return new AttributeQuery(query2, root.Name, root.Prefix, root.NodeType);

                case Axis.AxisType.Child:
                    if ((props & Props.NonFlat) == Props.None)
                    {
                        return new ChildrenQuery(query2, root.Name, root.Prefix, root.NodeType);
                    }
                    return new CacheChildrenQuery(query2, root.Name, root.Prefix, root.NodeType);

                case Axis.AxisType.Descendant:
                    if ((flags & Flags.SmartDesc) == Flags.None)
                    {
                        qyParent = new DescendantQuery(query2, root.Name, root.Prefix, root.NodeType, false, false);
                        if ((props & Props.NonFlat) != Props.None)
                        {
                            qyParent = new DocumentOrderQuery(qyParent);
                        }
                        break;
                    }
                    qyParent = new DescendantOverDescendantQuery(query2, false, root.Name, root.Prefix, root.NodeType, false);
                    break;

                case Axis.AxisType.DescendantOrSelf:
                    if ((flags & Flags.SmartDesc) == Flags.None)
                    {
                        qyParent = new DescendantQuery(query2, root.Name, root.Prefix, root.NodeType, true, root.AbbrAxis);
                        if ((props & Props.NonFlat) != Props.None)
                        {
                            qyParent = new DocumentOrderQuery(qyParent);
                        }
                    }
                    else
                    {
                        qyParent = new DescendantOverDescendantQuery(query2, true, root.Name, root.Prefix, root.NodeType, root.AbbrAxis);
                    }
                    props |= Props.NonFlat;
                    return qyParent;

                case Axis.AxisType.Following:
                    qyParent = new FollowingQuery(query2, root.Name, root.Prefix, root.NodeType);
                    props |= Props.NonFlat;
                    return qyParent;

                case Axis.AxisType.FollowingSibling:
                    qyParent = new FollSiblingQuery(query2, root.Name, root.Prefix, root.NodeType);
                    if ((props & Props.NonFlat) != Props.None)
                    {
                        qyParent = new DocumentOrderQuery(qyParent);
                    }
                    return qyParent;

                case Axis.AxisType.Namespace:
                    if ((((root.NodeType == XPathNodeType.All) || (root.NodeType == XPathNodeType.Element)) || (root.NodeType == XPathNodeType.Attribute)) && (root.Prefix.Length == 0))
                    {
                        return new NamespaceQuery(query2, root.Name, root.Prefix, root.NodeType);
                    }
                    return new EmptyQuery();

                case Axis.AxisType.Parent:
                    return new ParentQuery(query2, root.Name, root.Prefix, root.NodeType);

                case Axis.AxisType.Preceding:
                    qyParent = new PrecedingQuery(query2, root.Name, root.Prefix, root.NodeType);
                    props |= Props.NonFlat;
                    return qyParent;

                case Axis.AxisType.PrecedingSibling:
                    return new PreSiblingQuery(query2, root.Name, root.Prefix, root.NodeType);

                case Axis.AxisType.Self:
                    return new XPathSelfQuery(query2, root.Name, root.Prefix, root.NodeType);

                default:
                    throw XPathException.Create("Xp_NotSupported", this.query);
            }
            props |= Props.NonFlat;
            return qyParent;
        }
コード例 #8
0
 private FollowingQuery(FollowingQuery other) : base((BaseAxisQuery) other)
 {
     this.input = Query.Clone(other.input);
     this.iterator = Query.Clone(other.iterator);
 }