-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ITenantRepository refactoring (#209)
* added GetAll to ITenantRepository removed GetByHost from ITenantRepository added ITenantHostRepository fix PostMan collection * remove cache for all tenants * put back GetByHost added repo test Co-authored-by: [email protected] <[email protected]>
- Loading branch information
1 parent
f68bc7e
commit 5744ce4
Showing
10 changed files
with
142 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
src/MultiTenancy/NBB.MultiTenancy.Abstractions/Repositories/BasicTenantRepository.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
test/UnitTests/MultiTenancy/NBB.MultiTenancy.Configuration.Tests/TenantRepositoryTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// Copyright (c) TotalSoft. | ||
// This source code is licensed under the MIT license. | ||
|
||
using FluentAssertions; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.Options; | ||
using NBB.MultiTenancy.Abstractions; | ||
using NBB.MultiTenancy.Abstractions.Configuration; | ||
using NBB.MultiTenancy.Abstractions.Context; | ||
using NBB.MultiTenancy.Abstractions.Options; | ||
using NBB.MultiTenancy.Abstractions.Repositories; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Text; | ||
using Xunit; | ||
|
||
|
||
namespace NBB.MultiTenancy.Configuration.Tests | ||
{ | ||
public class TenantRepositoryTests | ||
{ | ||
[Fact] | ||
public void get_all_tenants_should_work() | ||
{ | ||
// Arrange | ||
var myConfiguration = @"{ | ||
""MultiTenancy"": { | ||
""Defaults"": { | ||
""ConnectionStrings"": { | ||
""Leasing_Database"": { | ||
""Server"": ""server1"", | ||
""Database"": ""db1"", | ||
""UserName"": ""web"", | ||
""OtherParams"": ""MultipleActiveResultSets=true"" | ||
} | ||
} | ||
}, | ||
""Tenants"": [ | ||
{ | ||
""TenantId"": ""68a448a2-e7d8-4875-8127-f18668217eb6"", | ||
""ConnectionStrings"": { | ||
""Leasing_Database"": ""Server=server0;Database=lsngdbqa;User Id=web;Password=;MultipleActiveResultSets=true"" | ||
} | ||
}, | ||
{ | ||
""TenantId"": ""ef8d5362-9969-4e02-8794-0d1af56816f6"", | ||
""Code"": ""BCR"" | ||
}, | ||
{ | ||
""TenantId"": ""da84628a-2925-4b69-9116-a90dd5a72b1f"", | ||
""Code"": ""DEV"" | ||
} | ||
] | ||
} | ||
}"; | ||
|
||
var configuration = new ConfigurationBuilder() | ||
.AddInMemoryCollection() | ||
.AddJsonStream(new MemoryStream(Encoding.UTF8.GetBytes(myConfiguration))) | ||
.Build(); | ||
|
||
var tenancyHostingOptions = new TenancyHostingOptions() | ||
{ | ||
TenancyType = TenancyType.MultiTenant | ||
}; | ||
|
||
var options = new OptionsWrapper<TenancyHostingOptions>(tenancyHostingOptions); | ||
|
||
var repo = new ConfigurationTenantRepository(configuration, options); | ||
|
||
//arrange | ||
var all = repo.GetAll().GetAwaiter().GetResult(); | ||
|
||
// Assert | ||
all.Should().NotBeNull(); | ||
all.Should().NotBeEmpty(); | ||
all.Count.Should().Be(3); | ||
|
||
//all[0].TenantId.Should().Be(Guid.Parse("ef8d5362-9969-4e02-8794-0d1af56816f6")); | ||
//all[1].TenantId.Should().Be(Guid.Parse("68a448a2-e7d8-4875-8127-f18668217eb6")); | ||
//all[2].TenantId.Should().Be(Guid.Parse("da84628a-2925-4b69-9116-a90dd5a72b1f")); | ||
|
||
//all[0].Code.Should().Be("BCR"); | ||
//all[1].Code.Should().BeNull(); | ||
//all[2].Code.Should().Be("DEV"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters