Skip to content

Commit 6659036

Browse files
committed
first test working!
1 parent 3d567e5 commit 6659036

File tree

3 files changed

+88
-4
lines changed

3 files changed

+88
-4
lines changed

AvansDevOps.Tests/AvansDevOps.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
<ItemGroup>
1313
<PackageReference Include="coverlet.collector" Version="6.0.0" />
14+
<PackageReference Include="FluentAssertions" Version="6.12.0" />
1415
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
1516
<PackageReference Include="xunit" Version="2.5.3" />
1617
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using AvansDevOps.Domain;
2+
using AvansDevOps.Domain.People;
3+
using FluentAssertions;
4+
5+
namespace AvansDevOps.Tests.ProjectTests
6+
{
7+
public class CreatesSprint
8+
{
9+
// mocks staan hier
10+
public CreatesSprint()
11+
{
12+
// mocks initialiseren
13+
}
14+
15+
[Theory]
16+
[InlineData(TypeOfSprints.PARTIALPRODUCTSPRINT)]
17+
[InlineData(TypeOfSprints.RELEASESPRINT)]
18+
internal void CreatesSprint_AddsASprintOfTheCorrectConcreteTypeToTheSpintsListInTheProject(TypeOfSprints typeOfSprint)
19+
{
20+
// Dirty code but can not be fixed :(
21+
Type concreteTypeOfSprint = null;
22+
if (typeOfSprint == TypeOfSprints.PARTIALPRODUCTSPRINT)
23+
{
24+
concreteTypeOfSprint = typeof(PartialProductSprint);
25+
}
26+
else if (typeOfSprint == TypeOfSprints.RELEASESPRINT)
27+
{
28+
concreteTypeOfSprint = typeof(ReleaseSprint);
29+
}
30+
31+
// Arrange
32+
ProductOwner productOwner = new ProductOwner("Jan", "Jansen", "[email protected]", new List<NotificationPlatformPreferences> { NotificationPlatformPreferences.EMAIL });
33+
Project project = new Project(productOwner, new LinkedList<BacklogItem>());
34+
35+
36+
String name = "Sprint 1";
37+
DateTime startDate = DateTime.Now;
38+
DateTime endDate = DateTime.Now.AddDays(14);
39+
ScrumMaster scrumMaster = new ScrumMaster("Piet", "Pietersen", "[email protected]", new List<NotificationPlatformPreferences> { NotificationPlatformPreferences.EMAIL });
40+
LinkedList<Developer> developers = new LinkedList<Developer>();
41+
LinkedList<Tester> testers = new LinkedList<Tester>();
42+
LinkedList<BacklogItem> backlogitems = new LinkedList<BacklogItem>();
43+
44+
// Act
45+
project.CreateSprint(typeOfSprint, name, startDate, endDate, scrumMaster, developers, testers, backlogitems);
46+
47+
// Assert
48+
project.GetMostRecentSprint().Should().BeOfType(concreteTypeOfSprint);
49+
}
50+
}
51+
}

AvansDevOps/Domain/Project.cs

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ namespace AvansDevOps.Domain
55
internal class Project
66
{
77
private ProductOwner productOwner;
8-
private LinkedList<BacklogItem> projectBacklog = new LinkedList<BacklogItem>();
9-
private LinkedList<Sprint> sprints = new LinkedList<Sprint>();
8+
private readonly LinkedList<BacklogItem> projectBacklog = new LinkedList<BacklogItem>();
9+
private readonly LinkedList<Sprint> sprints = new LinkedList<Sprint>();
1010
private readonly SprintFactory sprintFactory = new SprintFactory();
1111

1212
public Project(ProductOwner productOwner, LinkedList<BacklogItem> projectBacklog)
@@ -30,9 +30,31 @@ internal ScrumMaster GetScrumMaster()
3030
return this.sprints.Last!.Value.GetScrumMaster();
3131
}
3232

33-
public void CreateSprint(TypeOfSprints typeOfSprint, string name, DateTime startDate, DateTime endDate, ScrumMaster scrumMaster, LinkedList<Developer> developers, LinkedList<Tester> testers, LinkedList<BacklogItem> backlog)
33+
public void CreateSprint(TypeOfSprints typeOfSprint, string name, DateTime startDate, DateTime endDate, ScrumMaster scrumMaster, LinkedList<Developer> developers, LinkedList<Tester> testers, LinkedList<BacklogItem> backlogtems)
3434
{
35-
this.sprints.AddLast(this.sprintFactory.CreateSprint(this, typeOfSprint, name, startDate, endDate, scrumMaster, developers, testers, backlog));
35+
this.sprints.AddLast(this.sprintFactory.CreateSprint(this, typeOfSprint, name, startDate, endDate, scrumMaster, developers, testers, backlogtems));
36+
}
37+
38+
public void AddBacklogItem(BacklogItem backlogItem)
39+
{
40+
this.projectBacklog.AddLast(backlogItem);
41+
}
42+
43+
public BacklogItem GetBacklogItem(string name)
44+
{
45+
foreach (BacklogItem backlogItem in projectBacklog)
46+
{
47+
if (backlogItem.GetName() == name)
48+
{
49+
return backlogItem;
50+
}
51+
}
52+
return null;
53+
}
54+
55+
public LinkedList<BacklogItem> GetBacklogItems()
56+
{
57+
return this.projectBacklog;
3658
}
3759

3860
public LinkedList<Developer> GetDevelopers()
@@ -62,6 +84,16 @@ public LinkedList<Tester> GetTesters()
6284
return testers;
6385
}
6486

87+
public Sprint GetMostRecentSprint()
88+
{
89+
if (sprints.Last != null)
90+
{
91+
return sprints.Last.Value;
92+
93+
}
94+
return null;
95+
}
96+
6597

6698
}
6799
}

0 commit comments

Comments
 (0)