Example #1
0
        public void ProcessStopWebsiteTest()
        {
            const string websiteName = "website1";

            // Setup
            Mock <IWebsitesClient> websitesClientMock = new Mock <IWebsitesClient>();

            websitesClientMock.Setup(f => f.StopAzureWebsite(websiteName));

            // Test
            StopAzureWebsiteCommand stopAzureWebsiteCommand = new StopAzureWebsiteCommand()
            {
                ShareChannel        = true,
                CommandRuntime      = new MockCommandRuntime(),
                Name                = websiteName,
                CurrentSubscription = new SubscriptionData {
                    SubscriptionId = base.subscriptionId
                },
                WebsitesClient = websitesClientMock.Object
            };

            stopAzureWebsiteCommand.ExecuteCmdlet();

            websitesClientMock.Verify(f => f.StopAzureWebsite(websiteName), Times.Once());
        }
        public void StopsWebsiteSlot()
        {
            const string slot        = "staging";
            const string websiteName = "website1";

            // Setup
            Mock <IWebsitesClient> websitesClientMock = new Mock <IWebsitesClient>();

            websitesClientMock.Setup(f => f.StopWebsite(websiteName, slot));

            // Test
            StopAzureWebsiteCommand stopAzureWebsiteCommand = new StopAzureWebsiteCommand()
            {
                CommandRuntime      = new MockCommandRuntime(),
                Name                = websiteName,
                CurrentSubscription = new WindowsAzureSubscription {
                    SubscriptionId = base.subscriptionId
                },
                WebsitesClient = websitesClientMock.Object,
                Slot           = slot
            };

            stopAzureWebsiteCommand.ExecuteCmdlet();

            websitesClientMock.Verify(f => f.StopWebsite(websiteName, slot), Times.Once());
        }
Example #3
0
        public void StopsWebsiteSlot()
        {
            const string slot        = "staging";
            const string websiteName = "website1";

            // Setup
            Mock <IWebsitesClient> websitesClientMock = new Mock <IWebsitesClient>();

            websitesClientMock.Setup(f => f.StopWebsite(websiteName, slot));

            // Test
            StopAzureWebsiteCommand stopAzureWebsiteCommand = new StopAzureWebsiteCommand()
            {
                CommandRuntime = new MockCommandRuntime(),
                Name           = websiteName,
                WebsitesClient = websitesClientMock.Object,
                Slot           = slot
            };

            AzureSession.SetCurrentContext(new AzureSubscription {
                Id = new Guid(base.subscriptionId)
            }, null, null);

            stopAzureWebsiteCommand.ExecuteCmdlet();

            websitesClientMock.Verify(f => f.StopWebsite(websiteName, slot), Times.Once());
        }
        public void ProcessStopWebsiteTest()
        {
            const string websiteName = "website1";
            const string webspaceName = "webspace";

            // Setup
            bool updated = true;
            SimpleWebsitesManagement channel = new SimpleWebsitesManagement();
            channel.GetWebSpacesThunk = ar => new WebSpaces(new List<WebSpace> { new WebSpace { Name = webspaceName } });
            channel.GetSitesThunk = ar => new Sites(new List<Site> { new Site { Name = websiteName, WebSpace = webspaceName } });

            channel.UpdateSiteThunk = ar =>
            {
                Assert.AreEqual(webspaceName, ar.Values["webspaceName"]);
                Site website = ar.Values["site"] as Site;
                Assert.IsNotNull(website);
                Assert.AreEqual(websiteName, website.Name);
                Assert.IsNotNull(website.HostNames.FirstOrDefault(hostname => hostname.Equals(websiteName + General.AzureWebsiteHostNameSuffix)));
                Assert.AreEqual(website.State, "Stopped");
                updated = true;
            };

            // Test
            StopAzureWebsiteCommand stopAzureWebsiteCommand = new StopAzureWebsiteCommand(channel)
            {
                ShareChannel = true,
                CommandRuntime = new MockCommandRuntime(),
                Name = websiteName,
                CurrentSubscription = new SubscriptionData { SubscriptionId = "StopAzureWebSiteTests_ProcessStopWebsiteTest" }
            };

            stopAzureWebsiteCommand.ExecuteCommand();
            Assert.IsTrue(updated);
        }
Example #5
0
        public void StopsWebsiteSlot()
        {
            const string slot        = "staging";
            const string websiteName = "website1";

            // Setup
            Mock <IWebsitesClient> websitesClientMock = new Mock <IWebsitesClient>();

            websitesClientMock.Setup(f => f.StopWebsite(websiteName, slot));

            // Test
            StopAzureWebsiteCommand stopAzureWebsiteCommand = new StopAzureWebsiteCommand()
            {
                CommandRuntime = new MockCommandRuntime(),
                Name           = websiteName,
                WebsitesClient = websitesClientMock.Object,
                Slot           = slot
            };

            currentProfile = new AzureSMProfile();
            var subscription = new AzureSubscription {
                Id = new Guid(base.subscriptionId)
            };

            subscription.Properties[AzureSubscription.Property.Default] = "True";
            currentProfile.Subscriptions[new Guid(base.subscriptionId)] = subscription;

            stopAzureWebsiteCommand.ExecuteCmdlet();

            websitesClientMock.Verify(f => f.StopWebsite(websiteName, slot), Times.Once());
        }
        public void ProcessStopWebsiteTest()
        {
            const string websiteName = "website1";

            // Setup
            Mock <IWebsitesClient> websitesClientMock = new Mock <IWebsitesClient>();

            websitesClientMock.Setup(f => f.StopWebsite(websiteName, null));

            // Test
            StopAzureWebsiteCommand stopAzureWebsiteCommand = new StopAzureWebsiteCommand()
            {
                CommandRuntime = new MockCommandRuntime(),
                Name           = websiteName,
                WebsitesClient = websitesClientMock.Object
            };

            currentProfile = new AzureSMProfile();
            var subscription = new AzureSubscription {
                Id = base.subscriptionId
            };

            subscription.SetDefault();
            currentProfile.SubscriptionTable[new Guid(base.subscriptionId)] = subscription;

            stopAzureWebsiteCommand.ExecuteCmdlet();

            websitesClientMock.Verify(f => f.StopWebsite(websiteName, null), Times.Once());
        }
        public void ProcessStopWebsiteTest()
        {
            const string websiteName = "website1";

            // Setup
            Mock<IWebsitesClient> websitesClientMock = new Mock<IWebsitesClient>();
            websitesClientMock.Setup(f => f.StopWebsite(websiteName, null));

            // Test
            StopAzureWebsiteCommand stopAzureWebsiteCommand = new StopAzureWebsiteCommand()
            {
                CommandRuntime = new MockCommandRuntime(),
                Name = websiteName,
                CurrentSubscription = new WindowsAzureSubscription { SubscriptionId = base.subscriptionId },
                WebsitesClient = websitesClientMock.Object
            };

            stopAzureWebsiteCommand.ExecuteCmdlet();

            websitesClientMock.Verify(f => f.StopWebsite(websiteName, null), Times.Once());
        }