Skip to content

Commit

Permalink
v3.6 released
Browse files Browse the repository at this point in the history
  • Loading branch information
zijianhuang committed Jun 16, 2024
1 parent 5d14a6b commit 49e8b3c
Show file tree
Hide file tree
Showing 24 changed files with 331 additions and 235 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/dotnetRelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,5 @@ jobs:
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release
# - name: Run DemoCoreWeb
# run: pwsh ./StartCoreWebApi.ps1
# - name: Check Ports
# run: netstat -lntu
- name: Test
run: dotnet test --no-build --verbosity normal --configuration Release
2 changes: 1 addition & 1 deletion DemoCoreWeb/DemoCoreWeb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Fonlow.WebApiClientGenCore" Version="7.5.1" />
<PackageReference Include="Fonlow.WebApiClientGenCore" Version="7.7.1" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion DotNetPack.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$packCmd = 'dotnet pack $Name --no-build --output C:/NugetLocalFeeds --configuration Release'
$packCmd = 'dotnet pack $Name --no-build --output ./Release --configuration Release'
$projList = 'Fonlow.Testing.HttpCore/Fonlow.Testing.HttpCore.csproj', 'Fonlow.Testing.ServiceCore/Fonlow.Testing.ServiceCore.csproj'
foreach($name in $projList){
Invoke-Expression $ExecutionContext.InvokeCommand.ExpandString($packCmd)
Expand Down
1 change: 1 addition & 0 deletions Fonlow.Testing.HttpCore/AuthHttpClients.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace Fonlow.Testing
/// <summary>
/// A dictionary of HttpClientWithUserName
/// </summary>
[Obsolete("In favour of derived classes of HttpClientWithUsername in the integration test suites")]
public class AuthHttpClients: IDisposable
{
public AuthHttpClients() : this(null)
Expand Down
1 change: 1 addition & 0 deletions Fonlow.Testing.HttpCore/DefaultHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace Fonlow.Testing
/// <summary>
/// HttpClient wrapped read test settings from appsettings.json, and ignore SSL certificates.
/// </summary>
[Obsolete("In favour of BasicHttpClient")]
public class DefaultHttpClient : IDisposable
{
public DefaultHttpClient(HttpMessageHandler handler)
Expand Down
1 change: 1 addition & 0 deletions Fonlow.Testing.HttpCore/DefaultHttpClientWithUsername.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace Fonlow.Testing
/// Provide an authorized HttpClient instance with uri and username/password defined in appsettings.json:
/// BaseUrl, Username and Password.
/// </summary>
[Obsolete("In favour of ServiceCommand along with its username/password pairs")]
public class DefaultHttpClientWithUsername : HttpClientWithUsername
{
public DefaultHttpClientWithUsername() : this(null)
Expand Down
68 changes: 32 additions & 36 deletions Fonlow.Testing.HttpCore/Fonlow.Testing.HttpCore.csproj
Original file line number Diff line number Diff line change
@@ -1,36 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<Authors>Zijian Huang</Authors>
<Description>Setup http client resources</Description>
<Copyright>Copyright © Fonlow 2015-$([System.DateTime]::Now.Year)</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/zijianhuang/FonlowTesting</PackageProjectUrl>
<PackageTags>xunit nunit mstest unittesting iisexpress iis webapi restful dotnet</PackageTags>
<NeutralLanguage>en</NeutralLanguage>
<Version>3.4</Version>
<PackageReleaseNotes>Upgraded to .NET 8.</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
<AnalysisLevel>latest-all</AnalysisLevel>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<CopyDebugSymbolFilesFromPackages>true</CopyDebugSymbolFilesFromPackages>
<CopyDocumentationFilesFromPackages>true</CopyDocumentationFilesFromPackages>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<Authors>Zijian Huang</Authors>
<Description>Setup http client resources</Description>
<Copyright>Copyright © Fonlow 2015-$([System.DateTime]::Now.Year)</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/zijianhuang/FonlowTesting</PackageProjectUrl>
<PackageTags>xunit nunit mstest unittesting iisexpress iis webapi restful dotnet</PackageTags>
<NeutralLanguage>en</NeutralLanguage>
<Version>3.4</Version>
<PackageReleaseNotes>Upgraded to .NET 8.</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
<AnalysisLevel>latest-all</AnalysisLevel>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<CopyDebugSymbolFilesFromPackages>true</CopyDebugSymbolFilesFromPackages>
<CopyDocumentationFilesFromPackages>true</CopyDocumentationFilesFromPackages>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<None Include="..\README.md" Pack="true" PackagePath="\" />
</ItemGroup>
</Project>
5 changes: 3 additions & 2 deletions Fonlow.Testing.HttpCore/HttpClientWithUsername.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Http;
using Newtonsoft.Json.Linq;
using System.Text.Json.Nodes;
//using Newtonsoft.Json.Linq;

namespace Fonlow.Testing
{
Expand Down Expand Up @@ -102,7 +103,7 @@ void AnalyzeToken()
if (String.IsNullOrEmpty(text))
return;

var jObject = JObject.Parse(text);
var jObject = JsonObject.Parse(text);
var accessTokenObject = jObject["access_token"];
var expiriesInObject = jObject["expires_in"];
var tokenTypeObject = jObject["token_type"];
Expand Down
5 changes: 0 additions & 5 deletions Fonlow.Testing.HttpCore/README.md

This file was deleted.

51 changes: 48 additions & 3 deletions Fonlow.Testing.HttpCore/TestingSettings.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;

namespace Fonlow.Testing
{
/// <summary>
/// Data model of the "Testing" section "appsettings.json" and optionally "appsettings.BuildConfiguration.json";
/// and the singleton object to access the settings read from the JSON files
/// </summary>
public sealed class TestingSettings
{
private TestingSettings()
Expand Down Expand Up @@ -40,8 +46,41 @@ static TestingSettings Create()

static string GetBuildConfiguration()
{
var assemblyConfigurationAttribute = Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyConfigurationAttribute>();
return assemblyConfigurationAttribute?.Configuration;
var executingAssembly = Assembly.GetExecutingAssembly();
var location = executingAssembly.Location;
var dir = Path.GetDirectoryName(location);
var pathNames = Directory.GetFiles(dir, "*.dll");
List<Assembly> testAssemblies = new List<Assembly>();
foreach (var p in pathNames)
{
try
{
var a = Assembly.LoadFile(p);
var referencedAssemblies = a.GetReferencedAssemblies();
if (referencedAssemblies.Any(d => d.Name == "xunit.core") && !Path.GetFileName(p).StartsWith("xunit.", StringComparison.OrdinalIgnoreCase))
{
testAssemblies.Add(a);
}
}
catch (FileLoadException)
{
continue;
}
catch (BadImageFormatException)
{
continue;
}
}

if (testAssemblies.Count > 0)
{
var assemblyConfigurationAttribute = testAssemblies[0].GetCustomAttribute<AssemblyConfigurationAttribute>();
return assemblyConfigurationAttribute?.Configuration;
}
else
{
return "Debug";
}
}
}

Expand Down Expand Up @@ -86,7 +125,7 @@ static string GetBuildConfiguration()

/// <summary>
/// Build configuration such as Debug, Release or whatever custom build configuration.
/// ServiceCommandFixture will replace {BuildConfiguration} in arguments with this.
/// ServiceCommandFixture will replace {BuildConfiguration} in commandPath and arguments with this.
/// </summary>
public string BuildConfiguration { get; private set; }
}
Expand All @@ -108,5 +147,11 @@ public sealed class ServiceCommand
public int Delay { get; set; }
public string ConnectionString { get; set; }
public string BaseUrl { get; set; }

/// <summary>
/// For testing with many different user credentials with different authorization.
/// </summary>
/// <remarks>Obviously 2FA and alike are not welcome. Good enough for integration tests, but not E2E.</remarks>
public UsernamePassword[] Users { get; set; }
}
}
4 changes: 4 additions & 0 deletions Fonlow.Testing.ServiceCore/DeploymentItemFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

namespace Fonlow.Testing
{
/// <summary>
/// Copy files from source to destination. If file exists, copy only newer.
/// </summary>
[Obsolete("In favour of PowerShell scripts")]
public class DeploymentItemFixture
{
public DeploymentItemFixture()
Expand Down
56 changes: 29 additions & 27 deletions Fonlow.Testing.ServiceCore/DirFunctions.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
using System.IO;
using System.Linq;

namespace Fonlow.Testing
using System;
using System.IO;
using System.Linq;

namespace Fonlow.Testing
{
public static class DirFunctions
{
public static class DirFunctions
{
/// <summary>
/// Get Visual Studio Sln dir.
/// </summary>
/// <param name="dir"></param>
/// <returns></returns>
public static DirectoryInfo GetSlnDir(string dir)
{
var d = new DirectoryInfo(dir);

DirectoryInfo[] ds;
do
{
d = d.Parent;
if (d == null)
break;

ds = d.EnumerateDirectories(".vs", SearchOption.TopDirectoryOnly).ToArray();
}
while (ds.Length == 0);

return d;
}

}
}
/// <returns></returns>
[Obsolete("IIS Legacy")]
public static DirectoryInfo GetSlnDir(string dir)
{
var d = new DirectoryInfo(dir);

DirectoryInfo[] ds;
do
{
d = d.Parent;
if (d == null)
break;

ds = d.EnumerateDirectories(".vs", SearchOption.TopDirectoryOnly).ToArray();
}
while (ds.Length == 0);

return d;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@

<ItemGroup>
<ProjectReference Include="..\Fonlow.Testing.HttpCore\Fonlow.Testing.HttpCore.csproj" />
<None Include="README.md" Pack="true" PackagePath="\" />
<None Include="..\README.md" Pack="true" PackagePath="\" />
</ItemGroup>
</Project>
32 changes: 16 additions & 16 deletions Fonlow.Testing.ServiceCore/IisExpressAgent.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using System;

namespace Fonlow.Testing
using System;

namespace Fonlow.Testing
{
/// <summary>
/// To be used alone without fixture.
/// </summary>
[Obsolete("In favor of ServiceCommandAgent")]
public class IisExpressAgent: IisExpressAgentBase
{
public IisExpressAgent(): base(TestingSettings.Instance.HostSite, TestingSettings.Instance.HostSiteApplicationPool,
TestingSettings.Instance.SlnName, TestingSettings.Instance.SlnRoot)
{

}
}
}
/// <summary>
/// To be used alone without fixture.
/// </summary>
[Obsolete("In favor of ServiceCommandAgent")]
public class IisExpressAgent: IisExpressAgentBase
{
public IisExpressAgent(): base(TestingSettings.Instance.HostSite, TestingSettings.Instance.HostSiteApplicationPool,
TestingSettings.Instance.SlnName, TestingSettings.Instance.SlnRoot)
{

}
}
}
12 changes: 6 additions & 6 deletions Fonlow.Testing.ServiceCore/IisExpressAgentBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

namespace Fonlow.Testing
{
/// <summary>
/// For starting and stoping IIS Express
/// </summary>
/// <remarks>The IIS Express config is at </remarks>
[Obsolete("In favor of ServiceCommandAgent")]
public class IisExpressAgentBase
/// <summary>
/// For starting and stoping IIS Express
/// </summary>
/// <remarks>The IIS Express config is at </remarks>
[Obsolete("In favor of ServiceCommandAgent")]
public class IisExpressAgentBase
{
public IisExpressAgentBase(string hostSite, string hostSiteApplicationPool, string slnName, string slnRoot)
{
Expand Down
26 changes: 13 additions & 13 deletions Fonlow.Testing.ServiceCore/IisExpressFixture.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using System;

namespace Fonlow.Testing
{
[Obsolete("In favor of ServiceCommandFixture")]
public class IisExpressFixture : IisExpressFixtureBase
{
public IisExpressFixture(): base(!String.IsNullOrWhiteSpace(TestingSettings.Instance.HostSite))
{

}
}
}
using System;

namespace Fonlow.Testing
{
[Obsolete("In favor of ServiceCommandFixture")]
public class IisExpressFixture : IisExpressFixtureBase
{
public IisExpressFixture(): base(!String.IsNullOrWhiteSpace(TestingSettings.Instance.HostSite))
{

}
}
}
Loading

0 comments on commit 49e8b3c

Please sign in to comment.