Skip to content

Commit

Permalink
Update to newest version of NUnit.
Browse files Browse the repository at this point in the history
Disable tests for .NET Core (use .NET 6 instead and desupport .NET Core later).
  • Loading branch information
JornWildt committed Mar 19, 2024
1 parent 8c68469 commit a1adcdf
Show file tree
Hide file tree
Showing 79 changed files with 535 additions and 536 deletions.
11 changes: 7 additions & 4 deletions Ramone.Tests.Common/Ramone.Tests.Common.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\NUnit.3.14.0\build\NUnit.props" Condition="Exists('..\packages\NUnit.3.14.0\build\NUnit.props')" />
<Import Project="..\packages\NUnit.4.1.0\build\NUnit.props" Condition="Exists('..\packages\NUnit.4.1.0\build\NUnit.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand Down Expand Up @@ -38,8 +38,11 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework, Version=3.14.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.14.0\lib\net45\nunit.framework.dll</HintPath>
<Reference Include="nunit.framework, Version=4.0.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.4.1.0\lib\net462\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="nunit.framework.legacy, Version=4.0.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.4.1.0\lib\net462\nunit.framework.legacy.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
Expand Down Expand Up @@ -115,7 +118,7 @@
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\NUnit.3.14.0\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit.3.14.0\build\NUnit.props'))" />
<Error Condition="!Exists('..\packages\NUnit.4.1.0\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit.4.1.0\build\NUnit.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
8 changes: 4 additions & 4 deletions Ramone.Tests.Common/TestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,9 @@ protected async Task VerifyIsAsync<T>(Func<Request, Task<Response<T>>> asyncBloc
TimeSpan responseTime = DateTime.Now - t2;
TimeSpan totalTime = DateTime.Now - t1;

Assert.Less(getTime.TotalMilliseconds, 1000);
Assert.Less(responseTime.TotalMilliseconds, 1000);
Assert.GreaterOrEqual(totalTime.TotalMilliseconds, 4000);
Assert.That(getTime.TotalMilliseconds, Is.LessThan(1000));
Assert.That(responseTime.TotalMilliseconds, Is.LessThan(1000));
Assert.That(totalTime.TotalMilliseconds, Is.GreaterThanOrEqualTo(4000));

if (verifier != null)
verifier(response);
Expand All @@ -344,7 +344,7 @@ protected void TestAsyncEvent(Action<AutoResetEvent> asyncBlock)
// Wait for request to complete
bool signalReceived = handle.WaitOne(TimeSpan.FromSeconds(10));

Assert.IsTrue(signalReceived, "Timeout in async handler");
Assert.That(signalReceived, Is.True, "Timeout in async handler");
}
}
}
2 changes: 1 addition & 1 deletion Ramone.Tests.Common/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="3.14.0" targetFramework="net48" />
<package id="NUnit" version="4.1.0" targetFramework="net48" />
<package id="NUnit.Analyzers" version="4.1.0" targetFramework="net48" developmentDependency="true" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" />
Expand Down
4 changes: 2 additions & 2 deletions Ramone.Tests.Core/PostCoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public void CanPostSerializedData()
Uri createdDossierLocation = response.CreatedLocation;
Dossier createdDossier = response.Body;

Assert.IsNotNull(createdDossierLocation);
Assert.IsNotNull(createdDossier);
Assert.That(createdDossierLocation, Is.Not.Null);
Assert.That(createdDossier, Is.Not.Null);
Assert.That(createdDossier.Title, Is.EqualTo("A Core dossier"));
Assert.That(createdDossier.Id, Is.EqualTo(999));
}
Expand Down
12 changes: 4 additions & 8 deletions Ramone.Tests.Core/Ramone.Tests.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="Tavis.UriTemplates" Version="1.1.1" />
</ItemGroup>

Expand Down
24 changes: 12 additions & 12 deletions Ramone.Tests/AcceptTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void CanSetAcceptHeaderFromString()
HeaderList headers = r.Body;

