diff --git a/src/ServiceManagement/Services/Commands.Test/Websites/PublishAzureWebsiteProjectTests.cs b/src/ServiceManagement/Services/Commands.Test/Websites/PublishAzureWebsiteProjectTests.cs index ae55bd36cbfa..f67f8dad20f0 100644 --- a/src/ServiceManagement/Services/Commands.Test/Websites/PublishAzureWebsiteProjectTests.cs +++ b/src/ServiceManagement/Services/Commands.Test/Websites/PublishAzureWebsiteProjectTests.cs @@ -1,21 +1,72 @@ -using System.Collections; -using System.IO; +using System; +using System.Collections; using System.Management.Automation; +using Microsoft.WindowsAzure.Commands.ScenarioTest; using Microsoft.WindowsAzure.Commands.Test.Utilities.Common; using Microsoft.WindowsAzure.Commands.Test.Utilities.Websites; +using Microsoft.WindowsAzure.Commands.Utilities.Common; using Microsoft.WindowsAzure.Commands.Utilities.Websites; using Microsoft.WindowsAzure.Commands.Websites; using Microsoft.WindowsAzure.Management.WebSites.Models; using Moq; -using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; -using System; -using Microsoft.WindowsAzure.Commands.Utilities.Common; namespace Microsoft.WindowsAzure.Commands.Test.Websites { public class PublishAzureWebsiteProjectTests : WebsitesTestBase { + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void PublishFromPackageWithoutSetParameters() + { + const string websiteName = "test-site"; + const string package = "test-package"; + string slot = null; + var connectionStrings = new Hashtable(); + connectionStrings["DefaultConnection"] = "test-connection-string"; + + var publishProfile = new WebSiteGetPublishProfileResponse.PublishProfile + { + UserName = "test-user-name", + UserPassword = "test-password", + PublishUrl = "test-publish-url" + }; + + var published = false; + + var clientMock = new Mock(); + + clientMock.Setup(c => c.GetWebDeployPublishProfile(websiteName, slot)).Returns(publishProfile); + clientMock.Setup(c => c.PublishWebProject(websiteName, slot, package, null, connectionStrings, false, false)) + .Callback((string n, string s, string p, string spf, Hashtable cs, bool skipAppData, bool doNotDelete) => + { + Assert.Equal(websiteName, n); + Assert.Equal(slot, s); + Assert.Equal(package, p); + Assert.Equal(connectionStrings, cs); + Assert.False(skipAppData); + Assert.False(doNotDelete); + published = true; + }); + + var powerShellMock = new Mock(); + + var command = new PublishAzureWebsiteProject + { + CommandRuntime = powerShellMock.Object, + Name = websiteName, + Package = package, + ConnectionString = connectionStrings, + WebsitesClient = clientMock.Object, + SetParametersFile = null + }; + + command.ExecuteCmdlet(); + + powerShellMock.Verify(f => f.WriteVerbose(string.Format("[Complete] Publishing package {0}", package)), Times.Once()); + Assert.True(published); + } + [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void PublishFromPackage() diff --git a/src/ServiceManagement/Services/Commands/Websites/PublishAzureWebsiteProject.cs b/src/ServiceManagement/Services/Commands/Websites/PublishAzureWebsiteProject.cs index a5419a8cb135..2c800af44af8 100644 --- a/src/ServiceManagement/Services/Commands/Websites/PublishAzureWebsiteProject.cs +++ b/src/ServiceManagement/Services/Commands/Websites/PublishAzureWebsiteProject.cs @@ -87,7 +87,7 @@ public override void ExecuteCmdlet() } } - if (!File.Exists(fullSetParametersFile)) + if (!string.IsNullOrEmpty(fullSetParametersFile) && !File.Exists(fullSetParametersFile)) { if (File.Exists(Path.Combine(Path.GetDirectoryName(fullPackage), fullSetParametersFile))) {