protected Give_only_other_users_have_subscriptions()
 {
     LabelSubscription.SetUserSubscription(RepoOwner, RepoName, OtherUser, "Bug");
     LabelSubscription.SetUserSubscription(RepoOwner, RepoName, OtherUser, "Wonder");
     LabelSubscription.SetUserSubscription(RepoOwner, RepoName, AnotherUser, "Bug");
     LabelSubscription.SetUserSubscription(RepoOwner, RepoName, AnotherUser, "Invalid");
 }
        public void add_null_label()
        {
            Func <Task> act = async() => await LabelSubscription.SetUserSubscription(RepoOwner, RepoName, UserId, null !);

            act.Should().Throw <ArgumentNullException>()
            .WithMessage("*label*");
        }
        public void anonymously_add_labels()
        {
            Func <Task> act = async() => await LabelSubscription.SetUserSubscriptions(RepoOwner, RepoName, null !, new[] { "Bug", "Wonder" });

            act.Should().Throw <ArgumentNullException>()
            .WithMessage("*userId*");
        }
        public async Task get_empty_list_of_labels()
        {
            // act
            IEnumerable <LabelSubscriptionModel> list = await LabelSubscription.GetUserSubscriptions(RepoOwner, RepoName, UserId);

            list.Should().NotBeNull().And.BeEmpty();
        }
 public Given_no_issue_labeled()
 {
     UserLabelRepository = Substitute.For <InMemoryLabelSubscriptionRepository>();
     IssueSubscriber     = Substitute.For <IIssueSubscriber>();
     IssueQuery          = Substitute.For <IIssueQuery>();
     IssueSubscription   = new IssueSubscription(new InMemoryIssueLabelRepository(), UserLabelRepository, IssueSubscriber);
     LabelSubscription   = new LabelSubscription(UserLabelRepository, IssueSubscriber, IssueQuery);
 }
        public async Task subscribe_already_subscribed_user()
        {
            await LabelSubscription.SetUserSubscription(RepositoryOwner, RepositoryName, "userX", Label);

            IssueSubscriber.ClearReceivedCalls();
            await IssueSubscription.TryAddLabel(Issue, Label, ToBeLabeledAt);

            //assert
            await IssueSubscriber.ReceivedWithAnyArgs().SubscribeToIssue(default !, default !);
示例#7
0
        public void can_subscribe(string label)
        {
            var sub = new LabelSubscription();
            Action <Message> callback = msg => { };

            sub.Subscribe(label, callback);
            var actual = sub.Subscribers(label);

            Assert.AreEqual(callback, actual);
        }
        public async Task add_label_then_list_it()
        {
            // act
            await LabelSubscription.SetUserSubscription(RepoOwner, RepoName, UserId, "Bug");

            IEnumerable <LabelSubscriptionModel> list = await LabelSubscription.GetUserSubscriptions(RepoOwner, RepoName, UserId);

            list.Should().NotBeNull()
            .And.Contain(o => o.Label == "Bug" && o.UserId == UserId);
        }
        public async Task add_labels()
        {
            // act
            IEnumerable <LabelSubscriptionModel> list = await LabelSubscription.SetUserSubscriptions(RepoOwner, RepoName, UserId, new [] { "Bug", "Wonder" });

            list.Should().NotBeNull()
            .And.HaveCount(2)
            .And.Contain(o => o.Label == "Bug" && o.UserId == UserId)
            .And.Contain(o => o.Label == "Wonder" && o.UserId == UserId);
        }
示例#10
0
        public void can_unsubscribe()
        {
            var sub = new LabelSubscription();
            Action <Message> callback = msg => { };
            var unsub = sub.Subscribe("fred", callback);

            unsub.Dispose();
            var actual = sub.Subscribers("fred");

            Assert.IsNull(actual);
        }
示例#11
0
        public void an_error_in_the_callback_does_not_propergate_to_the_caller()
        {
            var sub = new LabelSubscription();
            Action <Message> callback = msg => { throw new InvalidOperationException(); };

            sub.Subscribe("hello", callback);
            var expected = new Message {
                Label = "hello"
            };

            sub.Dispatch(expected);
            Assert.Pass();
        }
示例#12
0
        public void can_dispatch(string subscriptionLabel, string msgLabel)
        {
            var              sub      = new LabelSubscription();
            Message          actual   = null;
            Action <Message> callback = msg => actual = msg;

            sub.Subscribe(subscriptionLabel, callback);
            var expected = new Message {
                Label = msgLabel
            };

            sub.Dispatch(expected);
            Assert.AreEqual(expected, actual);
        }
示例#13
0
        public void can_subscribe_multiple_times()
        {
            var sub = new LabelSubscription();
            Action <Message> callback1 = msg => { };
            Action <Message> callback2 = msg => { };

            sub.Subscribe("fred", callback1);
            sub.Subscribe("fred", callback2);
            var actual        = sub.Subscribers("fred");
            var subscriptions = actual.GetInvocationList();

            Assert.IsTrue(Array.IndexOf(subscriptions, callback1) >= 0);
            Assert.IsTrue(Array.IndexOf(subscriptions, callback2) >= 0);
        }
示例#14
0
        public void an_error_in_a_callback_does_not_prevent_other_callbacks_from_being_called()
        {
            var              sub       = new LabelSubscription();
            bool             got       = false;
            Action <Message> callback1 = msg => { throw new InvalidOperationException(); };
            Action <Message> callback2 = msg => { got = true; };

            sub.Subscribe("hello", callback1);
            sub.Subscribe("hello", callback2);
            var expected = new Message {
                Label = "hello"
            };

            sub.Dispatch(expected);
            Assert.AreEqual(true, got);
        }
        public async Task add_label()
        {
            LabelSubscriptionModel inserted = await LabelSubscription.SetUserSubscription(RepoOwner, RepoName, UserId, "Bug");

            inserted.Should().Match <LabelSubscriptionModel>(l => l.Label == "Bug" && l.UserId == UserId);
        }
 public void add_any_null_label()
 {
     Func <Task> act = async() => await LabelSubscription.SetUserSubscriptions(RepoOwner, RepoName, UserId, new[] { "Bug", null ! });
 protected Given_no_label_subscription()
 {
     IssueSubscriber   = Substitute.For <IIssueSubscriber>();
     IssueQuery        = Substitute.For <IIssueQuery>();
     LabelSubscription = new LabelSubscription(new InMemoryLabelSubscriptionRepository(), IssueSubscriber, IssueQuery);
 }
 protected Given_user_have_subscriptions()
 {
     LabelSubscription.SetUserSubscription(RepoOwner, RepoName, UserId, "Bug");
     LabelSubscription.SetUserSubscription(RepoOwner, RepoName, UserId, "Wonder");
     LabelSubscription.SetUserSubscription(RepoOwner, RepoName, UserId, "Invalid");
 }