// Assert
Assert.IsTrue(headers.Any(h => h == "Accept: application/xml"), "Must contain Accept header");
Assert.That(headers.Any(h => h == "Accept: application/xml"), Is.True, "Must contain Accept header");
}
}

Expand All @@ -63,7 +63,7 @@ public void CanSetMultipleAcceptHeaderFromString()
HeaderList headers = r.Body;

// Assert
Assert.IsTrue(headers.Any(h => h == "Accept: application/xml, application/json"), "Must contain Accept header");
Assert.That(headers.Any(h => h == "Accept: application/xml, application/json"), Is.True, "Must contain Accept header");
}
}

Expand All @@ -82,7 +82,7 @@ public void CanSetAcceptHeaderWithQValueFromString()
HeaderList headers = r.Body;

// Assert
Assert.IsTrue(headers.Any(h => h == "Accept: application/xml; q=0.34"), "Must contain Accept header with q-value");
Assert.That(headers.Any(h => h == "Accept: application/xml; q=0.34"), Is.True, "Must contain Accept header with q-value");
}
}

Expand All @@ -101,7 +101,7 @@ public void CanSetMultipleAcceptHeaderWithQValueFromString()
HeaderList headers = r.Body;

// Assert
Assert.IsTrue(headers.Any(h => h == "Accept: application/xml; q=0.34, application/json; q=0.12"), "Must contain Accept header with q-value");
Assert.That(headers.Any(h => h == "Accept: application/xml; q=0.34, application/json; q=0.12"), Is.True, "Must contain Accept header with q-value");
}
}

Expand All @@ -120,7 +120,7 @@ public void CanSetAcceptHeaderFromMediaType()
HeaderList headers = r.Body;

// Assert
Assert.IsTrue(headers.Any(h => h == "Accept: application/xml"), "Must contain Accept header");
Assert.That(headers.Any(h => h == "Accept: application/xml"), Is.True, "Must contain Accept header");
}
}

Expand All @@ -139,7 +139,7 @@ public void CanSetMultipleAcceptHeaderFromMediaType()
HeaderList headers = r.Body;

// Assert
Assert.IsTrue(headers.Any(h => h == "Accept: application/xml, application/xhtml+xml"), "Must contain Accept header");
Assert.That(headers.Any(h => h == "Accept: application/xml, application/xhtml+xml"), Is.True, "Must contain Accept header");
}
}

Expand All @@ -158,7 +158,7 @@ public void CanSetAcceptHeaderWithQValueFromMediaType()
HeaderList headers = r.Body;

// Assert
Assert.IsTrue(headers.Any(h => h == "Accept: application/xml; q=0.34"), "Must contain Accept header with q-value");
Assert.That(headers.Any(h => h == "Accept: application/xml; q=0.34"), Is.True, "Must contain Accept header with q-value");
}
}

Expand All @@ -177,7 +177,7 @@ public void CanSetMultipleAcceptHeaderWithQValueFromMediaType()
HeaderList headers = r.Body;

// Assert
Assert.IsTrue(headers.Any(h => h == "Accept: application/xml; q=0.89, application/xhtml+xml; q=1.00"), "Must contain Accept header");
Assert.That(headers.Any(h => h == "Accept: application/xml; q=0.89, application/xhtml+xml; q=1.00"), Is.True, "Must contain Accept header");
}
}

Expand All @@ -193,7 +193,7 @@ public void CanSetTypedAcceptHeaderWithQValueFromString()
HeaderList headers = r.Body;

// Assert
Assert.IsTrue(headers.Any(h => h == "Accept: application/xml; q=0.34"), "Must contain Accept header with q-value");
Assert.That(headers.Any(h => h == "Accept: application/xml; q=0.34"), Is.True, "Must contain Accept header with q-value");
}
}

Expand All @@ -212,7 +212,7 @@ public void ItAlwaysUsesDefaultAcceptFromSession()
HeaderList headers = r.Body;

