Skip to content

Commit af3bd13

Browse files
committed
Added generic attributes
1 parent 05406e9 commit af3bd13

File tree

15 files changed

+140
-10
lines changed

15 files changed

+140
-10
lines changed

Branding.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CoreHelpers.Branding.AspNet
1818
EndProject
1919
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CoreHelpers.Branding.Stores.AzureStorage.Tests", "CoreHelpers.Branding.Stores.AzureStorage.Tests\CoreHelpers.Branding.Stores.AzureStorage.Tests.csproj", "{802BB680-BF47-4B74-A7DF-3FC81B07D6E9}"
2020
EndProject
21+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CoreHelpers.Branding.Runtime.Tests", "CoreHelpers.Branding.Runtime.Tests\CoreHelpers.Branding.Runtime.Tests.csproj", "{7C362EF5-CD21-4A26-835C-24AB6194A614}"
22+
EndProject
2123
Global
2224
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2325
Debug|Any CPU = Debug|Any CPU
@@ -44,6 +46,10 @@ Global
4446
{802BB680-BF47-4B74-A7DF-3FC81B07D6E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
4547
{802BB680-BF47-4B74-A7DF-3FC81B07D6E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
4648
{802BB680-BF47-4B74-A7DF-3FC81B07D6E9}.Release|Any CPU.Build.0 = Release|Any CPU
49+
{7C362EF5-CD21-4A26-835C-24AB6194A614}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
50+
{7C362EF5-CD21-4A26-835C-24AB6194A614}.Debug|Any CPU.Build.0 = Debug|Any CPU
51+
{7C362EF5-CD21-4A26-835C-24AB6194A614}.Release|Any CPU.ActiveCfg = Release|Any CPU
52+
{7C362EF5-CD21-4A26-835C-24AB6194A614}.Release|Any CPU.Build.0 = Release|Any CPU
4753
EndGlobalSection
4854
GlobalSection(SolutionProperties) = preSolution
4955
HideSolutionNode = FALSE

CoreHelpers.Branding.Runtime.Abstractions/ICompanyBranding.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,19 @@ public interface ICompanyBrandingColors
2525
string Primary { get; }
2626
string PrimaryHover { get; }
2727
string PrimaryFont { get; }
28-
}
29-
28+
}
29+
3030
public interface ICompanyBranding
3131
{
32-
string Name { get; }
32+
string Name { get; }
3333

3434
Dictionary<nLogoSize, string> Logos { get; }
3535

3636
Dictionary<nLegalItems, string> Legals { get; }
3737

3838
ICompanyBrandingColors Colors { get; }
39+
40+
Dictionary<string, string> Attributes { get; }
3941
}
4042
}
4143

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
namespace CoreHelpers.Branding.Runtime.Tests;
2+
3+
using CoreHelpers.Branding.Runtime.Services;
4+
5+
public class BrandingBuilderTests
6+
{
7+
[Fact]
8+
public void TestLogos()
9+
{
10+
var builder = new BrandingBuilder();
11+
Assert.Equal("small", builder.AddLogo(nLogoSize.small, "small").Build().Logos[nLogoSize.small]);
12+
Assert.Equal("medium", builder.AddLogo(nLogoSize.medium, "medium").Build().Logos[nLogoSize.medium]);
13+
Assert.Equal("large", builder.AddLogo(nLogoSize.large, "large").Build().Logos[nLogoSize.large]);
14+
Assert.Equal("fav16", builder.AddLogo(nLogoSize.fav16, "fav16").Build().Logos[nLogoSize.fav16]);
15+
Assert.Equal("fav32", builder.AddLogo(nLogoSize.fav32, "fav32").Build().Logos[nLogoSize.fav32]);
16+
}
17+
18+
[Fact]
19+
public void TestLegals()
20+
{
21+
var builder = new BrandingBuilder();
22+
Assert.Equal("IMPRINT", builder.AddLegal(nLegalItems.imprint, "IMPRINT").Build().Legals[nLegalItems.imprint]);
23+
Assert.Equal("DP", builder.AddLegal(nLegalItems.dataPrivacy, "DP").Build().Legals[nLegalItems.dataPrivacy]);
24+
}
25+
26+
[Fact]
27+
public void TestAttributes()
28+
{
29+
var builder = new BrandingBuilder();
30+
Assert.Equal("demo", builder.AddAttribute("attr01", "demo").Build().Attributes["attr01"]);
31+
}
32+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
8+
<IsPackable>false</IsPackable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
13+
<PackageReference Include="xunit" Version="2.4.1" />
14+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
15+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
16+
<PrivateAssets>all</PrivateAssets>
17+
</PackageReference>
18+
<PackageReference Include="coverlet.collector" Version="3.1.2">
19+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
20+
<PrivateAssets>all</PrivateAssets>
21+
</PackageReference>
22+
</ItemGroup>
23+
24+
<ItemGroup>
25+
<ProjectReference Include="..\CoreHelpers.Branding.Runtime\CoreHelpers.Branding.Runtime.csproj" />
26+
</ItemGroup>
27+
</Project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
global using Xunit;

CoreHelpers.Branding.Runtime/CoreHelpers.Branding.Runtime.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414

1515
<ItemGroup>
1616
<None Remove="Services\" />
17+
<None Remove="Properties\" />
1718
</ItemGroup>
1819
<ItemGroup>
1920
<Folder Include="Services\" />
21+
<Folder Include="Properties\" />
2022
</ItemGroup>
2123
<ItemGroup>
2224
<ProjectReference Include="..\CoreHelpers.Branding.Runtime.Abstractions\CoreHelpers.Branding.Runtime.Abstractions.csproj" />
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
4+
[assembly: InternalsVisibleTo("CoreHelpers.Branding.Runtime.Tests")]

CoreHelpers.Branding.Runtime/Services/BrandingBuilder.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace CoreHelpers.Branding.Runtime.Services
55
{
6-
public class BrandingBuilderColorModel : ICompanyBrandingColors
6+
internal class BrandingBuilderColorModel : ICompanyBrandingColors
77
{
88
public string Font { get; set; } = string.Empty;
99

@@ -18,7 +18,7 @@ public class BrandingBuilderColorModel : ICompanyBrandingColors
1818
public string PrimaryFont { get; set; } = string.Empty;
1919
}
2020

21-
public class BrandingBuilderModel : ICompanyBranding
21+
internal class BrandingBuilderModel : ICompanyBranding
2222
{
2323
public string Name { get; set; } = string.Empty;
2424

@@ -27,9 +27,11 @@ public class BrandingBuilderModel : ICompanyBranding
2727
public Dictionary<nLegalItems, string> Legals { get; } = new Dictionary<nLegalItems, string>();
2828

2929
public ICompanyBrandingColors Colors { get; set; } = new BrandingBuilderColorModel();
30+
31+
public Dictionary<string, string> Attributes { get; set; } = new Dictionary<string, string>();
3032
}
31-
32-
public class BrandingBuilder : IBrandingBuilder
33+
34+
internal class BrandingBuilder : IBrandingBuilder
3335
{
3436
private BrandingBuilderModel model = new BrandingBuilderModel();
3537
private BrandingBuilderColorModel colorModel = new BrandingBuilderColorModel();
@@ -93,6 +95,16 @@ public IBrandingBuilder SetColor(nColorType colorType, string colorValue)
9395
return this;
9496
}
9597

98+
public IBrandingBuilder AddAttribute(string key, string value)
99+
{
100+
if (model.Attributes.ContainsKey(key))
101+
model.Attributes[key] = value;
102+
else
103+
model.Attributes.Add(key, value);
104+
105+
return this;
106+
}
107+
96108
public ICompanyBranding Build()
97109
{
98110
return model;

CoreHelpers.Branding.Runtime/Services/BrandingManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace CoreHelpers.Branding.Runtime.Services
77
{
8-
public class BrandingManager : IBrandingManager
8+
internal class BrandingManager : IBrandingManager
99
{
1010
private IEnumerable<IBrandingStore> _stores;
1111
private IMemoryCache _memoryCache;

CoreHelpers.Branding.Runtime/Services/BrandingStateService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
namespace CoreHelpers.Branding.Runtime.Services
33
{
4-
public class BrandingStateService : IBrandingStateService
4+
internal class BrandingStateService : IBrandingStateService
55
{
66
public ICompanyBranding CurrentCompanyBranding { get; private set; }
77

0 commit comments

Comments
 (0)