Ejemplo n.º 1
0
        public async Task Create()
        {
            var toBot = this.Fixture.CreateMessage();

            toBot.Text = "create 1";

            var account     = "anaccount";
            var profile     = this.Fixture.CreateProfile();
            var teamProject = "anteamproject";

            var release = new Release();

            var target = new ReleasesDialog(this.Fixture.AuthenticationService.Object, this.Fixture.VstsService.Object)
            {
                Account     = account,
                Profile     = profile,
                TeamProject = teamProject
            };

            this.Fixture.VstsService
            .Setup(s => s.CreateReleaseAsync(account, teamProject, 1, profile.Token))
            .ReturnsAsync(release);

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

            this.Fixture.VstsService.VerifyAll();

            this.Fixture.DialogContext.Verify(c => c.PostAsync(It.IsAny <IMessageActivity>(), CancellationToken.None));
            this.Fixture.DialogContext.Verify(c => c.Done(It.IsAny <IMessageActivity>()));
        }
Ejemplo n.º 2
0
        public async Task Releases_Empty_List()
        {
            var toBot = this.Fixture.CreateMessage();

            toBot.Text = "releases";

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

            data.Profiles.Add(profile);

            this.Fixture.UserData
            .Setup(ud => ud.TryGetValue("userData", out data))
            .Returns(true);

            var releaseDefinitions = new List <ReleaseDefinition>();

            this.Fixture.VstsService
            .Setup(s => s.GetReleaseDefinitionsAsync(data.Account, data.TeamProject, profile.Token))
            .ReturnsAsync(() => releaseDefinitions);

            var target = new ReleasesDialog(this.Fixture.AuthenticationService.Object, this.Fixture.VstsService.Object);
            await target.ReleasesAsync(this.Fixture.DialogContext.Object, this.Fixture.MakeAwaitable(toBot));

            this.Fixture.VstsService.VerifyAll();

            this.Fixture.DialogContext.Verify(c => c.PostAsync(It.IsAny <IMessageActivity>(), CancellationToken.None));

            this.Fixture.DialogContext.Verify(c => c.Done(It.IsAny <IMessageActivity>()));
        }
Ejemplo n.º 3
0
        public async Task Create_No_Text()
        {
            var toBot = this.Fixture.CreateMessage();

            toBot.Text = null;

            var target = new ReleasesDialog(this.Fixture.AuthenticationService.Object, this.Fixture.VstsService.Object);
            await target.CreateAsync(this.Fixture.DialogContext.Object, this.Fixture.MakeAwaitable(toBot));

            this.Fixture.DialogContext.Verify(c => c.Fail(It.IsAny <UnknownCommandException>()));
        }
Ejemplo n.º 4
0
        public async Task Releases()
        {
            var toBot = this.Fixture.CreateMessage();

            toBot.Text = "releases";

            var account     = "anaccount";
            var profile     = this.Fixture.CreateProfile();
            var teamProject = "anteamproject";

            var releaseDefinitions = new List <ReleaseDefinition> {
                new ReleaseDefinition {
                    Id = 1
                }
            };

            this.Fixture.UserData
            .Setup(ud => ud.TryGetValue("Account", out account))
            .Returns(true);
            this.Fixture.UserData
            .Setup(ud => ud.TryGetValue("Profile", out profile))
            .Returns(true);
            this.Fixture.UserData
            .Setup(ud => ud.TryGetValue("TeamProject", out teamProject))
            .Returns(true);

            this.Fixture.VstsService
            .Setup(s => s.GetReleaseDefinitionsAsync(account, teamProject, profile.Token))
            .ReturnsAsync(() => releaseDefinitions);

            var applicationMock = new Mock <IVstsApplication>();

            applicationMock
            .Setup(application => application.AuthenticationService)
            .Returns(new Mock <IAuthenticationService>().Object);

            this.Fixture.VstsApplicationRegistry
            .Setup(registry => registry.GetVstsApplicationRegistration(It.IsAny <string>()))
            .Returns(applicationMock.Object);

            var target = new ReleasesDialog(this.Fixture.VstsService.Object, this.Fixture.VstsApplicationRegistry.Object);
            await target.ReleasesAsync(this.Fixture.DialogContext.Object, this.Fixture.MakeAwaitable(toBot));

            this.Fixture.VstsService.VerifyAll();

            this.Fixture.DialogContext.Verify(c => c.PostAsync(It.IsAny <IMessageActivity>(), CancellationToken.None));

            this.Fixture.DialogContext.Verify(c => c.Wait <IMessageActivity>(target.CreateAsync));
        }
Ejemplo n.º 5
0
        public async Task Releases_No_Text()
        {
            var toBot = this.Fixture.CreateMessage();

            toBot.Text = null;

            var applicationMock = new Mock <IVstsApplication>();

            applicationMock
            .Setup(application => application.AuthenticationService)
            .Returns(new Mock <IAuthenticationService>().Object);

            this.Fixture.VstsApplicationRegistry
            .Setup(registry => registry.GetVstsApplicationRegistration(It.IsAny <string>()))
            .Returns(applicationMock.Object);

            var target = new ReleasesDialog(this.Fixture.VstsService.Object, this.Fixture.VstsApplicationRegistry.Object);
            await target.ReleasesAsync(this.Fixture.DialogContext.Object, this.Fixture.MakeAwaitable(toBot));

            this.Fixture.DialogContext.Verify(c => c.Fail(It.IsAny <UnknownCommandException>()));
        }
Ejemplo n.º 6
0
        public async Task Releases_No_Text()
        {
            var toBot = this.Fixture.CreateMessage();

            toBot.Text = null;

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

            data.Profiles.Add(profile);

            this.Fixture.UserData
            .Setup(ud => ud.TryGetValue("userData", out data))
            .Returns(true);

            var target = new ReleasesDialog(this.Fixture.AuthenticationService.Object, this.Fixture.VstsService.Object);
            await target.ReleasesAsync(this.Fixture.DialogContext.Object, this.Fixture.MakeAwaitable(toBot));

            this.Fixture.DialogContext.Verify(c => c.Fail(It.IsAny <UnknownCommandException>()));
        }
Ejemplo n.º 7
0
        public async Task Releases_Missing_Awaitable()
        {
            var target = new ReleasesDialog(this.Fixture.AuthenticationService.Object, this.Fixture.VstsService.Object);

            await Assert.ThrowsExceptionAsync <ArgumentNullException>(async() => await target.ReleasesAsync(this.Fixture.DialogContext.Object, null));
        }
Ejemplo n.º 8
0
        public async Task Create_Missing_Context()
        {
            var target = new ReleasesDialog(this.Fixture.AuthenticationService.Object, this.Fixture.VstsService.Object);

            await Assert.ThrowsExceptionAsync <ArgumentNullException>(async() => await target.CreateAsync(null, null));
        }
Ejemplo n.º 9
0
        public async Task Releases_Missing_Context()
        {
            var target = new ReleasesDialog(this.Fixture.VstsService.Object, this.Fixture.VstsApplicationRegistry.Object);

            await Assert.ThrowsExceptionAsync <ArgumentNullException>(async() => await target.ReleasesAsync(null, null));
        }
Ejemplo n.º 10
0
        public async Task Create_Missing_Awaitable()
        {
            var target = new ReleasesDialog(this.Fixture.VstsService.Object, this.Fixture.VstsApplicationRegistry.Object);

            await Assert.ThrowsExceptionAsync <ArgumentNullException>(async() => await target.CreateAsync(this.Fixture.DialogContext.Object, null));
        }