Skip to content

Commit

Permalink
Merge pull request #13 from axuno/v4.3.0_MultiTenancy
Browse files Browse the repository at this point in the history
V4.3.0 multi tenancy
  • Loading branch information
axunonb authored Jan 2, 2021
2 parents 40ffa54 + 047441f commit 9a6b63e
Show file tree
Hide file tree
Showing 217 changed files with 3,098 additions and 2,852 deletions.
38 changes: 19 additions & 19 deletions Axuno.Tools/DateAndTime/TimeZoneConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using NodaTime;
using NodaTime.TimeZones;
using TzConverter = TimeZoneConverter;

#nullable enable
namespace Axuno.Tools.DateAndTime
{
/// <summary>
Expand All @@ -18,8 +18,8 @@ public class TimeZoneConverter
{
private readonly IDateTimeZoneProvider _dateTimeZoneProvider;
private readonly string _timeZoneId;
private readonly CultureInfo _cultureInfo;
private readonly ZoneLocalMappingResolver _resolver;
private readonly CultureInfo? _cultureInfo;
private readonly ZoneLocalMappingResolver? _resolver;

/// <summary>
/// CTOR.
Expand All @@ -29,7 +29,7 @@ public class TimeZoneConverter
/// <param name="cultureInfo">The <see cref="CultureInfo"/> to use for converting.</param>
/// <param name="resolver">The <see cref="ZoneLocalMappingResolver"/> to use for converting.</param>
public TimeZoneConverter(IDateTimeZoneProvider dateTimeZoneProvider, TimeZoneInfo timeZoneInfo,
CultureInfo cultureInfo = null, ZoneLocalMappingResolver resolver = null) : this(dateTimeZoneProvider,
CultureInfo? cultureInfo = null, ZoneLocalMappingResolver? resolver = null) : this(dateTimeZoneProvider,
TzConverter.TZConvert.WindowsToIana(timeZoneInfo.Id), cultureInfo, resolver)
{}

Expand All @@ -41,7 +41,7 @@ public TimeZoneConverter(IDateTimeZoneProvider dateTimeZoneProvider, TimeZoneInf
/// <param name="cultureInfo">The <see cref="CultureInfo"/> to use for converting.</param>
/// <param name="resolver">The <see cref="ZoneLocalMappingResolver"/> to use for converting.</param>
public TimeZoneConverter(IDateTimeZoneProvider dateTimeZoneProvider, string ianaTimeZoneId,
CultureInfo cultureInfo = null, ZoneLocalMappingResolver resolver = null)
CultureInfo? cultureInfo = null, ZoneLocalMappingResolver? resolver = null)
{
_dateTimeZoneProvider = dateTimeZoneProvider;
_timeZoneId = ianaTimeZoneId;
Expand All @@ -56,7 +56,7 @@ public TimeZoneConverter(IDateTimeZoneProvider dateTimeZoneProvider, string iana
/// <param name="dateTimeOfAnyKind"></param>
/// <param name="cultureInfo">The <see cref="CultureInfo"/> to use for time zone localization. If <see langword="null"/>, the default culture will be used.</param>
/// <returns>Returns the converted <see cref="DateTime"/> as a <see cref="ZonedTime"/> instance or null, if the <see cref="dateTimeOfAnyKind"/> parameter is null.</returns>
public ZonedTime ToZonedTime(DateTime? dateTimeOfAnyKind, CultureInfo? cultureInfo = null)
public ZonedTime? ToZonedTime(DateTime? dateTimeOfAnyKind, CultureInfo? cultureInfo = null)
{
return ToZonedTime(dateTimeOfAnyKind, _timeZoneId, cultureInfo ?? _cultureInfo, _dateTimeZoneProvider);
}
Expand All @@ -68,7 +68,7 @@ public ZonedTime ToZonedTime(DateTime? dateTimeOfAnyKind, CultureInfo? cultureIn
/// <param name="dateTimeOfAnyKind"></param>
/// <param name="cultureInfo">The <see cref="CultureInfo"/> to use for time zone localization. If <see langword="null"/>, the default culture will be used.</param>
/// <returns>Returns the converted <see cref="DateTime"/> as a <see cref="ZonedTime"/> instance.</returns>
public ZonedTime ToZonedTime(DateTime dateTimeOfAnyKind, CultureInfo? cultureInfo = null)
public ZonedTime? ToZonedTime(DateTime dateTimeOfAnyKind, CultureInfo? cultureInfo = null)
{
return ToZonedTime(dateTimeOfAnyKind, _timeZoneId, cultureInfo ?? _cultureInfo, _dateTimeZoneProvider);
}
Expand Down Expand Up @@ -131,8 +131,8 @@ public DateTime ToUtc(DateTime zoneDateTime, string timeZoneId)
/// </param>
/// <returns>Returns the converted <see cref="DateTime"/> as a <see cref="ZonedTime"/> instance or null, if the <see cref="dateTimeOfAnyKind"/> parameter is null.</returns>
/// <exception cref="DateTimeZoneNotFoundException">If <see cref="timeZoneId"/> is unknown.</exception>
public static ZonedTime ToZonedTime(DateTime? dateTimeOfAnyKind, string timeZoneId,
CultureInfo cultureInfo = null, IDateTimeZoneProvider timeZoneProvider = null)
public static ZonedTime? ToZonedTime(DateTime? dateTimeOfAnyKind, string timeZoneId,
CultureInfo? cultureInfo = null, IDateTimeZoneProvider? timeZoneProvider = null)
{
if (!dateTimeOfAnyKind.HasValue) return null;

Expand Down Expand Up @@ -167,8 +167,8 @@ public static ZonedTime ToZonedTime(DateTime? dateTimeOfAnyKind, string timeZone
/// </param>
/// <returns>Returns the converted <see cref="DateTime"/> as a <see cref="ZonedTime"/> instance.</returns>
/// <exception cref="DateTimeZoneNotFoundException">If <see cref="timeZoneId"/> is unknown.</exception>
public static ZonedTime ToZonedTime(DateTime dateTimeOfAnyKind, string timeZoneId,
CultureInfo cultureInfo = null, IDateTimeZoneProvider timeZoneProvider = null)
public static ZonedTime? ToZonedTime(DateTime dateTimeOfAnyKind, string timeZoneId,
CultureInfo? cultureInfo = null, IDateTimeZoneProvider? timeZoneProvider = null)
{
return ToZonedTime((DateTime?) dateTimeOfAnyKind, timeZoneId, cultureInfo, timeZoneProvider);
}
Expand All @@ -186,8 +186,8 @@ public static ZonedTime ToZonedTime(DateTime dateTimeOfAnyKind, string timeZoneI
/// </param>
/// <returns>Returns the converted <see cref="Nullable{DateTimeOffset}"/> as a <see cref="ZonedTime"/> instance or null, if the <see cref="dateTimeOffset"/> parameter is null.</returns>
/// <exception cref="DateTimeZoneNotFoundException">If IANA <see cref="timeZoneId"/> is unknown.</exception>
public static ZonedTime ToZonedTime(DateTimeOffset? dateTimeOffset, string timeZoneId,
CultureInfo cultureInfo = null, IDateTimeZoneProvider timeZoneProvider = null)
public static ZonedTime? ToZonedTime(DateTimeOffset? dateTimeOffset, string timeZoneId,
CultureInfo? cultureInfo = null, IDateTimeZoneProvider? timeZoneProvider = null)
{
if (!dateTimeOffset.HasValue) return null;

Expand Down Expand Up @@ -236,8 +236,8 @@ public static ZonedTime ToZonedTime(DateTimeOffset? dateTimeOffset, string timeZ
/// </param>
/// <returns>Returns the converted <see cref="Nullable{DateTimeOffset}"/> as a <see cref="ZonedTime"/> instance.</returns>
/// <exception cref="DateTimeZoneNotFoundException">If IANA <see cref="timeZoneId"/> is unknown.</exception>
public static ZonedTime ToZonedTime(DateTimeOffset dateTimeOffset, string timeZoneId,
CultureInfo cultureInfo = null, IDateTimeZoneProvider timeZoneProvider = null)
public static ZonedTime? ToZonedTime(DateTimeOffset dateTimeOffset, string timeZoneId,
CultureInfo? cultureInfo = null, IDateTimeZoneProvider? timeZoneProvider = null)
{
return ToZonedTime((DateTimeOffset?) dateTimeOffset, timeZoneId, cultureInfo, timeZoneProvider);
}
Expand All @@ -252,7 +252,7 @@ public static ZonedTime ToZonedTime(DateTimeOffset dateTimeOffset, string timeZo
/// <returns>Returns the converted <see cref="DateTime"/> with <see cref="DateTimeKind.Utc"/> or null, if the <see cref="zoneDateTime"/> parameter is null.</returns>
/// <exception cref="DateTimeZoneNotFoundException">If <see cref="timeZoneId"/> is unknown.</exception>
public static DateTime? ToUtc(DateTime? zoneDateTime, string timeZoneId,
IDateTimeZoneProvider timeZoneProvider, ZoneLocalMappingResolver resolver = null)
IDateTimeZoneProvider? timeZoneProvider, ZoneLocalMappingResolver? resolver = null)
{
if (!zoneDateTime.HasValue) return null;

Expand All @@ -277,9 +277,9 @@ public static ZonedTime ToZonedTime(DateTimeOffset dateTimeOffset, string timeZo
/// <returns>Returns the converted <see cref="DateTime"/> with <see cref="DateTimeKind.Utc"/>.</returns>
/// <exception cref="DateTimeZoneNotFoundException">If <see cref="timeZoneId"/> is unknown.</exception>
public static DateTime ToUtc(DateTime zoneDateTime, string timeZoneId,
IDateTimeZoneProvider timeZoneProvider, ZoneLocalMappingResolver resolver = null)
IDateTimeZoneProvider timeZoneProvider, ZoneLocalMappingResolver? resolver = null)
{
return ToUtc((DateTime?)zoneDateTime, timeZoneId, timeZoneProvider, resolver).Value;
return ToUtc((DateTime?)zoneDateTime, timeZoneId, timeZoneProvider, resolver)!.Value;
}

/// <summary>
Expand All @@ -297,7 +297,7 @@ public static bool CanMapToIanaTimeZone(TimeZoneInfo timeZoneInfo)
/// </summary>
/// <param name="timeZoneProvider">The <see cref="IDateTimeZoneProvider"/> to use. Default is <see cref="DateTimeZoneProviders.Tzdb"/>.</param>
/// <returns>Returns a collection of available <see cref="IDateTimeZoneProvider.Ids"/>.</returns>
public static IReadOnlyCollection<string> GetTimeZoneList(IDateTimeZoneProvider timeZoneProvider = null)
public static IReadOnlyCollection<string> GetTimeZoneList(IDateTimeZoneProvider? timeZoneProvider = null)
{
timeZoneProvider ??= DateTimeZoneProviders.Tzdb;
return timeZoneProvider.Ids;
Expand Down
2 changes: 1 addition & 1 deletion Axuno.Tools/Password/Password.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static bool Verify(string password, string hashcode, bool throwOnIllegalA
if (hashBytes[i + 16] != hash[i])
return false;
}
catch (Exception e)
catch (Exception)
{
if (throwOnIllegalArgs)
throw;
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2000 - 2020 axuno gGbmH
Copyright (c) 2000 - 2021 axuno gGbmH and Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 0 additions & 1 deletion League.Test/Controllers/AccountControllerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public class AccountControllerTest : ControllerTestBase
{
private readonly IStringLocalizer<Account> _mockLocalizer;
private Account _controller;
private ViewResult _result;

public AccountControllerTest()
{
Expand Down
11 changes: 1 addition & 10 deletions League.Test/Controllers/ControllerTestBase.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
using System;
using System.Net.Http;
using System.Reflection;
using League.Test.TestComponents;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.ApplicationParts;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.ViewComponents;
using Microsoft.AspNetCore.TestHost;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection;
using NUnit.Framework;

namespace League.Test.Controllers
Expand All @@ -20,10 +13,8 @@ public class ControllerTestBase : IDisposable

// see: https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/testing?view=aspnetcore-2.1 and
// https://docs.microsoft.com/en-us/dotnet/core/testing/unit-testing-with-nunit?view=aspnetcore-2.1

protected ControllerTestBase()
public ControllerTestBase()
{

var appFactory = new WebApplicationFactory<Startup>().WithWebHostBuilder(builder =>
{
builder.ConfigureServices(services =>
Expand Down
7 changes: 2 additions & 5 deletions League.Test/Identity/RoleStoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
using System.Security.Claims;
using System.Threading.Tasks;
using System.Threading;
using League.DI;
using League.Identity;
using NUnit.Framework;
using SD.LLBLGen.Pro.ORMSupportClasses;
using TournamentManager.Data;
using TournamentManager.DAL.EntityClasses;
using TournamentManager.DAL.DatabaseSpecific;
using TournamentManager.MultiTenancy;

namespace League.Test.Identity
{
Expand All @@ -22,15 +21,13 @@ namespace League.Test.Identity
public class RoleStoreTests
{
private readonly UnitTestHelpers _uth = new UnitTestHelpers();
private readonly SiteContext _orgCtx;
private readonly AppDb _appDb;
private readonly RoleStore _roleStore;
private readonly UserStore _userStore;

public RoleStoreTests()
{
_orgCtx = _uth.GetsiteContext();
_appDb = _orgCtx.AppDb;
_appDb = _uth.GetTenantContext().DbContext.AppDb;
_userStore = _uth.GetUserStore();
_roleStore = _uth.GetRoleStore();
}
Expand Down
6 changes: 2 additions & 4 deletions League.Test/Identity/UserAuthenticationTokenStoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
using System.Data;
using System.Threading.Tasks;
using System.Threading;
using League.DI;
using League.Identity;
using NUnit.Framework;
using TournamentManager.DAL.DatabaseSpecific;
using TournamentManager.Data;
using TournamentManager.DAL.EntityClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;
using TournamentManager.MultiTenancy;

namespace League.Test.Identity
{
Expand All @@ -20,14 +20,12 @@ namespace League.Test.Identity
public class UserAuthenticationTokenStoreTests
{
private readonly UnitTestHelpers _uth = new UnitTestHelpers();
private readonly SiteContext _orgCtx;
private readonly AppDb _appDb;
private readonly UserStore _store;

public UserAuthenticationTokenStoreTests()
{
_orgCtx = _uth.GetsiteContext();
_appDb = _orgCtx.AppDb;
_appDb = _uth.GetTenantContext().DbContext.AppDb;
_store = _uth.GetUserStore();
}

Expand Down
6 changes: 2 additions & 4 deletions League.Test/Identity/UserClaimStoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
using System.Security.Claims;
using System.Threading.Tasks;
using System.Threading;
using League.DI;
using League.Identity;
using NUnit.Framework;
using SD.LLBLGen.Pro.ORMSupportClasses;
using TournamentManager.Data;
using TournamentManager.DAL.EntityClasses;
using TournamentManager.DAL.DatabaseSpecific;
using TournamentManager.MultiTenancy;

namespace League.Test.Identity
{
Expand All @@ -22,15 +22,13 @@ namespace League.Test.Identity
public class UserClaimStoreTests
{
private readonly UnitTestHelpers _uth = new UnitTestHelpers();
private readonly SiteContext _orgCtx;
private readonly AppDb _appDb; private ApplicationUser _user = null;
private readonly UserStore _store;
private TeamEntity _team = null;

public UserClaimStoreTests()
{
_orgCtx = _uth.GetsiteContext();
_appDb = _orgCtx.AppDb;
_appDb = _uth.GetTenantContext().DbContext.AppDb;
_store = _uth.GetUserStore();
}

Expand Down
6 changes: 2 additions & 4 deletions League.Test/Identity/UserLoginStoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
using System.Linq;
using System.Threading.Tasks;
using System.Threading;
using League.DI;
using League.Identity;
using NUnit.Framework;
using TournamentManager.DAL.DatabaseSpecific;
using TournamentManager.Data;
using TournamentManager.DAL.EntityClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;
using TournamentManager.MultiTenancy;

namespace League.Test.Identity
{
Expand All @@ -21,15 +21,13 @@ namespace League.Test.Identity
public class UserLoginStoreTests
{
private readonly UnitTestHelpers _uth = new UnitTestHelpers();
private readonly SiteContext _orgCtx;
private readonly AppDb _appDb;
private readonly UserStore _store;
private readonly RoleStore _roleStore;

public UserLoginStoreTests()
{
_orgCtx = _uth.GetsiteContext();
_appDb = _orgCtx.AppDb;
_appDb = _uth.GetTenantContext().DbContext.AppDb;
_store = _uth.GetUserStore();
_roleStore = _uth.GetRoleStore();
}
Expand Down
6 changes: 2 additions & 4 deletions League.Test/Identity/UserRoleStoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Linq;
using System.Threading.Tasks;
using System.Threading;
using League.DI;
using League.Identity;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization;
Expand All @@ -14,6 +13,7 @@
using TournamentManager.Data;
using TournamentManager.DAL.EntityClasses;
using TournamentManager.DAL.HelperClasses;
using TournamentManager.MultiTenancy;

namespace League.Test.Identity
{
Expand All @@ -24,15 +24,13 @@ namespace League.Test.Identity
public class UserRoleStoreTests
{
private readonly UnitTestHelpers _uth = new UnitTestHelpers();
private readonly SiteContext _orgCtx;
private readonly AppDb _appDb;
private readonly UserStore _userStore;
private ApplicationUser _user = null;

public UserRoleStoreTests()
{
_orgCtx = _uth.GetsiteContext();
_appDb = _orgCtx.AppDb;
_appDb = _uth.GetTenantContext().DbContext.AppDb;
_userStore = _uth.GetUserStore();
}

Expand Down
7 changes: 2 additions & 5 deletions League.Test/Identity/UserStoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
using System.Data;
using System.Threading.Tasks;
using System.Threading;
using League.DI;
using League.Identity;
using NUnit.Framework;
using TournamentManager.DAL.DatabaseSpecific;
using TournamentManager.Data;
using TournamentManager.DAL.EntityClasses;
using TournamentManager.MultiTenancy;

namespace League.Test.Identity
{
Expand All @@ -19,15 +18,13 @@ namespace League.Test.Identity
public class UserStoreTests
{
private readonly UnitTestHelpers _uth = new UnitTestHelpers();
private readonly SiteContext _orgCtx;
private readonly AppDb _appDb;
private readonly UserStore _store;
private readonly RoleStore _roleStore;

public UserStoreTests()
{
_orgCtx = _uth.GetsiteContext();
_appDb = _orgCtx.AppDb;
_appDb = _uth.GetTenantContext().DbContext.AppDb;
_store = _uth.GetUserStore();
_roleStore = _uth.GetRoleStore();
}
Expand Down
11 changes: 6 additions & 5 deletions League.Test/League.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.10" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="2.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1">
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.1.5" />
<PackageReference Include="Moq" Version="4.14.1" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.1.10" />
<PackageReference Include="Moq" Version="4.15.2" />
<PackageReference Include="ObjectsComparer" Version="1.4.1" />
</ItemGroup>

Expand Down
Loading

0 comments on commit 9a6b63e

Please sign in to comment.