// Assert
Assert.IsTrue(headers.Any(h => h == "Accept: application/xml"), "Must contain Accept header with q-value");
Assert.That(headers.Any(h => h == "Accept: application/xml"), Is.True, "Must contain Accept header with q-value");
}
}

Expand All @@ -232,7 +232,7 @@ public void ItUsesMultipleDefaultAcceptFromSessionWithAdditionalAcceptFromReques
HeaderList headers = r.Body;

// Assert
Assert.IsTrue(headers.Any(h => h == "Accept: application/json, text/csv; q=0.21, application/xml; q=0.88, text/plain"), "Must contain Accept header with q-value");
Assert.That(headers.Any(h => h == "Accept: application/json, text/csv; q=0.21, application/xml; q=0.88, text/plain"), Is.True, "Must contain Accept header with q-value");
}
}

Expand All @@ -255,7 +255,7 @@ public void ItUsesMultipleDefaultAcceptFromServiceWithAdditionalAcceptFromReques
HeaderList headers = r.Body;

// Assert
Assert.IsTrue(headers.Any(h => h == "Accept: application/json, text/csv; q=0.21, application/xml; q=0.88, text/plain, text/html"), "Must contain Accept header with q-value");
Assert.That(headers.Any(h => h == "Accept: application/json, text/csv; q=0.21, application/xml; q=0.88, text/plain, text/html"), Is.True, "Must contain Accept header with q-value");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Ramone.Tests/AdditionalMethodsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void CanDoHead()
using (Response response = dossierReq.Head())
{
// Assert
Assert.IsNotNull(response);
Assert.That(response, Is.Not.Null);
Assert.That(response.Headers["X-ExtraHeader"], Is.EqualTo("1"));
}
}
Expand Down
14 changes: 7 additions & 7 deletions Ramone.Tests/AnonymousSessionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void CanCreateRequestFromUriWithoutExplicitSession()
var body = response.Body;

// Assert
Assert.IsNotNull(body);
Assert.That(body, Is.Not.Null);
}
}

Expand All @@ -41,7 +41,7 @@ public void CanCreateRequestFromStringWithoutExplicitSession()
var body = response.Body;

// Assert
Assert.IsNotNull(body);
Assert.That(body, Is.Not.Null);
}
}

Expand All @@ -58,7 +58,7 @@ public void CanBindRequestFromUriWithoutExplicitSession()
var body = response.Body;

// Assert
Assert.IsNotNull(body);
Assert.That(body, Is.Not.Null);
Assert.That(body.Name, Is.EqualTo("Petra"));
}
}
Expand All @@ -76,7 +76,7 @@ public void CanBindRequestFromStringWithoutExplicitSession()
var body = response.Body;

// Assert
Assert.IsNotNull(body);
Assert.That(body, Is.Not.Null);
Assert.That(body.Name, Is.EqualTo("Petra"));
}
}
Expand All @@ -95,7 +95,7 @@ public void CanFollowLinkWithoutExplicitSession()
var body = response.Body;

// Assert
Assert.IsNotNull(body);
Assert.That(body, Is.Not.Null);
Assert.That(body.Name, Is.EqualTo("MIAUW"));
}
}
Expand All @@ -119,7 +119,7 @@ public void CanBindRequestFromLinkTemplateWithoutExplicitSession()
var body = response.Body;

// Assert
Assert.IsNotNull(body);
Assert.That(body, Is.Not.Null);
Assert.That(body.Name, Is.EqualTo("Petra"));
}
}
Expand All @@ -137,7 +137,7 @@ public void CanBindRequestFromUriTemplateWithoutExplicitSession()
var body = response.Body;

