Skip to content

Commit

Permalink
feat: add StyleCop
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidRouyer committed Sep 1, 2019
1 parent 1adabdb commit 6f4c4e1
Show file tree
Hide file tree
Showing 139 changed files with 572 additions and 418 deletions.
33 changes: 33 additions & 0 deletions pipedrive.ruleset
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="Pipedrive.net Rules" Description="Pipedrive.net Rules" ToolsVersion="15.0">
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
<Rule Id="SA0001" Action="None" />
<Rule Id="SA1009" Action="None" />
<Rule Id="SA1101" Action="None" />
<Rule Id="SA1116" Action="None" />
<Rule Id="SA1117" Action="None" />
<Rule Id="SA1118" Action="None" />
<Rule Id="SA1128" Action="None" />
<Rule Id="SA1129" Action="None" />
<Rule Id="SA1201" Action="None" />
<Rule Id="SA1202" Action="None" />
<Rule Id="SA1204" Action="None" />
<Rule Id="SA1300" Action="None" />
<Rule Id="SA1303" Action="None" />
<Rule Id="SA1309" Action="None" />
<Rule Id="SA1311" Action="None" />
<Rule Id="SA1400" Action="None" />
<Rule Id="SA1401" Action="None" />
<Rule Id="SA1402" Action="None" />
<Rule Id="SA1404" Action="None" />
<Rule Id="SA1413" Action="None" />
<Rule Id="SA1501" Action="None" />
<Rule Id="SA1503" Action="None" />
<Rule Id="SA1600" Action="None" />
<Rule Id="SA1602" Action="None" />
<Rule Id="SA1615" Action="None" />
<Rule Id="SA1623" Action="None" />
<Rule Id="SA1629" Action="None" />
<Rule Id="SA1633" Action="None" />
</Rules>
</RuleSet>
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public async Task CanDelete()

await fixture.Delete(createdActivity.Id);

var deletedActivity = await fixture.Get(createdActivity.Id);
var deletedActivity = await fixture.Get(createdActivity.Id);

Assert.False(deletedActivity.ActiveFlag);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Pipedrive.CustomFields;
using System;
using System;
using System.Threading.Tasks;
using Pipedrive.CustomFields;
using Xunit;

