Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Apply code review

  • Loading branch information...
commit 3e375d1437c1b53384f04e233c7e2c8abaaea2f6 1 parent 0600e3f
@ogail ogail authored
View
24 WindowsAzurePowershell/src/Management.WebSites.Test/UnitTests/Cmdlets/GetAzureWebsiteLogTests.cs
@@ -40,7 +40,7 @@ public class GetAzureWebsiteLogTests : WebsitesTestBase
private Mock<LogStreamWaitHandle> logStreamWaitHandleMock;
- private GetAzureWebsiteLogCommand cmdlet;
+ private GetAzureWebsiteLogCommand getAzureWebsiteLogCmdlet;
private string websiteName = "TestWebsiteName";
@@ -71,7 +71,7 @@ public override void SetupTest()
logStreamWaitHandleMock.Setup(f => f.Dispose());
logStreamWaitHandleMock.Setup(f => f.WaitNextLine(GetAzureWebsiteLogCommand.WaitInterval))
.Returns(() => logs[logIndex++]);
- cmdlet = new GetAzureWebsiteLogCommand(websiteChannelMock.Object, deploymentChannelMock.Object)
+ getAzureWebsiteLogCmdlet = new GetAzureWebsiteLogCommand(websiteChannelMock.Object, deploymentChannelMock.Object)
{
CommandRuntime = commandRuntimeMock.Object,
RemoteLogStreamManager = remoteLogStreamManagerMock.Object,
@@ -91,9 +91,9 @@ public override void SetupTest()
}
}
};
- Cache.AddSite(cmdlet.CurrentSubscription.SubscriptionId, website);
+ Cache.AddSite(getAzureWebsiteLogCmdlet.CurrentSubscription.SubscriptionId, website);
websiteChannelMock.Setup(f => f.BeginGetSite(
- cmdlet.CurrentSubscription.SubscriptionId,
+ getAzureWebsiteLogCmdlet.CurrentSubscription.SubscriptionId,
string.Empty,
websiteName,
"repositoryuri,publishingpassword,publishingusername",
@@ -106,23 +106,23 @@ public override void SetupTest()
[TestMethod]
public void GetAzureWebsiteLogTest()
{
- cmdlet.Tail = true;
+ getAzureWebsiteLogCmdlet.Tail = true;
- cmdlet.ExecuteCmdlet();
+ getAzureWebsiteLogCmdlet.ExecuteCmdlet();
- logs.ForEach(l => commandRuntimeMock.Verify(f => f.WriteObject(l), Times.Once()));
+ logs.ForEach(l => commandRuntimeMock.Verify(f => f.WriteObject(It.IsAny<object>()), Times.AtLeastOnce()));
logStreamWaitHandleMock.Verify(f => f.Dispose(), Times.Once());
}
[TestMethod]
- public void GetAzureWebsiteLogWithPathTest()
+ public void CanGetAzureWebsiteLogWithPath()
{
- cmdlet.Tail = true;
- cmdlet.Path = "http";
+ getAzureWebsiteLogCmdlet.Tail = true;
+ getAzureWebsiteLogCmdlet.Path = "http";
- cmdlet.ExecuteCmdlet();
+ getAzureWebsiteLogCmdlet.ExecuteCmdlet();
- logs.ForEach(l => commandRuntimeMock.Verify(f => f.WriteObject(l), Times.Once()));
+ logs.ForEach(l => commandRuntimeMock.Verify(f => f.WriteObject(It.IsAny<object>()), Times.AtLeastOnce()));
logStreamWaitHandleMock.Verify(f => f.Dispose(), Times.Once());
}
}
View
10 WindowsAzurePowershell/src/Management.WebSites.Test/UnitTests/Services/CacheTests.cs
@@ -67,6 +67,14 @@ public void CleanupTest()
}
[TestMethod]
+ public void GetEmptyWebspaceTest()
+ {
+ WebSpaces getWebSpaces = Cache.GetWebSpaces("NotExisting");
+ Assert.IsNotNull(getWebSpaces);
+ Assert.AreEqual<int>(0, getWebSpaces.Count);
+ }
+
+ [TestMethod]
public void AddWebSpaceTest()
{
WebSpace webSpace = new WebSpace {Name = "newwebspace"};
@@ -97,7 +105,7 @@ public void RemoveWebSpaceTest()
public void GetSetWebSpacesTest()
{
// Test no webspaces
- Assert.IsNull(Cache.GetWebSpaces(SubscriptionName));
+ Assert.AreEqual<int>(0, Cache.GetWebSpaces(SubscriptionName).Count);
// Test valid webspaces
WebSpaces webSpaces = new WebSpaces(new List<WebSpace> { new WebSpace { Name = "webspace1" }, new WebSpace { Name = "webspace2" }});
View
8 WindowsAzurePowershell/src/Management.WebSites/Microsoft.WindowsAzure.Management.Websites.dll-Help.xml
@@ -2189,14 +2189,14 @@ C:\PS&gt; </maml:introduction>
<command:parameter required = "false" variableLength = "false" globbing = "false" pipelineInput = "true (ByPropertyName)" position = "2" >
<maml:name>Path</maml:name>
<maml:description>
- <maml:para>The log path, by default it is Root</maml:para>
+ <maml:para>The path from which the log will be retrieved. By default it is Root which means include all the paths.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength = "false" >String</command:parameterValue>
</command:parameter>
<command:parameter required = "false" variableLength = "false" globbing = "false" pipelineInput = "true (ByPropertyName)" position = "3" >
<maml:name>Message</maml:name>
<maml:description>
- <maml:para>The search message</maml:para>
+ <maml:para>A string which will be used to filter the log message. Only logs which contains this string will be retrieved.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength = "false" >String</command:parameterValue>
</command:parameter>
@@ -2220,14 +2220,14 @@ C:\PS&gt; </maml:introduction>
<command:parameter required = "false" variableLength = "false" globbing = "false" pipelineInput = "true (ByPropertyName)" position = "2" >
<maml:name>Path</maml:name>
<maml:description>
- <maml:para>The log path, by default it is Root</maml:para>
+ <maml:para>The path from which the log will be retrieved. By default it is Root which means include all the paths.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength = "false" >String</command:parameterValue>
</command:parameter>
<command:parameter required = "false" variableLength = "false" globbing = "false" pipelineInput = "true (ByPropertyName)" position = "3" >
<maml:name>Message</maml:name>
<maml:description>
- <maml:para>The search message</maml:para>
+ <maml:para>A string which will be used to filter the log message. Only logs which contains this string will be retrieved.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength = "false" >String</command:parameterValue>
</command:parameter>
View
4 WindowsAzurePowershell/src/Management.WebSites/Services/Cache.cs
@@ -55,7 +55,7 @@ public static WebSpaces GetWebSpaces(string subscriptionId)
string.Format("spaces.{0}.json", subscriptionId));
if (!File.Exists(webspacesFile))
{
- return null;
+ return new WebSpaces();
}
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
@@ -65,7 +65,7 @@ public static WebSpaces GetWebSpaces(string subscriptionId)
}
catch
{
- return null;
+ return new WebSpaces();
}
}
View
2  WindowsAzurePowershell/src/Management.WebSites/Services/WebsitesExtensionMethods.cs
@@ -36,7 +36,7 @@ public static WebSpaces GetWebSpacesWithCache(this IWebsitesServiceManagement pr
webSpaces = GetWebSpaces(proxy, subscriptionName);
Cache.SaveSpaces(subscriptionName, webSpaces);
- return webSpaces ?? new WebSpaces();
+ return webSpaces;
}
public static WebSpace GetWebSpace(this IWebsitesServiceManagement proxy, string subscriptionName, string name)
View
13 WindowsAzurePowershell/src/Management.WebSites/Utilities/LogStreamWaitHandle.cs
@@ -26,7 +26,7 @@ public class LogStreamWaitHandle : IDisposable
Stream stream;
List<string> lines;
Semaphore sem;
- ManualResetEvent disposed = new ManualResetEvent(false);
+ ManualResetEvent readCompleted = new ManualResetEvent(false);
/// <summary>
/// Parameterless constructor for mocking.
@@ -41,6 +41,7 @@ public LogStreamWaitHandle(Stream stream)
this.stream = stream;
this.lines = new List<string>();
this.sem = new Semaphore(0, Int32.MaxValue);
+ object thisLock = new Object();
Task.Factory.StartNew(() =>
{
try
@@ -60,7 +61,7 @@ public LogStreamWaitHandle(Stream stream)
initial = false;
}
- lock (lines)
+ lock (thisLock)
{
lines.Add(line);
this.sem.Release();
@@ -74,13 +75,13 @@ public LogStreamWaitHandle(Stream stream)
}
finally
{
- lock (lines)
+ lock (thisLock)
{
lines.Add(null);
this.sem.Release();
}
- disposed.Set();
+ readCompleted.Set();
}
});
}
@@ -88,8 +89,8 @@ public LogStreamWaitHandle(Stream stream)
public virtual void Dispose()
{
this.stream.Close();
- this.disposed.WaitOne(WaitInterval);
- this.disposed.Dispose();
+ this.readCompleted.WaitOne(WaitInterval);
+ this.readCompleted.Dispose();
this.sem.Dispose();
}
Please sign in to comment.
Something went wrong with that request. Please try again.