Skip to content

Commit

Permalink
Fix test builds (#109)
Browse files Browse the repository at this point in the history
* Remove old serializers (deprecated after v3)
* Add sanity tests to NETFramework project
* Fix package hint path
* Remove old dependencies
* Reuse test code
* Moving tests to Common. Adding them to test projects as links
  • Loading branch information
nbarbettini authored and abatishchev committed May 16, 2017
1 parent e0092b8 commit d51a8a3
Show file tree
Hide file tree
Showing 8 changed files with 263 additions and 284 deletions.
2 changes: 1 addition & 1 deletion build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Task("TestNetFramework")

NuGetRestore(
string.Format("./tests/{0}/{0}.csproj", frameworkTestProject),
new NuGetRestoreSettings { PackagesDirectory = string.Format("./tests/{0}/packages/", frameworkTestProject) });
new NuGetRestoreSettings { PackagesDirectory = string.Format("./packages/", frameworkTestProject) });

MSBuild(
string.Format("./tests/{0}/{0}.csproj", frameworkTestProject),
Expand Down
10 changes: 10 additions & 0 deletions tests/JWT.Tests.Common/JWT.Tests.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,14 @@
<TargetFramework>netstandard1.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Remove="JwtDecoderTest.cs" />
<Compile Remove="JwtEncoderTest.cs" />
</ItemGroup>

<ItemGroup>
<None Include="JwtDecoderTest.cs" />
<None Include="JwtEncoderTest.cs" />
</ItemGroup>

</Project>

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
using System.Collections.Generic;
using FluentAssertions;
using JWT.Algorithms;
using JWT.Serializers;
using Xunit;
using JWT.Tests.Common;

namespace JWT.Tests
{
public class JwtEncoderTest
{
[Fact]
public void Encode_Should_Encode_To_Token()
{
var serializer = new JsonNetSerializer();
var urlEncoder = new JwtBase64UrlEncoder();
var encoder = new JwtEncoder(new HMACSHA256Algorithm(), serializer, urlEncoder);

var actual = encoder.Encode(TestData.Customer, "ABC");

actual.Should().Be(TestData.Token);
}

[Fact]
public void Encode_Should_Encode_To_Token_With_Extra_Headers()
{
var serializer = new JsonNetSerializer();
var urlEncoder = new JwtBase64UrlEncoder();
var encoder = new JwtEncoder(new HMACSHA256Algorithm(), serializer, urlEncoder);

var extraheaders = new Dictionary<string, object> { { "foo", "bar" } };
var actual = encoder.Encode(extraheaders, TestData.Customer, "ABC");

actual.Should().Be(TestData.ExtraHeadersToken);
}
}
using System.Collections.Generic;
using FluentAssertions;
using JWT.Algorithms;
using JWT.Serializers;
using Xunit;
using JWT.Tests.Common;

namespace JWT.Tests
{
public class JwtEncoderTest
{
[Fact]
public void Encode_Should_Encode_To_Token()
{
var serializer = new JsonNetSerializer();
var urlEncoder = new JwtBase64UrlEncoder();
var encoder = new JwtEncoder(new HMACSHA256Algorithm(), serializer, urlEncoder);

var actual = encoder.Encode(TestData.Customer, "ABC");

actual.Should().Be(TestData.Token);
}

[Fact]
public void Encode_Should_Encode_To_Token_With_Extra_Headers()
{
var serializer = new JsonNetSerializer();
var urlEncoder = new JwtBase64UrlEncoder();
var encoder = new JwtEncoder(new HMACSHA256Algorithm(), serializer, urlEncoder);

var extraheaders = new Dictionary<string, object> { { "foo", "bar" } };
var actual = encoder.Encode(extraheaders, TestData.Customer, "ABC");

actual.Should().Be(TestData.ExtraHeadersToken);
}
}
}
5 changes: 5 additions & 0 deletions tests/JWT.Tests.Core/JWT.Tests.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\JWT.Tests.Common\JwtDecoderTest.cs" Link="JwtDecoderTest.cs" />
<Compile Include="..\JWT.Tests.Common\JwtEncoderTest.cs" Link="JwtEncoderTest.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="4.19.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
Expand Down
24 changes: 12 additions & 12 deletions tests/JWT.Tests.NETFramework/JWT.Tests.NETFramework.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,36 +39,36 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="FluentAssertions, Version=4.19.2.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
<HintPath>packages\FluentAssertions.4.19.2\lib\net45\FluentAssertions.dll</HintPath>
<HintPath>..\..\packages\FluentAssertions.4.19.2\lib\net45\FluentAssertions.dll</HintPath>
</Reference>
<Reference Include="FluentAssertions.Core, Version=4.19.2.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
<HintPath>.\packages\FluentAssertions.4.19.2\lib\net45\FluentAssertions.Core.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Text, Version=4.5.6.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>.\packages\ServiceStack.Text.4.5.6\lib\net45\ServiceStack.Text.dll</HintPath>
<HintPath>..\..\packages\FluentAssertions.4.19.2\lib\net45\FluentAssertions.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>.\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll</HintPath>
<HintPath>..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll</HintPath>
</Reference>
<Reference Include="xunit.assert, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>.\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll</HintPath>
<HintPath>..\..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll</HintPath>
</Reference>
<Reference Include="xunit.core, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>.\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll</HintPath>
<HintPath>..\..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll</HintPath>
</Reference>
<Reference Include="xunit.execution.desktop, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>.\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll</HintPath>
<HintPath>..\..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\JWT.Tests.Common\JwtDecoderTest.cs">
<Link>JwtDecoderTest.cs</Link>
</Compile>
<Compile Include="..\JWT.Tests.Common\JwtEncoderTest.cs">
<Link>JwtEncoderTest.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Serializers\ServiceStackJsonSerializer.cs" />
<Compile Include="Serializers\WebScriptJsonSerializer.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit d51a8a3

Please sign in to comment.