|
1 |
| -using System.Collections; |
2 |
| -using System.IO; |
| 1 | +using System; |
| 2 | +using System.Collections; |
3 | 3 | using System.Management.Automation;
|
| 4 | +using Microsoft.WindowsAzure.Commands.ScenarioTest; |
4 | 5 | using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
|
5 | 6 | using Microsoft.WindowsAzure.Commands.Test.Utilities.Websites;
|
| 7 | +using Microsoft.WindowsAzure.Commands.Utilities.Common; |
6 | 8 | using Microsoft.WindowsAzure.Commands.Utilities.Websites;
|
7 | 9 | using Microsoft.WindowsAzure.Commands.Websites;
|
8 | 10 | using Microsoft.WindowsAzure.Management.WebSites.Models;
|
9 | 11 | using Moq;
|
10 |
| -using Microsoft.WindowsAzure.Commands.ScenarioTest; |
11 | 12 | using Xunit;
|
12 |
| -using System; |
13 |
| -using Microsoft.WindowsAzure.Commands.Utilities.Common; |
14 | 13 |
|
15 | 14 | namespace Microsoft.WindowsAzure.Commands.Test.Websites
|
16 | 15 | {
|
17 | 16 | public class PublishAzureWebsiteProjectTests : WebsitesTestBase
|
18 | 17 | {
|
| 18 | + [Fact] |
| 19 | + [Trait(Category.AcceptanceType, Category.CheckIn)] |
| 20 | + public void PublishFromPackageWithoutSetParameters() |
| 21 | + { |
| 22 | + const string websiteName = "test-site"; |
| 23 | + const string package = "test-package"; |
| 24 | + string slot = null; |
| 25 | + var connectionStrings = new Hashtable(); |
| 26 | + connectionStrings["DefaultConnection"] = "test-connection-string"; |
| 27 | + |
| 28 | + var publishProfile = new WebSiteGetPublishProfileResponse.PublishProfile |
| 29 | + { |
| 30 | + UserName = "test-user-name", |
| 31 | + UserPassword = "test-password", |
| 32 | + PublishUrl = "test-publish-url" |
| 33 | + }; |
| 34 | + |
| 35 | + var published = false; |
| 36 | + |
| 37 | + var clientMock = new Mock<IWebsitesClient>(); |
| 38 | + |
| 39 | + clientMock.Setup(c => c.GetWebDeployPublishProfile(websiteName, slot)).Returns(publishProfile); |
| 40 | + clientMock.Setup(c => c.PublishWebProject(websiteName, slot, package, null, connectionStrings, false, false)) |
| 41 | + .Callback((string n, string s, string p, string spf, Hashtable cs, bool skipAppData, bool doNotDelete) => |
| 42 | + { |
| 43 | + Assert.Equal(websiteName, n); |
| 44 | + Assert.Equal(slot, s); |
| 45 | + Assert.Equal(package, p); |
| 46 | + Assert.Equal(connectionStrings, cs); |
| 47 | + Assert.False(skipAppData); |
| 48 | + Assert.False(doNotDelete); |
| 49 | + published = true; |
| 50 | + }); |
| 51 | + |
| 52 | + var powerShellMock = new Mock<ICommandRuntime>(); |
| 53 | + |
| 54 | + var command = new PublishAzureWebsiteProject |
| 55 | + { |
| 56 | + CommandRuntime = powerShellMock.Object, |
| 57 | + Name = websiteName, |
| 58 | + Package = package, |
| 59 | + ConnectionString = connectionStrings, |
| 60 | + WebsitesClient = clientMock.Object, |
| 61 | + SetParametersFile = null |
| 62 | + }; |
| 63 | + |
| 64 | + command.ExecuteCmdlet(); |
| 65 | + |
| 66 | + powerShellMock.Verify(f => f.WriteVerbose(string.Format("[Complete] Publishing package {0}", package)), Times.Once()); |
| 67 | + Assert.True(published); |
| 68 | + } |
| 69 | + |
19 | 70 | [Fact]
|
20 | 71 | [Trait(Category.AcceptanceType, Category.CheckIn)]
|
21 | 72 | public void PublishFromPackage()
|
|
0 commit comments