Skip to content

Commit 4d73d1b

Browse files
committed
Added Builder for Skills and added SkillTagTests
1 parent 36ba668 commit 4d73d1b

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using LinkDotNet.Domain;
2+
3+
namespace LinkDotNet.Blog.TestUtilities
4+
{
5+
public class SkillBuilder
6+
{
7+
private string skill = "C#";
8+
private string iconUrl;
9+
private string capability = "Backend";
10+
private ProficiencyLevel proficiencyLevel = ProficiencyLevel.Familiar;
11+
12+
public SkillBuilder WithSkillName(string skill)
13+
{
14+
this.skill = skill;
15+
return this;
16+
}
17+
18+
public SkillBuilder WithIconUrl(string iconUrl)
19+
{
20+
this.iconUrl = iconUrl;
21+
return this;
22+
}
23+
24+
public SkillBuilder WithCapability(string capability)
25+
{
26+
this.capability = capability;
27+
return this;
28+
}
29+
30+
public SkillBuilder WithProficiencyLevel(ProficiencyLevel proficiencyLevel)
31+
{
32+
this.proficiencyLevel = proficiencyLevel;
33+
return this;
34+
}
35+
36+
public Skill Build()
37+
{
38+
return Skill.Create(skill, iconUrl, capability, proficiencyLevel.Key);
39+
}
40+
}
41+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.Linq;
2+
using Bunit;
3+
using FluentAssertions;
4+
using LinkDotNet.Blog.TestUtilities;
5+
using LinkDotNet.Blog.Web.Shared.Skills;
6+
using Xunit;
7+
8+
namespace LinkDotNet.Blog.UnitTests.Web.Shared.Skills
9+
{
10+
public class SkillTagTests : TestContext
11+
{
12+
[Fact]
13+
public void ShouldRenderImageAndText()
14+
{
15+
var skill = new SkillBuilder().WithSkillName("C#").WithIconUrl("test").Build();
16+
17+
var cut = RenderComponent<SkillTag>(p => p.Add(
18+
s => s.Skill, skill));
19+
20+
cut.Find("span").TextContent.Should().Contain("C#");
21+
cut.Find("img").Attributes.Single(a => a.Name == "src").Value.Should().Be("test");
22+
}
23+
24+
[Fact]
25+
public void ShouldNotRenderImageWhenNotAvailable()
26+
{
27+
var skill = new SkillBuilder().WithIconUrl(null).Build();
28+
29+
var cut = RenderComponent<SkillTag>(p => p.Add(
30+
s => s.Skill, skill));
31+
32+
cut.FindAll("img").Should().HaveCount(0);
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)