namespace Pipedrive.Tests.Integration.Clients
Expand Down
11 changes: 9 additions & 2 deletions src/Pipedrive.net.Tests.Integration/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ namespace Pipedrive.Tests.Integration
{
public static class Helper
{
public static Uri ApiUrl { get { return _apiUrl.Value; } }
public static Uri ApiUrl
{
get { return _apiUrl.Value; }
}

public static string ApiToken { get { return Environment.GetEnvironmentVariable("PIPEDRIVE_APITOKEN"); } }
public static string ApiToken
{
get { return Environment.GetEnvironmentVariable("PIPEDRIVE_APITOKEN"); }
}

static readonly Lazy<Uri> _apiUrl = new Lazy<Uri>(() =>
{
Expand Down Expand Up @@ -39,6 +45,7 @@ public static Stream LoadFixture(string fileName)
throw new InvalidOperationException(
"The file '" + fileName + "' was not found as an embedded resource in the assembly. Failing the test...");
}

return stream;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,8 @@
using System.Collections.Generic;
using Xunit;
using Xunit.Abstractions;
using Xunit;
using Xunit.Sdk;

namespace Pipedrive.Tests.Integration
{
public class IntegrationTestDiscoverer : IXunitTestCaseDiscoverer
{
readonly IMessageSink diagnosticMessageSink;

public IntegrationTestDiscoverer(IMessageSink diagnosticMessageSink)
{
this.diagnosticMessageSink = diagnosticMessageSink;
}

public IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
{
return new[] { new XunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod) };
}
}

[XunitTestCaseDiscoverer("Pipedrive.Tests.Integration.IntegrationTestDiscoverer", "Pipedrive.Tests.Integration")]
public class IntegrationTestAttribute : FactAttribute
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Collections.Generic;
using Xunit.Abstractions;
using Xunit.Sdk;

namespace Pipedrive.Tests.Integration
{
public class IntegrationTestDiscoverer : IXunitTestCaseDiscoverer
{
readonly IMessageSink diagnosticMessageSink;

public IntegrationTestDiscoverer(IMessageSink diagnosticMessageSink)
{
this.diagnosticMessageSink = diagnosticMessageSink;
}

public IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
{
return new[] { new XunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod) };
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
Expand All @@ -44,4 +48,11 @@

<ProjectExtensions><VisualStudio><UserProperties /></VisualStudio></ProjectExtensions>

<PropertyGroup>
<CodeAnalysisRuleSet>..\..\pipedrive.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<ItemGroup>
<AdditionalFiles Include="..\..\stylecop.json" Link="stylecop.json" />
</ItemGroup>
</Project>
15 changes: 6 additions & 9 deletions src/Pipedrive.net.Tests/Clients/ActivitiesClientTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using NSubstitute;
using System;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using NSubstitute;
using Xunit;

namespace Pipedrive.Tests.Clients
Expand Down Expand Up @@ -52,8 +52,7 @@ await connection.GetAll<Activity>(
&& d["done"] == "1"),
Arg.Is<ApiOptions>(o => o.PageSize == 1
&& o.PageCount == 1
&& o.StartPage == 0)
);
&& o.StartPage == 0));
});
}
}
Expand Down Expand Up @@ -88,12 +87,11 @@ public async Task RequestsCorrectUrl()
{
await connection.GetAll<Activity>(
Arg.Is<Uri>(u => u.ToString() == "activities"),
Arg.Is<Dictionary<string,string>>(d => d.Count == 1
Arg.Is<Dictionary<string, string>>(d => d.Count == 1
&& d["done"] == "1"),
Arg.Is<ApiOptions>(o => o.PageSize == 1
&& o.PageCount == 1
&& o.StartPage == 0)
);
&& o.StartPage == 0));
});
}
}
Expand Down Expand Up @@ -133,8 +131,7 @@ await connection.GetAll<Activity>(
&& d["done"] == "1"),
Arg.Is<ApiOptions>(o => o.PageSize == 1
&& o.PageCount == 1
&& o.StartPage == 0)
);
&& o.StartPage == 0));
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Pipedrive.net.Tests/Clients/ActivityFieldsClientTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using NSubstitute;
using System;
using System;
using System.Threading.Tasks;
using NSubstitute;
using Xunit;

namespace Pipedrive.Tests.Clients
Expand Down
4 changes: 2 additions & 2 deletions src/Pipedrive.net.Tests/Clients/ActivityTypesClientTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using NSubstitute;
using System;
using System;
using System.Threading.Tasks;
using NSubstitute;
using Xunit;

namespace Pipedrive.Tests.Clients
Expand Down
6 changes: 3 additions & 3 deletions src/Pipedrive.net.Tests/Clients/CurrenciesClientTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using NSubstitute;
using System;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using NSubstitute;
using Xunit;

namespace Pipedrive.Tests.Clients
Expand All @@ -27,7 +27,7 @@ public async Task RequestsCorrectUrl()

await client.GetAll();

