Skip to content

Commit

Permalink
first test working!
Browse files Browse the repository at this point in the history
  • Loading branch information
joost-van-dam committed Mar 23, 2024
1 parent 3d567e5 commit 6659036
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 4 deletions.
1 change: 1 addition & 0 deletions AvansDevOps.Tests/AvansDevOps.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
Expand Down
51 changes: 51 additions & 0 deletions AvansDevOps.Tests/ProjectTests/CreatesSprint.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using AvansDevOps.Domain;
using AvansDevOps.Domain.People;
using FluentAssertions;

namespace AvansDevOps.Tests.ProjectTests
{
public class CreatesSprint
{
// mocks staan hier
public CreatesSprint()
{
// mocks initialiseren
}

[Theory]
[InlineData(TypeOfSprints.PARTIALPRODUCTSPRINT)]
[InlineData(TypeOfSprints.RELEASESPRINT)]
internal void CreatesSprint_AddsASprintOfTheCorrectConcreteTypeToTheSpintsListInTheProject(TypeOfSprints typeOfSprint)
{
// Dirty code but can not be fixed :(
Type concreteTypeOfSprint = null;
if (typeOfSprint == TypeOfSprints.PARTIALPRODUCTSPRINT)
{
concreteTypeOfSprint = typeof(PartialProductSprint);
}
else if (typeOfSprint == TypeOfSprints.RELEASESPRINT)
{
concreteTypeOfSprint = typeof(ReleaseSprint);
}

// Arrange
ProductOwner productOwner = new ProductOwner("Jan", "Jansen", "[email protected]", new List<NotificationPlatformPreferences> { NotificationPlatformPreferences.EMAIL });
Project project = new Project(productOwner, new LinkedList<BacklogItem>());


String name = "Sprint 1";
DateTime startDate = DateTime.Now;
DateTime endDate = DateTime.Now.AddDays(14);
ScrumMaster scrumMaster = new ScrumMaster("Piet", "Pietersen", "[email protected]", new List<NotificationPlatformPreferences> { NotificationPlatformPreferences.EMAIL });
LinkedList<Developer> developers = new LinkedList<Developer>();
LinkedList<Tester> testers = new LinkedList<Tester>();
LinkedList<BacklogItem> backlogitems = new LinkedList<BacklogItem>();

// Act
project.CreateSprint(typeOfSprint, name, startDate, endDate, scrumMaster, developers, testers, backlogitems);

// Assert
project.GetMostRecentSprint().Should().BeOfType(concreteTypeOfSprint);
}
}
}
40 changes: 36 additions & 4 deletions AvansDevOps/Domain/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ namespace AvansDevOps.Domain
internal class Project
{
private ProductOwner productOwner;
private LinkedList<BacklogItem> projectBacklog = new LinkedList<BacklogItem>();
private LinkedList<Sprint> sprints = new LinkedList<Sprint>();
private readonly LinkedList<BacklogItem> projectBacklog = new LinkedList<BacklogItem>();
private readonly LinkedList<Sprint> sprints = new LinkedList<Sprint>();
private readonly SprintFactory sprintFactory = new SprintFactory();

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

public void CreateSprint(TypeOfSprints typeOfSprint, string name, DateTime startDate, DateTime endDate, ScrumMaster scrumMaster, LinkedList<Developer> developers, LinkedList<Tester> testers, LinkedList<BacklogItem> backlog)
public void CreateSprint(TypeOfSprints typeOfSprint, string name, DateTime startDate, DateTime endDate, ScrumMaster scrumMaster, LinkedList<Developer> developers, LinkedList<Tester> testers, LinkedList<BacklogItem> backlogtems)
{
this.sprints.AddLast(this.sprintFactory.CreateSprint(this, typeOfSprint, name, startDate, endDate, scrumMaster, developers, testers, backlog));
this.sprints.AddLast(this.sprintFactory.CreateSprint(this, typeOfSprint, name, startDate, endDate, scrumMaster, developers, testers, backlogtems));
}

public void AddBacklogItem(BacklogItem backlogItem)
{
this.projectBacklog.AddLast(backlogItem);
}

public BacklogItem GetBacklogItem(string name)
{
foreach (BacklogItem backlogItem in projectBacklog)
{
if (backlogItem.GetName() == name)
{
return backlogItem;
}
}
return null;
}

public LinkedList<BacklogItem> GetBacklogItems()
{
return this.projectBacklog;
}

public LinkedList<Developer> GetDevelopers()
Expand Down Expand Up @@ -62,6 +84,16 @@ public LinkedList<Tester> GetTesters()
return testers;
}

public Sprint GetMostRecentSprint()
{
if (sprints.Last != null)
{
return sprints.Last.Value;

}
return null;
}


}
}

0 comments on commit 6659036

Please sign in to comment.