Skip to content

Commit 74fb716

Browse files
Ethan CrawfordEthan Crawford
authored andcommitted
Initialize hashtable after declaration to fix build break
1 parent 2049f0d commit 74fb716

File tree

1 file changed

+172
-171
lines changed

1 file changed

+172
-171
lines changed

src/ServiceManagement/Services/Commands.Test/Websites/PublishAzureWebsiteProjectTests.cs

Lines changed: 172 additions & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -13,175 +13,176 @@
1313

1414
namespace Microsoft.WindowsAzure.Commands.Test.Websites
1515
{
16-
public class PublishAzureWebsiteProjectTests : WebsitesTestBase
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 { ["DefaultConnection"] = "test-connection-string" };
26-
27-
var publishProfile = new WebSiteGetPublishProfileResponse.PublishProfile
28-
{
29-
UserName = "test-user-name",
30-
UserPassword = "test-password",
31-
PublishUrl = "test-publish-url"
32-
};
33-
34-
var published = false;
35-
36-
var clientMock = new Mock<IWebsitesClient>();
37-
38-
clientMock.Setup(c => c.GetWebDeployPublishProfile(websiteName, slot)).Returns(publishProfile);
39-
clientMock.Setup(c => c.PublishWebProject(websiteName, slot, package, null, connectionStrings, false, false))
40-
.Callback((string n, string s, string p, string spf, Hashtable cs, bool skipAppData, bool doNotDelete) =>
41-
{
42-
Assert.Equal(websiteName, n);
43-
Assert.Equal(slot, s);
44-
Assert.Equal(package, p);
45-
Assert.Equal(connectionStrings, cs);
46-
Assert.False(skipAppData);
47-
Assert.False(doNotDelete);
48-
published = true;
49-
});
50-
51-
var powerShellMock = new Mock<ICommandRuntime>();
52-
53-
var command = new PublishAzureWebsiteProject
54-
{
55-
CommandRuntime = powerShellMock.Object,
56-
Name = websiteName,
57-
Package = package,
58-
ConnectionString = connectionStrings,
59-
WebsitesClient = clientMock.Object,
60-
SetParametersFile = null
61-
};
62-
63-
command.ExecuteCmdlet();
64-
65-
powerShellMock.Verify(f => f.WriteVerbose(string.Format("[Complete] Publishing package {0}", package)), Times.Once());
66-
Assert.True(published);
67-
}
68-
69-
[Fact]
70-
[Trait(Category.AcceptanceType, Category.CheckIn)]
71-
public void PublishFromPackage()
72-
{
73-
var websiteName = "test-site";
74-
string slot = null;
75-
var package = "test-package";
76-
var connectionStrings = new Hashtable();
77-
connectionStrings["DefaultConnection"] = "test-connection-string";
78-
string setParametersFile = "testfile.xml";
79-
80-
var publishProfile = new WebSiteGetPublishProfileResponse.PublishProfile()
81-
{
82-
UserName = "test-user-name",
83-
UserPassword = "test-password",
84-
PublishUrl = "test-publlish-url"
85-
};
86-
87-
var published = false;
88-
89-
Mock<IWebsitesClient> clientMock = new Mock<IWebsitesClient>();
90-
91-
clientMock.Setup(c => c.GetWebDeployPublishProfile(websiteName, slot)).Returns(publishProfile);
92-
clientMock.Setup(c => c.PublishWebProject(websiteName, slot, package, setParametersFile, connectionStrings, false, false))
93-
.Callback((string n, string s, string p, string spf, Hashtable cs, bool skipAppData, bool doNotDelete) =>
94-
{
95-
Assert.Equal(websiteName, n);
96-
Assert.Equal(slot, s);
97-
Assert.Equal(package, p);
98-
Assert.Equal(setParametersFile, spf);
99-
Assert.Equal(connectionStrings, cs);
100-
Assert.False(skipAppData);
101-
Assert.False(doNotDelete);
102-
published = true;
103-
});
104-
105-
Mock<ICommandRuntime> powerShellMock = new Mock<ICommandRuntime>();
106-
107-
var command = new PublishAzureWebsiteProject()
108-
{
109-
CommandRuntime = powerShellMock.Object,
110-
Name = websiteName,
111-
Package = package,
112-
ConnectionString = connectionStrings,
113-
WebsitesClient = clientMock.Object,
114-
SetParametersFile = setParametersFile
115-
};
116-
117-
command.ExecuteCmdlet();
118-
119-
powerShellMock.Verify(f => f.WriteVerbose(string.Format("[Complete] Publishing package {0}", package)), Times.Once());
120-
Assert.True(published);
121-
}
122-
123-
[Fact]
124-
[Trait(Category.AcceptanceType, Category.CheckIn)]
125-
public void PublishFromProjectFile()
126-
{
127-
var websiteName = "test-site";
128-
string slot = null;
129-
var projectFile = string.Format(@"{0}\Resources\MyWebApplication\WebApplication4.csproj", AppDomain.CurrentDomain.BaseDirectory);
130-
var configuration = "Debug";
131-
var logFile = string.Format(@"{0}\build.log", AppDomain.CurrentDomain.BaseDirectory);
132-
var connectionStrings = new Hashtable();
133-
connectionStrings["DefaultConnection"] = "test-connection-string";
134-
string setParametersFile = "testfile.xml";
135-
136-
using (FileSystemHelper files = new FileSystemHelper(this))
137-
{
138-
string originalDirectory = AppDomain.CurrentDomain.BaseDirectory;
139-
}
140-
141-
var publishProfile = new WebSiteGetPublishProfileResponse.PublishProfile()
142-
{
143-
UserName = "test-user-name",
144-
UserPassword = "test-password",
145-
PublishUrl = "test-publlish-url"
146-
};
147-
var package = "test-package.zip";
148-
149-
var published = false;
150-
151-
Mock<IWebsitesClient> clientMock = new Mock<IWebsitesClient>();
152-
153-
clientMock.Setup(c => c.GetWebDeployPublishProfile(websiteName, slot)).Returns(publishProfile);
154-
clientMock.Setup(c => c.BuildWebProject(projectFile, configuration, logFile)).Returns(package);
155-
clientMock.Setup(c => c.PublishWebProject(websiteName, slot, package, setParametersFile, connectionStrings, false, false))
156-
.Callback((string n, string s, string p, string spf, Hashtable cs, bool skipAppData, bool doNotDelete) =>
157-
{
158-
Assert.Equal(websiteName, n);
159-
Assert.Equal(slot, s);
160-
Assert.Equal(package, p);
161-
Assert.Equal(setParametersFile, spf);
162-
Assert.Equal(connectionStrings, cs);
163-
Assert.False(skipAppData);
164-
Assert.False(doNotDelete);
165-
published = true;
166-
});
167-
168-
Mock<ICommandRuntime> powerShellMock = new Mock<ICommandRuntime>();
169-
TestMockSupport.TestExecutionFolder = AppDomain.CurrentDomain.BaseDirectory;
170-
var command = new PublishAzureWebsiteProject()
171-
{
172-
CommandRuntime = powerShellMock.Object,
173-
WebsitesClient = clientMock.Object,
174-
Name = websiteName,
175-
ProjectFile = projectFile,
176-
Configuration = configuration,
177-
ConnectionString = connectionStrings,
178-
SetParametersFile = setParametersFile
179-
};
180-
181-
command.ExecuteCmdlet();
182-
183-
powerShellMock.Verify(f => f.WriteVerbose(string.Format("[Complete] Publishing package {0}", package)), Times.Once());
184-
Assert.True(published);
185-
}
186-
}
16+
public class PublishAzureWebsiteProjectTests : WebsitesTestBase
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+
70+
[Fact]
71+
[Trait(Category.AcceptanceType, Category.CheckIn)]
72+
public void PublishFromPackage()
73+
{
74+
var websiteName = "test-site";
75+
string slot = null;
76+
var package = "test-package";
77+
var connectionStrings = new Hashtable();
78+
connectionStrings["DefaultConnection"] = "test-connection-string";
79+
string setParametersFile = "testfile.xml";
80+
81+
var publishProfile = new WebSiteGetPublishProfileResponse.PublishProfile()
82+
{
83+
UserName = "test-user-name",
84+
UserPassword = "test-password",
85+
PublishUrl = "test-publlish-url"
86+
};
87+
88+
var published = false;
89+
90+
Mock<IWebsitesClient> clientMock = new Mock<IWebsitesClient>();
91+
92+
clientMock.Setup(c => c.GetWebDeployPublishProfile(websiteName, slot)).Returns(publishProfile);
93+
clientMock.Setup(c => c.PublishWebProject(websiteName, slot, package, setParametersFile, connectionStrings, false, false))
94+
.Callback((string n, string s, string p, string spf, Hashtable cs, bool skipAppData, bool doNotDelete) =>
95+
{
96+
Assert.Equal(websiteName, n);
97+
Assert.Equal(slot, s);
98+
Assert.Equal(package, p);
99+
Assert.Equal(setParametersFile, spf);
100+
Assert.Equal(connectionStrings, cs);
101+
Assert.False(skipAppData);
102+
Assert.False(doNotDelete);
103+
published = true;
104+
});
105+
106+
Mock<ICommandRuntime> powerShellMock = new Mock<ICommandRuntime>();
107+
108+
var command = new PublishAzureWebsiteProject()
109+
{
110+
CommandRuntime = powerShellMock.Object,
111+
Name = websiteName,
112+
Package = package,
113+
ConnectionString = connectionStrings,
114+
WebsitesClient = clientMock.Object,
115+
SetParametersFile = setParametersFile
116+
};
117+
118+
command.ExecuteCmdlet();
119+
120+
powerShellMock.Verify(f => f.WriteVerbose(string.Format("[Complete] Publishing package {0}", package)), Times.Once());
121+
Assert.True(published);
122+
}
123+
124+
[Fact]
125+
[Trait(Category.AcceptanceType, Category.CheckIn)]
126+
public void PublishFromProjectFile()
127+
{
128+
var websiteName = "test-site";
129+
string slot = null;
130+
var projectFile = string.Format(@"{0}\Resources\MyWebApplication\WebApplication4.csproj", AppDomain.CurrentDomain.BaseDirectory);
131+
var configuration = "Debug";
132+
var logFile = string.Format(@"{0}\build.log", AppDomain.CurrentDomain.BaseDirectory);
133+
var connectionStrings = new Hashtable();
134+
connectionStrings["DefaultConnection"] = "test-connection-string";
135+
string setParametersFile = "testfile.xml";
136+
137+
using (FileSystemHelper files = new FileSystemHelper(this))
138+
{
139+
string originalDirectory = AppDomain.CurrentDomain.BaseDirectory;
140+
}
141+
142+
var publishProfile = new WebSiteGetPublishProfileResponse.PublishProfile()
143+
{
144+
UserName = "test-user-name",
145+
UserPassword = "test-password",
146+
PublishUrl = "test-publlish-url"
147+
};
148+
var package = "test-package.zip";
149+
150+
var published = false;
151+
152+
Mock<IWebsitesClient> clientMock = new Mock<IWebsitesClient>();
153+
154+
clientMock.Setup(c => c.GetWebDeployPublishProfile(websiteName, slot)).Returns(publishProfile);
155+
clientMock.Setup(c => c.BuildWebProject(projectFile, configuration, logFile)).Returns(package);
156+
clientMock.Setup(c => c.PublishWebProject(websiteName, slot, package, setParametersFile, connectionStrings, false, false))
157+
.Callback((string n, string s, string p, string spf, Hashtable cs, bool skipAppData, bool doNotDelete) =>
158+
{
159+
Assert.Equal(websiteName, n);
160+
Assert.Equal(slot, s);
161+
Assert.Equal(package, p);
162+
Assert.Equal(setParametersFile, spf);
163+
Assert.Equal(connectionStrings, cs);
164+
Assert.False(skipAppData);
165+
Assert.False(doNotDelete);
166+
published = true;
167+
});
168+
169+
Mock<ICommandRuntime> powerShellMock = new Mock<ICommandRuntime>();
170+
TestMockSupport.TestExecutionFolder = AppDomain.CurrentDomain.BaseDirectory;
171+
var command = new PublishAzureWebsiteProject()
172+
{
173+
CommandRuntime = powerShellMock.Object,
174+
WebsitesClient = clientMock.Object,
175+
Name = websiteName,
176+
ProjectFile = projectFile,
177+
Configuration = configuration,
178+
ConnectionString = connectionStrings,
179+
SetParametersFile = setParametersFile
180+
};
181+
182+
command.ExecuteCmdlet();
183+
184+
powerShellMock.Verify(f => f.WriteVerbose(string.Format("[Complete] Publishing package {0}", package)), Times.Once());
185+
Assert.True(published);
186+
}
187+
}
187188
}

0 commit comments

Comments
 (0)