Received.InOrder(async() =>
Received.InOrder(async () =>
{
await connection.GetAll<Currency>(Arg.Is<Uri>(u => u.ToString() == "currencies"));
});
Expand Down
4 changes: 2 additions & 2 deletions src/Pipedrive.net.Tests/Clients/DealFieldsClientTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using NSubstitute;
using System;
using System;
using System.Threading.Tasks;
using NSubstitute;
using Xunit;

namespace Pipedrive.Tests.Clients
Expand Down
30 changes: 11 additions & 19 deletions src/Pipedrive.net.Tests/Clients/DealsClientTests.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using NSubstitute;
using Pipedrive.CustomFields;
using Pipedrive.Models.Response;
using System;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using NSubstitute;
using Pipedrive.CustomFields;
using Pipedrive.Models.Response;
using Xunit;
using static Pipedrive.DealsClient;

namespace Pipedrive.Tests.Clients
{
Expand Down Expand Up @@ -55,8 +54,7 @@ await connection.GetAll<Deal>(
&& d["status"] == "lost"),
Arg.Is<ApiOptions>(o => o.PageSize == 1
&& o.PageCount == 1
&& o.StartPage == 0)
);
&& o.StartPage == 0));
});
}
}
Expand Down Expand Up @@ -96,8 +94,7 @@ await connection.GetAll<Deal>(
&& d["status"] == "lost"),
Arg.Is<ApiOptions>(o => o.PageSize == 1
&& o.PageCount == 1
&& o.StartPage == 0)
);
&& o.StartPage == 0));
});
}
}
Expand Down Expand Up @@ -137,8 +134,7 @@ await connection.GetAll<Deal>(
&& d["status"] == "lost"),
Arg.Is<ApiOptions>(o => o.PageSize == 1
&& o.PageCount == 1
&& o.StartPage == 0)
);
&& o.StartPage == 0));
});
}
}
Expand Down Expand Up @@ -277,8 +273,7 @@ await connection.GetAll<DealUpdateFlow>(
&& d["id"] == "123"),
Arg.Is<ApiOptions>(o => o.PageSize == 1
&& o.PageCount == 1
&& o.StartPage == 0)
);
&& o.StartPage == 0));
});
}
}
Expand All @@ -298,8 +293,7 @@ public async Task RequestsCorrectUrl()
await connection.GetAll<Follower>(
Arg.Is<Uri>(u => u.ToString() == "deals/123/followers"),
Arg.Is<Dictionary<string, string>>(d => d.Count == 1
&& d["id"] == "123")
);
&& d["id"] == "123"));
});
}
}
Expand Down Expand Up @@ -369,8 +363,7 @@ await connection.GetAll<DealActivity>(
&& d["done"] == "1"),
Arg.Is<ApiOptions>(o => o.PageSize == 1
&& o.PageCount == 1
&& o.StartPage == 0)
);
&& o.StartPage == 0));
});
}
}
Expand Down Expand Up @@ -408,8 +401,7 @@ await connection.GetAll<DealParticipant>(
&& d["id"] == "123"),
Arg.Is<ApiOptions>(o => o.PageSize == 1
&& o.PageCount == 1
&& o.StartPage == 0)
);
&& o.StartPage == 0));
});
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/Pipedrive.net.Tests/Clients/FilesClientTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using NSubstitute;
using System;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using NSubstitute;
using Xunit;

namespace Pipedrive.Tests.Clients
Expand Down Expand Up @@ -49,8 +49,7 @@ await connection.GetAll<File>(
Arg.Is<Dictionary<string, string>>(d => d.Count == 0),
Arg.Is<ApiOptions>(o => o.PageSize == 1
&& o.PageCount == 1
&& o.StartPage == 0)
);
&& o.StartPage == 0));
});
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/Pipedrive.net.Tests/Clients/NotesClientTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using NSubstitute;
using System;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using NSubstitute;
using Xunit;

namespace Pipedrive.Tests.Clients
Expand Down Expand Up @@ -49,8 +49,7 @@ await connection.GetAll<Note>(
Arg.Is<Dictionary<string, string>>(d => d.Count == 0),
Arg.Is<ApiOptions>(o => o.PageSize == 1
&& o.PageCount == 1
&& o.StartPage == 0)
);
&& o.StartPage == 0));
});
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using NSubstitute;
using System;
using System;
using System.Threading.Tasks;
using NSubstitute;
using Xunit;

namespace Pipedrive.Tests.Clients
Expand Down
Loading

0 comments on commit 6f4c4e1

Please sign in to comment.