Skip to content

Commit

Permalink
added fix for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
md committed Nov 21, 2024
1 parent e4de3c1 commit bb758ad
Showing 1 changed file with 42 additions and 10 deletions.
52 changes: 42 additions & 10 deletions backend/Tests/AbsenceTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Api.StaffingController;
using Core.Absences;
using Core.Agreements;
using Core.Consultants;
using Core.Customers;
using Core.DomainModels;
Expand Down Expand Up @@ -56,16 +57,39 @@ public void AvailabilityCalculation(
Consultants = Substitute.For<List<Consultant>>()
};

var customer = new Customer
{
Id = 1,
Name = "TestCustomer",
Organization = org,
Projects = new List<Engagement>()
};

var engagement = new Engagement
{
Id = 1,
Customer = customer,
State = EngagementState.Order,
IsBillable = true,
Staffings = new List<Staffing>(),
Name = "TestProject",

};

customer.Projects.Add(engagement);

Consultant consultant = new()
{
Id = 1,
Name = "Test Variant",
Email = "[email protected]",
GraduationYear = 2010,
Department = department
Department = department,
Projects = new List<Engagement>()
};

consultant.Projects.Add(engagement);

var mondayDateOnly = numberOfHolidays switch
{
0 => new DateOnly(2023, 9, 4), // Week 36, 4th Sept 2023, (no public holidays)
Expand All @@ -76,12 +100,17 @@ public void AvailabilityCalculation(
};

var week = Week.FromDateOnly(mondayDateOnly);
var project = Substitute.For<Engagement>();
var customer = Substitute.For<Customer>();
customer.Name = "TestCustomer";
project.Customer = customer;
project.State = EngagementState.Order;
project.IsBillable = true;



Agreement agreement = new()
{
Id = 1,
EndDate = new DateTime(2023, 12, 31),
StartDate = new DateTime(2023, 1, 1),
EngagementId = 1,
Engagement = engagement,
};


// TODO: Change this to update consultant data
Expand All @@ -108,11 +137,11 @@ public void AvailabilityCalculation(
if (staffedHours > 0)
consultant.Staffings.Add(new Staffing
{
Engagement = project,
Engagement = engagement,
Consultant = consultant,
Hours = staffedHours,
Week = week,
EngagementId = project.Id,
EngagementId = engagement.Id,
ConsultantId = consultant.Id
});

Expand Down Expand Up @@ -162,9 +191,12 @@ public void MultiplePlannedAbsences()
Name = "Test Variant",
Email = "[email protected]",
GraduationYear = 2010,
Department = department
Department = department,
Projects = new List<Engagement>()
};

consultant.Projects.Add(Substitute.For<Engagement>());

var week = new Week(2000, 1);

consultant.PlannedAbsences.Add(new PlannedAbsence
Expand Down

0 comments on commit bb758ad

Please sign in to comment.