Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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<IWebsitesClient>();

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<ICommandRuntime>();

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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
{
Expand Down