Skip to content
This repository has been archived by the owner on Mar 20, 2019. It is now read-only.

Commit

Permalink
Activating StyleCop on aspnet test assembly and fixed issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
AArnott committed Mar 12, 2012
1 parent 71ad979 commit 15b4b6f
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 46 deletions.
10 changes: 5 additions & 5 deletions Settings.StyleCop
@@ -1,13 +1,13 @@
<StyleCopSettings Version="4.3">
<Parsers>
<Parser ParserId="Microsoft.StyleCop.CSharp.CsParser">
<Parser ParserId="StyleCop.CSharp.CsParser">
<ParserSettings>
<BooleanProperty Name="AnalyzeDesignerFiles">False</BooleanProperty>
</ParserSettings>
</Parser>
</Parsers>
<Analyzers>
<Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.SpacingRules">
<Analyzer AnalyzerId="StyleCop.CSharp.SpacingRules">
<Rules>
<Rule Name="TabsMustNotBeUsed">
<RuleSettings>
Expand All @@ -17,7 +17,7 @@
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.LayoutRules">
<Analyzer AnalyzerId="StyleCop.CSharp.LayoutRules">
<Rules>
<Rule Name="CurlyBracketsForMultiLineStatementsMustNotShareLine">
<RuleSettings>
Expand All @@ -37,7 +37,7 @@
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.ReadabilityRules">
<Analyzer AnalyzerId="StyleCop.CSharp.ReadabilityRules">
<Rules>
<Rule Name="ParametersMustBeOnSameLineOrSeparateLines">
<RuleSettings>
Expand All @@ -52,7 +52,7 @@
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.NamingRules">
<Analyzer AnalyzerId="StyleCop.CSharp.NamingRules">
<AnalyzerSettings>
<CollectionProperty Name="Hungarian">
<Value>ax</Value>
Expand Down
Expand Up @@ -2,7 +2,6 @@
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " />
<PropertyGroup>
<StyleCopEnabled>False</StyleCopEnabled>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
Expand Down
16 changes: 11 additions & 5 deletions src/DotNetOpenAuth.AspNet.Test/OAuth2ClientTest.cs
@@ -1,4 +1,10 @@
namespace DotNetOpenAuth.AspNet.Test {
//-----------------------------------------------------------------------
// <copyright file="OAuth2ClientTest.cs" company="Microsoft">
// Copyright (c) Microsoft. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace DotNetOpenAuth.AspNet.Test {
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
Expand Down Expand Up @@ -113,10 +119,10 @@ public MockOAuth2Client()
protected override IDictionary<string, string> GetUserData(string accessToken) {
if (accessToken == "abcde") {
return new Dictionary<string, string>
{
{"id", "12345"},
{"name", "John Doe"}
};
{
{ "id", "12345" },
{ "name", "John Doe" },
};
}

return null;
Expand Down
@@ -1,4 +1,10 @@
namespace DotNetOpenAuth.Test.Web {
//-----------------------------------------------------------------------
// <copyright file="OAuthAuthenticationTickerHelperTest.cs" company="Microsoft">
// Copyright (c) Microsoft. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace DotNetOpenAuth.Test.Web {
using System;
using System.Web;
using System.Web.Security;
Expand All @@ -10,12 +16,12 @@
public class OAuthAuthenticationTickerHelperTest {
[TestCase]
public void SetAuthenticationTicketSetCookieOnHttpResponseWithPersistentSet() {
SetAuthenticationTicketSetCookieOnHttpResponse(isPersistent: true);
this.SetAuthenticationTicketSetCookieOnHttpResponse(isPersistent: true);
}

[TestCase]
public void SetAuthenticationTicketSetCookieOnHttpResponseWithPersistentNotSet() {
SetAuthenticationTicketSetCookieOnHttpResponse(isPersistent: false);
this.SetAuthenticationTicketSetCookieOnHttpResponse(isPersistent: false);
}

[TestCase]
Expand All @@ -30,8 +36,7 @@ public class OAuthAuthenticationTickerHelperTest {
"OAuth",
FormsAuthentication.FormsCookiePath);

var cookie = new HttpCookie(name: FormsAuthentication.FormsCookieName,
value: FormsAuthentication.Encrypt(ticket));
var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket));
var cookies = new HttpCookieCollection { cookie };

var context = new Mock<HttpContextBase>();
Expand Down Expand Up @@ -69,8 +74,7 @@ public class OAuthAuthenticationTickerHelperTest {
null,
FormsAuthentication.FormsCookiePath);

var cookie = new HttpCookie(name: FormsAuthentication.FormsCookieName,
value: FormsAuthentication.Encrypt(ticket));
var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket));
var cookies = new HttpCookieCollection { cookie };

var context = new Mock<HttpContextBase>();
Expand All @@ -97,8 +101,7 @@ public class OAuthAuthenticationTickerHelperTest {
"OAuth",
FormsAuthentication.FormsCookiePath);

var cookie = new HttpCookie(name: "random cookie name",
value: FormsAuthentication.Encrypt(ticket));
var cookie = new HttpCookie("random cookie name", FormsAuthentication.Encrypt(ticket));
var cookies = new HttpCookieCollection { cookie };

