-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor breadcrumb code out of team controllers #626
- Loading branch information
1 parent
0ebbabe
commit de1415a
Showing
169 changed files
with
382 additions
and
254 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
62 changes: 62 additions & 0 deletions
62
Stoolball.Web.UnitTests/Navigation/TeamBreadcrumbBuilderTests.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,62 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Stoolball.Clubs; | ||
using Stoolball.Teams; | ||
using Stoolball.Web.Navigation; | ||
using Xunit; | ||
|
||
namespace Stoolball.Web.UnitTests.Navigation | ||
{ | ||
public class TeamBreadcrumbBuilderTests | ||
{ | ||
#nullable disable | ||
[Fact] | ||
public void Null_breadcrumbs_throws_ArgumentNullException() | ||
{ | ||
var builder = new TeamBreadcrumbBuilder(); | ||
|
||
Assert.Throws<ArgumentNullException>(() => builder.BuildBreadcrumbs(null, new Team(), true)); | ||
} | ||
|
||
[Fact] | ||
public void Null_team_throws_ArgumentNullException() | ||
{ | ||
var builder = new TeamBreadcrumbBuilder(); | ||
|
||
Assert.Throws<ArgumentNullException>(() => builder.BuildBreadcrumbs(new List<Breadcrumb>(), null, true)); | ||
} | ||
#nullable enable | ||
|
||
[Fact] | ||
public void Club_adds_club_breadcrumb() | ||
{ | ||
var builder = new TeamBreadcrumbBuilder(); | ||
var breadcrumbs = new List<Breadcrumb>(); | ||
var team = new Team { Club = new Club { ClubName = "Example club", ClubRoute = "/clubs/example-club" } }; | ||
|
||
builder.BuildBreadcrumbs(breadcrumbs, team, false); | ||
|
||
Assert.Equal(2, breadcrumbs.Count); | ||
Assert.Equal(Constants.Pages.Teams, breadcrumbs[0].Name); | ||
Assert.Equal(Constants.Pages.TeamsUrl, breadcrumbs[0].Url?.ToString()); | ||
Assert.Equal(team.Club.ClubName, breadcrumbs[1].Name); | ||
Assert.Equal(team.Club.ClubRoute, breadcrumbs[1].Url?.ToString()); | ||
} | ||
|
||
[Fact] | ||
public void IncludeTeam_adds_team_breadcrumb() | ||
{ | ||
var builder = new TeamBreadcrumbBuilder(); | ||
var breadcrumbs = new List<Breadcrumb>(); | ||
var team = new Team { TeamName = "Example team", TeamRoute = "/teams/example-team" }; | ||
|
||
builder.BuildBreadcrumbs(breadcrumbs, team, true); | ||
|
||
Assert.Equal(2, breadcrumbs.Count); | ||
Assert.Equal(Constants.Pages.Teams, breadcrumbs[0].Name); | ||
Assert.Equal(Constants.Pages.TeamsUrl, breadcrumbs[0].Url?.ToString()); | ||
Assert.Equal(team.TeamName, breadcrumbs[1].Name); | ||
Assert.Equal(team.TeamRoute, breadcrumbs[1].Url?.ToString()); | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.