Exemplo n.º 1
0
        public async Task Subscriptions()
        {
            var strategies = new List <ISubscriptionStrategy>();

            var toBot = this.Fixture.CreateMessage();

            toBot.Text = "subscriptions";

            var profile = this.Fixture.CreateProfile();
            var data    = new UserData {
                Account = "anaccount", TeamProject = "anteamproject"
            };

            data.Profiles.Add(profile);

            var subscription  = new Subscription();
            var subscriptions = new List <Subscription> {
                subscription
            };

            var target = new SubscriptionsDialog(this.Fixture.AuthenticationService.Object, this.Fixture.DocumentClient.Object, strategies, this.Fixture.VstsService.Object);

            this.Fixture.UserData
            .Setup(ud => ud.TryGetValue("userData", out data))
            .Returns(true);
            this.Fixture.DocumentClient
            .Setup(dc => dc.CreateDocumentQuery <Subscription>(It.IsAny <Uri>(), null))
            .Returns(subscriptions.AsQueryable().OrderBy(s => s.Id));

            await target.SubscriptionsAsync(this.Fixture.DialogContext.Object, this.Fixture.MakeAwaitable(toBot));

            this.Fixture.DialogContext.Verify(c => c.PostAsync(It.IsAny <IMessageActivity>(), CancellationToken.None));
            this.Fixture.DialogContext.Verify(c => c.Wait <IMessageActivity>(target.SubscribeAsync));
        }
Exemplo n.º 2
0
        public async Task Subscriptions_No_Text()
        {
            var strategies = new List <ISubscriptionStrategy>();

            var toBot = this.Fixture.CreateMessage();

            toBot.Text = null;

            var target = new SubscriptionsDialog(this.Fixture.AuthenticationService.Object, this.Fixture.DocumentClient.Object, strategies, this.Fixture.VstsService.Object);

            await target.SubscriptionsAsync(this.Fixture.DialogContext.Object, this.Fixture.MakeAwaitable(toBot));

            this.Fixture.DialogContext.Verify(c => c.Fail(It.IsAny <UnknownCommandException>()));
        }
Exemplo n.º 3
0
        public async Task Builds_Missing_Context()
        {
            var strategies = new List <ISubscriptionStrategy>();

            var target = new SubscriptionsDialog(this.Fixture.AuthenticationService.Object, this.Fixture.DocumentClient.Object, strategies, this.Fixture.VstsService.Object);

            await Assert.ThrowsExceptionAsync <ArgumentNullException>(async() => await target.SubscriptionsAsync(null, null));
        }