var context = new Mock<HttpContextBase>();
Expand Down
26 changes: 19 additions & 7 deletions src/DotNetOpenAuth.AspNet.Test/OAuthClientTest.cs
@@ -1,12 +1,18 @@
namespace DotNetOpenAuth.AspNet.Test {
//-----------------------------------------------------------------------
// <copyright file="OAuthClientTest.cs" company="Microsoft">
// Copyright (c) Microsoft. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace DotNetOpenAuth.AspNet.Test {
using System;
using System.Web;
using DotNetOpenAuth.AspNet;
using DotNetOpenAuth.AspNet.Clients;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.OAuth.Messages;
using DotNetOpenAuth.AspNet.Clients;
using Moq;
using NUnit.Framework;
using DotNetOpenAuth.AspNet;

[TestFixture]
public class OAuthClientTest {
Expand All @@ -26,10 +32,9 @@ public class OAuthClientTest {
public void RequestAuthenticationInvokeMethodOnWebWorker() {
// Arrange
var webWorker = new Mock<IOAuthWebWorker>(MockBehavior.Strict);
webWorker.Setup(
w => w.RequestAuthentication(
It.Is<Uri>(u => u.ToString().Equals("http://live.com/my/path.cshtml?q=one"))))
.Verifiable();
webWorker
.Setup(w => w.RequestAuthentication(It.Is<Uri>(u => u.ToString().Equals("http://live.com/my/path.cshtml?q=one"))))
.Verifiable();

var client = new MockOAuthClient(webWorker.Object);
var returnUri = new Uri("http://live.com/my/path.cshtml?q=one");
Expand Down Expand Up @@ -113,10 +118,17 @@ public class OAuthClientTest {
}

private class MockOAuthClient : OAuthClient {
/// <summary>
/// Initializes a new instance of the <see cref="MockOAuthClient"/> class.
/// </summary>
public MockOAuthClient()
: this(new Mock<IOAuthWebWorker>().Object) {
}

/// <summary>
/// Initializes a new instance of the <see cref="MockOAuthClient"/> class.
/// </summary>
/// <param name="worker">The worker.</param>
public MockOAuthClient(IOAuthWebWorker worker)
: base("mockoauth", worker) {
}
Expand Down
8 changes: 7 additions & 1 deletion src/DotNetOpenAuth.AspNet.Test/Properties/AssemblyInfo.cs
@@ -1,4 +1,10 @@
using System.Reflection;
//-----------------------------------------------------------------------
// <copyright file="AssemblyInfo.cs" company="Microsoft">
// Copyright (c) Microsoft. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

Expand Down
10 changes: 5 additions & 5 deletions src/DotNetOpenAuth.AspNet.Test/Settings.StyleCop
@@ -1,6 +1,6 @@
<StyleCopSettings Version="4.3">
<StyleCopSettings Version="105">
<Analyzers>
<Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.DocumentationRules">
<Analyzer AnalyzerId="StyleCop.CSharp.DocumentationRules">
<Rules>
<Rule Name="ElementsMustBeDocumented">
<RuleSettings>
Expand All @@ -15,7 +15,7 @@
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.LayoutRules">
<Analyzer AnalyzerId="StyleCop.CSharp.LayoutRules">
<Rules>
<Rule Name="SingleLineCommentMustBePrecededByBlankLine">
<RuleSettings>
Expand All @@ -25,7 +25,7 @@
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.NamingRules">
<Analyzer AnalyzerId="StyleCop.CSharp.NamingRules">
<AnalyzerSettings>
<CollectionProperty Name="Hungarian">
<Value>op</Value>
Expand All @@ -34,7 +34,7 @@
</CollectionProperty>
</AnalyzerSettings>
</Analyzer>
<Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.MaintainabilityRules">
<Analyzer AnalyzerId="StyleCop.CSharp.MaintainabilityRules">
<Rules>
<Rule Name="FieldsMustBePrivate">
<RuleSettings>
Expand Down
32 changes: 19 additions & 13 deletions src/DotNetOpenAuth.AspNet.Test/UriHelperTest.cs
@@ -1,4 +1,10 @@
namespace DotNetOpenAuth.AspNet.Test {
//-----------------------------------------------------------------------
// <copyright file="UriHelperTest.cs" company="Microsoft">
// Copyright (c) Microsoft. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace DotNetOpenAuth.AspNet.Test {
using System;
using DotNetOpenAuth.AspNet.Clients;
using NUnit.Framework;
Expand All @@ -9,20 +15,20 @@ public class UriHelperTest {
public void TestAttachQueryStringParameterMethod() {
// Arrange
string[] input = new string[]
{
"http://x.com",
"https://xxx.com/one?s=123",
"https://yyy.com/?s=6&u=a",
"https://zzz.com/default.aspx?name=sd"
};
{
"http://x.com",
"https://xxx.com/one?s=123",
"https://yyy.com/?s=6&u=a",
"https://zzz.com/default.aspx?name=sd"
};

string[] expectedOutput = new string[]
{
"http://x.com/?s=awesome",
"https://xxx.com/one?s=awesome",
"https://yyy.com/?s=awesome&u=a",
"https://zzz.com/default.aspx?name=sd&s=awesome"
};
{
"http://x.com/?s=awesome",
"https://xxx.com/one?s=awesome",
"https://yyy.com/?s=awesome&u=a",
"https://zzz.com/default.aspx?name=sd&s=awesome"
};

for (int i = 0; i < input.Length; i++) {
// Act
Expand Down

0 comments on commit 15b4b6f

Please sign in to comment.