Пример #1
0
        public void CallsTheUserPostMethod()
        {
            var user = new Mock <IUser>();

            sut.Handle(user.Object, "a b");

            user.Verify(it => it.Post("a b"));
        }
Пример #2
0
        public async Task Notify_When_Text_Invalid()
        {
            var invalidCommand = new NewQuestionCommand {
                Text = "Iae?", User = "******"
            };

            var result = await _handler.Handle(invalidCommand);

            var notifications = (List <string>)result.Data;
            var notificationWithTextMinChar = notifications.Where(n => n == Message.PostTextMinChar).Any();

            Assert.True(notificationWithTextMinChar);
        }
Пример #3
0
        /// <summary>
        /// Ported from handle_value
        /// </summary>
        public static void HandleValue(Value value, Account account, Xact xact, Temporaries temps, PostHandler handler,
                                       Date date        = default(Date), bool actDateP = true, Value total = null, bool directAmount = false,
                                       bool markVisited = false, bool bidirLink        = true)
        {
            Post post = temps.CreatePost(xact, account, bidirLink);

            post.Flags |= SupportsFlagsEnum.ITEM_GENERATED;

            // If the account for this post is all virtual, then report the post as
            // such.  This allows subtotal reports to show "(Account)" for accounts
            // that contain only virtual posts.
            if (account != null && account.HasXData && account.XData.AutoVirtualize)
            {
                if (!account.XData.HasNonVirtuals)
                {
                    post.Flags |= SupportsFlagsEnum.POST_VIRTUAL;
                    if (!account.XData.HasUnbVirtuals)
                    {
                        post.Flags |= SupportsFlagsEnum.POST_MUST_BALANCE;
                    }
                }
            }

            PostXData xdata = post.XData;

            if (date.IsValid())
            {
                if (actDateP)
                {
                    xdata.Date = date;
                }
                else
                {
                    xdata.ValueDate = date;
                }
            }

            Value temp = Value.Clone(value);

            switch (value.Type)
            {
            case ValueTypeEnum.Boolean:
            case ValueTypeEnum.Integer:
                temp.InPlaceCast(ValueTypeEnum.Amount);
                post.Amount = temp.AsAmount;
                break;

            case ValueTypeEnum.Amount:
                post.Amount = temp.AsAmount;
                break;

            case ValueTypeEnum.Balance:
            case ValueTypeEnum.Sequence:
                xdata.CompoundValue = temp;
                xdata.Compound      = true;
                break;

            default:
                throw new InvalidOperationException();
            }

            if (!Value.IsNullOrEmpty(total))
            {
                xdata.Total = total;
            }

            if (directAmount)
            {
                xdata.DirectAmt = true;
            }

            Logger.Current.Debug("filters.changed_value.rounding", () => String.Format("post.amount = {0}", post.Amount));

            handler.Handle(post);

            if (markVisited)
            {
                post.XData.Visited         = true;
                post.Account.XData.Visited = true;
            }
        }