// Assert
Assert.IsNotNull(body);
Assert.That(body, Is.Not.Null);
Assert.That(body.Name, Is.EqualTo("Petra"));
}
}
Expand Down
8 changes: 4 additions & 4 deletions Ramone.Tests/ApplicationErrorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public void CanDecodeErrorStream()
{
using (var response = Session.Decode<ApplicationError>(ex))
{
Assert.IsNotNull(response);
Assert.IsNotNull(response.Body);
Assert.That(response, Is.Not.Null);
Assert.That(response.Body, Is.Not.Null);
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
Assert.IsInstanceOf<ApplicationError>(response.Body);
Assert.That(response.Body, Is.InstanceOf<ApplicationError>());
Assert.That(response.Body.Code, Is.EqualTo(10));
Assert.That(response.Body.Message, Is.EqualTo("Error X"));
}
Expand All @@ -50,7 +50,7 @@ public void WhenDecodingMissingErrorStreamItReturnsNull()
{
using (var response = Session.Decode<ApplicationError>(ex))
{
Assert.IsNull(response);
Assert.That(response, Is.Null);
}
}
}
Expand Down
30 changes: 15 additions & 15 deletions Ramone.Tests/AsyncEventTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void CanDoAsyncEventRequest()
});

// Assert
Assert.IsTrue(ok);
Assert.That(ok, Is.True);
}


Expand All @@ -44,9 +44,9 @@ public void WhenExceptionIsThrownItIsPassedToErrorHandler()
{
request.AsyncEvent().OnError(error =>
{
Assert.IsNotNull(error);
Assert.IsNotNull(error.Exception);
Assert.IsNotNull(error.Response);
Assert.That(error, Is.Not.Null);
Assert.That(error.Exception, Is.Not.Null);
Assert.That(error.Response, Is.Not.Null);
wh.Set();
}).Get(r => { });
});
Expand Down Expand Up @@ -74,7 +74,7 @@ public void WhenExceptionIsThrownItAlsoCallsOnComplete()
});

// Assert
Assert.IsTrue(onErrorHandled);
Assert.That(onErrorHandled, Is.True);
}


Expand All @@ -101,7 +101,7 @@ public void ItCallsOnErrorWhenRequestingUnknownService()
});

// Assert
Assert.IsTrue(onErrorHandled);
Assert.That(onErrorHandled, Is.True);
}


Expand All @@ -123,9 +123,9 @@ public void WhenExceptionIsThrownInCallbackItCallsErrorHandlerWithRequestAsWellA
});
});

Assert.IsNotNull(error);
Assert.IsInstanceOf<InvalidOperationException>(error.Exception);
Assert.IsNotNull(error.Response);
Assert.That(error, Is.Not.Null);
Assert.That(error.Exception, Is.InstanceOf<InvalidOperationException>());
Assert.That(error.Response, Is.Not.Null);
}


Expand All @@ -150,9 +150,9 @@ public void CanCancelAsyncEventRequest()
});

// Assert
Assert.IsFalse(gotOk);
Assert.IsFalse(gotError);
Assert.IsTrue(gotComplete);
Assert.That(gotOk, Is.False);
Assert.That(gotError, Is.False);
Assert.That(gotComplete, Is.True);
}


Expand All @@ -177,9 +177,9 @@ public void ItIsSafeToCancelClosedAsyncEventRequest()
request.CancelAsync();

// Assert
Assert.IsTrue(gotOk);
Assert.IsFalse(gotError);
Assert.IsTrue(gotComplete);
Assert.That(gotOk, Is.True);
Assert.That(gotError, Is.False);
Assert.That(gotComplete, Is.True);
}
}
}
2 changes: 1 addition & 1 deletion Ramone.Tests/AuthenticationHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void WhenNoAuthorizationCodeIsSendItAsksForAuthorization_AsyncEvent()
});
});

Assert.IsNotNull(errorResponse);
Assert.That(errorResponse, Is.Not.Null);
Assert.That(errorResponse.StatusCode, Is.EqualTo(HttpStatusCode.Unauthorized));

// Will get called twice since it does not try to fix the access problem
Expand Down
Loading

0 comments on commit a1adcdf

Please sign in to comment.