public void GetAzureWebsiteDeploymentLogsTest() { // Setup SimpleWebsitesManagement channel = new SimpleWebsitesManagement(); channel.GetWebSpacesThunk = ar => new WebSpaces(new List<WebSpace> { new WebSpace { Name = "webspace1" }, new WebSpace { Name = "webspace2" } }); channel.GetSitesThunk = ar => { if (ar.Values["webspaceName"].Equals("webspace1")) { return new Sites(new List<Site> { new Site { Name = "website1", WebSpace = "webspace1", SiteProperties = new SiteProperties { Properties = new List<NameValuePair> { new NameValuePair { Name = "repositoryuri", Value = "http" }, new NameValuePair { Name = "PublishingUsername", Value = "user1" }, new NameValuePair { Name = "PublishingPassword", Value = "password1" } } }} }); } return new Sites(new List<Site> { new Site { Name = "website2", WebSpace = "webspace2" } }); }; SimpleDeploymentServiceManagement deploymentChannel = new SimpleDeploymentServiceManagement(); deploymentChannel.GetDeploymentsThunk = ar => new List<DeployResult> { new DeployResult { Id = "commit1" }, new DeployResult { Id = "commit2" } }; deploymentChannel.GetDeploymentLogsThunk = ar => { if (ar.Values["commitId"].Equals("commit1")) { return new List<LogEntry> { new LogEntry { Id = "log1" }, new LogEntry { Id = "log2" } }; } return new List<LogEntry>(); }; // Test GetAzureWebsiteDeploymentCommand getAzureWebsiteDeploymentCommand = new GetAzureWebsiteDeploymentCommand(channel, deploymentChannel) { Name = "website1", ShareChannel = true, Details = true, CommandRuntime = new MockCommandRuntime(), CurrentSubscription = new SubscriptionData { SubscriptionId = base.subscriptionName } }; getAzureWebsiteDeploymentCommand.ExecuteCmdlet(); Assert.AreEqual(1, ((MockCommandRuntime)getAzureWebsiteDeploymentCommand.CommandRuntime).OutputPipeline.Count); var deployments = (IEnumerable<DeployResult>)((MockCommandRuntime)getAzureWebsiteDeploymentCommand.CommandRuntime).OutputPipeline.FirstOrDefault(); Assert.IsNotNull(deployments); Assert.AreEqual(2, deployments.Count()); Assert.IsNotNull(deployments.First(d => d.Id.Equals("commit1")).Logs); }
public void GetAzureWebsiteDeploymentTest() { // Setup var clientMock = new Mock<IWebsitesClient>(); var site1 = new Site { Name = "website1", WebSpace = "webspace1", SiteProperties = new SiteProperties { Properties = new List<NameValuePair> { new NameValuePair {Name = "repositoryuri", Value = "http"}, new NameValuePair {Name = "PublishingUsername", Value = "user1"}, new NameValuePair {Name = "PublishingPassword", Value = "password1"} } } }; clientMock.Setup(c => c.GetWebsite("website1", null)) .Returns(site1); clientMock.Setup(c => c.ListWebSpaces()) .Returns(new[] { new WebSpace { Name = "webspace1" }, new WebSpace { Name = "webspace2" } }); clientMock.Setup(c => c.ListSitesInWebSpace("webspace1")) .Returns(new[] { site1 }); clientMock.Setup(c => c.ListSitesInWebSpace("webspace2")) .Returns(new[] { new Site { Name = "website2", WebSpace = "webspace2" } }); SimpleDeploymentServiceManagement deploymentChannel = new SimpleDeploymentServiceManagement(); deploymentChannel.GetDeploymentsThunk = ar => new List<DeployResult> { new DeployResult(), new DeployResult() }; // Test GetAzureWebsiteDeploymentCommand getAzureWebsiteDeploymentCommand = new GetAzureWebsiteDeploymentCommand(deploymentChannel) { Name = "website1", ShareChannel = true, WebsitesClient = clientMock.Object, CommandRuntime = new MockCommandRuntime(), CurrentSubscription = new WindowsAzureSubscription { SubscriptionId = base.subscriptionId } }; getAzureWebsiteDeploymentCommand.ExecuteCmdlet(); Assert.AreEqual(1, ((MockCommandRuntime)getAzureWebsiteDeploymentCommand.CommandRuntime).OutputPipeline.Count); var deployments = (IEnumerable<DeployResult>)((MockCommandRuntime)getAzureWebsiteDeploymentCommand.CommandRuntime).OutputPipeline.FirstOrDefault(); Assert.IsNotNull(deployments); Assert.AreEqual(2, deployments.Count()); }
public void GetAzureWebsiteDeploymentTest() { // Setup var clientMock = new Mock <IWebsitesClient>(); var site1 = new Site { Name = "website1", WebSpace = "webspace1", SiteProperties = new SiteProperties { Properties = new List <NameValuePair> { new NameValuePair { Name = "repositoryuri", Value = "http" }, new NameValuePair { Name = "PublishingUsername", Value = "user1" }, new NameValuePair { Name = "PublishingPassword", Value = "password1" } } } }; clientMock.Setup(c => c.GetWebsite("website1", null)) .Returns(site1); clientMock.Setup(c => c.ListWebSpaces()) .Returns(new[] { new WebSpace { Name = "webspace1" }, new WebSpace { Name = "webspace2" } }); clientMock.Setup(c => c.ListSitesInWebSpace("webspace1")) .Returns(new[] { site1 }); clientMock.Setup(c => c.ListSitesInWebSpace("webspace2")) .Returns(new[] { new Site { Name = "website2", WebSpace = "webspace2" } }); SimpleDeploymentServiceManagement deploymentChannel = new SimpleDeploymentServiceManagement(); deploymentChannel.GetDeploymentsThunk = ar => new List <DeployResult> { new DeployResult(), new DeployResult() }; // Test GetAzureWebsiteDeploymentCommand getAzureWebsiteDeploymentCommand = new GetAzureWebsiteDeploymentCommand(deploymentChannel) { Name = "website1", ShareChannel = true, WebsitesClient = clientMock.Object, CommandRuntime = new MockCommandRuntime(), CurrentSubscription = new WindowsAzureSubscription { SubscriptionId = base.subscriptionId } }; getAzureWebsiteDeploymentCommand.ExecuteCmdlet(); Assert.AreEqual(1, ((MockCommandRuntime)getAzureWebsiteDeploymentCommand.CommandRuntime).OutputPipeline.Count); var deployments = (IEnumerable <DeployResult>)((MockCommandRuntime)getAzureWebsiteDeploymentCommand.CommandRuntime).OutputPipeline.FirstOrDefault(); Assert.IsNotNull(deployments); Assert.AreEqual(2, deployments.Count()); }
public void GetAzureWebsiteDeploymentTest() { // Setup var clientMock = new Mock <IWebsitesClient>(); var site1 = new Site { Name = "website1", WebSpace = "webspace1", SiteProperties = new SiteProperties { Properties = new List <NameValuePair> { new NameValuePair { Name = "repositoryuri", Value = "http" }, new NameValuePair { Name = "PublishingUsername", Value = "user1" }, new NameValuePair { Name = "PublishingPassword", Value = "password1" } } } }; clientMock.Setup(c => c.GetWebsite("website1", null)) .Returns(site1); clientMock.Setup(c => c.ListWebSpaces()) .Returns(new[] { new WebSpace { Name = "webspace1" }, new WebSpace { Name = "webspace2" } }); clientMock.Setup(c => c.ListSitesInWebSpace("webspace1")) .Returns(new[] { site1 }); clientMock.Setup(c => c.ListSitesInWebSpace("webspace2")) .Returns(new[] { new Site { Name = "website2", WebSpace = "webspace2" } }); SimpleDeploymentServiceManagement deploymentChannel = new SimpleDeploymentServiceManagement(); deploymentChannel.GetDeploymentsThunk = ar => new List <DeployResult> { new DeployResult(), new DeployResult() }; // Test GetAzureWebsiteDeploymentCommand getAzureWebsiteDeploymentCommand = new GetAzureWebsiteDeploymentCommand(deploymentChannel) { Name = "website1", ShareChannel = true, WebsitesClient = clientMock.Object, CommandRuntime = new MockCommandRuntime(), }; currentProfile = new AzureProfile(); var subscription = new AzureSubscription { Id = new Guid(subscriptionId) }; subscription.Properties[AzureSubscription.Property.Default] = "True"; currentProfile.Subscriptions[new Guid(subscriptionId)] = subscription; getAzureWebsiteDeploymentCommand.ExecuteCmdlet(); var deployments = System.Management.Automation.LanguagePrimitives.GetEnumerable(((MockCommandRuntime)getAzureWebsiteDeploymentCommand.CommandRuntime).OutputPipeline).Cast <DeployResult>(); Assert.NotNull(deployments); Assert.Equal(2, deployments.Count()); }
public void GetAzureWebsiteDeploymentLogsTest() { // Setup var clientMock = new Mock <IWebsitesClient>(); var site1 = new Site { Name = "website1", WebSpace = "webspace1", SiteProperties = new SiteProperties { Properties = new List <NameValuePair> { new NameValuePair { Name = "repositoryuri", Value = "http" }, new NameValuePair { Name = "PublishingUsername", Value = "user1" }, new NameValuePair { Name = "PublishingPassword", Value = "password1" } } } }; clientMock.Setup(c => c.ListWebSpaces()) .Returns(new[] { new WebSpace { Name = "webspace1" }, new WebSpace { Name = "webspace2" } }); clientMock.Setup(c => c.GetWebsite("website1", null)).Returns(site1); SimpleDeploymentServiceManagement deploymentChannel = new SimpleDeploymentServiceManagement(); deploymentChannel.GetDeploymentsThunk = ar => new List <DeployResult> { new DeployResult { Id = "commit1" }, new DeployResult { Id = "commit2" } }; deploymentChannel.GetDeploymentLogsThunk = ar => { if (ar.Values["commitId"].Equals("commit1")) { return(new List <LogEntry> { new LogEntry { Id = "log1" }, new LogEntry { Id = "log2" } }); } return(new List <LogEntry>()); }; // Test GetAzureWebsiteDeploymentCommand getAzureWebsiteDeploymentCommand = new GetAzureWebsiteDeploymentCommand(deploymentChannel) { Name = "website1", ShareChannel = true, WebsitesClient = clientMock.Object, Details = true, CommandRuntime = new MockCommandRuntime(), }; currentProfile = new AzureProfile(); var subscription = new AzureSubscription { Id = new Guid(subscriptionId) }; subscription.Properties[AzureSubscription.Property.Default] = "True"; currentProfile.Subscriptions[new Guid(subscriptionId)] = subscription; getAzureWebsiteDeploymentCommand.ExecuteCmdlet(); Assert.Equal(1, ((MockCommandRuntime)getAzureWebsiteDeploymentCommand.CommandRuntime).OutputPipeline.Count); var deployments = (IEnumerable <DeployResult>)((MockCommandRuntime)getAzureWebsiteDeploymentCommand.CommandRuntime).OutputPipeline.FirstOrDefault(); Assert.NotNull(deployments); Assert.Equal(2, deployments.Count()); Assert.NotNull(deployments.First(d => d.Id.Equals("commit1")).Logs); }
public void GetAzureWebsiteDeploymentTest() { // Setup SimpleWebsitesManagement channel = new SimpleWebsitesManagement(); channel.GetWebSpacesThunk = ar => new WebSpaces(new List <WebSpace> { new WebSpace { Name = "webspace1" }, new WebSpace { Name = "webspace2" } }); channel.GetSitesThunk = ar => { if (ar.Values["webspaceName"].Equals("webspace1")) { return(new Sites(new List <Site> { new Site { Name = "website1", WebSpace = "webspace1", SiteProperties = new SiteProperties { Properties = new List <NameValuePair> { new NameValuePair { Name = "repositoryuri", Value = "http" }, new NameValuePair { Name = "PublishingUsername", Value = "user1" }, new NameValuePair { Name = "PublishingPassword", Value = "password1" } } } } })); } return(new Sites(new List <Site> { new Site { Name = "website2", WebSpace = "webspace2" } })); }; SimpleDeploymentServiceManagement deploymentChannel = new SimpleDeploymentServiceManagement(); deploymentChannel.GetDeploymentsThunk = ar => new List <DeployResult> { new DeployResult(), new DeployResult() }; // Test GetAzureWebsiteDeploymentCommand getAzureWebsiteDeploymentCommand = new GetAzureWebsiteDeploymentCommand(channel, deploymentChannel) { Name = "website1", ShareChannel = true, CommandRuntime = new MockCommandRuntime(), CurrentSubscription = new SubscriptionData { SubscriptionId = base.subscriptionId } }; getAzureWebsiteDeploymentCommand.ExecuteCmdlet(); Assert.AreEqual(1, ((MockCommandRuntime)getAzureWebsiteDeploymentCommand.CommandRuntime).OutputPipeline.Count); var deployments = (IEnumerable <DeployResult>)((MockCommandRuntime)getAzureWebsiteDeploymentCommand.CommandRuntime).OutputPipeline.FirstOrDefault(); Assert.IsNotNull(deployments); Assert.AreEqual(2, deployments.Count()); }
public void GetAzureWebsiteDeploymentTest() { // Setup SimpleWebsitesManagement channel = new SimpleWebsitesManagement(); channel.GetWebSpacesThunk = ar => new WebSpaces(new List<WebSpace> { new WebSpace { Name = "webspace1" }, new WebSpace { Name = "webspace2" } }); channel.GetSitesThunk = ar => { if (ar.Values["webspaceName"].Equals("webspace1")) { return new Sites(new List<Site> { new Site { Name = "website1", WebSpace = "webspace1", SiteProperties = new SiteProperties { Properties = new List<NameValuePair> { new NameValuePair { Name = "repositoryuri", Value = "http" }, new NameValuePair { Name = "PublishingUsername", Value = "user1" }, new NameValuePair { Name = "PublishingPassword", Value = "password1" } } }} }); } return new Sites(new List<Site> { new Site { Name = "website2", WebSpace = "webspace2" } }); }; SimpleDeploymentServiceManagement deploymentChannel = new SimpleDeploymentServiceManagement(); deploymentChannel.GetDeploymentsThunk = ar => new List<DeployResult> { new DeployResult(), new DeployResult() }; // Test GetAzureWebsiteDeploymentCommand getAzureWebsiteDeploymentCommand = new GetAzureWebsiteDeploymentCommand(channel, deploymentChannel) { Name = "website1", ShareChannel = true, CommandRuntime = new MockCommandRuntime(), CurrentSubscription = new SubscriptionData { SubscriptionId = "GetAzureWebsiteDeploymentTests_GetAzureWebsiteDeploymentTest" } }; getAzureWebsiteDeploymentCommand.ExecuteCommand(); Assert.AreEqual(1, ((MockCommandRuntime)getAzureWebsiteDeploymentCommand.CommandRuntime).WrittenObjects.Count); var deployments = (IEnumerable<DeployResult>)((MockCommandRuntime)getAzureWebsiteDeploymentCommand.CommandRuntime).WrittenObjects.FirstOrDefault(); Assert.IsNotNull(deployments); Assert.AreEqual(2, deployments.Count()); }