Skip to content

Commit

Permalink
Remove hardcoded 35 hours from GetLateDevelopers usecase
Browse files Browse the repository at this point in the history
  • Loading branch information
C-gyorfi committed May 13, 2019
1 parent 11e8d40 commit b7ee31f
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 15 deletions.
Expand Up @@ -55,6 +55,17 @@
"Marketing Manager"
],
"is_active":false
},
{
"id": 1902070,
"first_name": "Harvey",
"last_name": "Dent",
"email": "two-face@gotham.com",
"weekly_capacity": 100800,
"roles": [
"Lead Engineer"
],
"is_active":true
}
]
}
Expand Up @@ -82,7 +82,7 @@ public void CanOnlyGetActiveDevelopers()
public void CanGetWeeklyHoursForDevelopers(string name, int hours)
{
var response = _harvestGateway.RetrieveDevelopers();
response.First(developer => developer.FirstName == name).Hours.Should().Be(hours);
response.First(developer => developer.FirstName == name).WeeklyHours.Should().Be(hours);
}
}

Expand Down
29 changes: 18 additions & 11 deletions CryptoTechReminderSystem.Test/UseCase/GetLateDevelopersTests.cs
Expand Up @@ -151,14 +151,16 @@ public void SetUp()
Id = 1337,
FirstName = "Fred",
LastName = "Flintstone",
Email = "fred@fred.com"
Email = "fred@fred.com",
WeeklyHours = 35
},
new HarvestDeveloper
{
Id = 123,
FirstName = "Joe",
LastName = "Bloggs",
Email = "Joe@Bloggs.com"
Email = "Joe@Bloggs.com",
WeeklyHours = 28
}
}
};
Expand All @@ -182,12 +184,12 @@ public void SetUp()
}

[Test]
[TestCase(1337, "U9999")]
[TestCase(123, "U8723")]
public void CanGetLateADeveloper(int harvestUserId, string slackUserId)
[TestCase(1337, "U9999", 5)]
[TestCase(123, "U8723", 4)]
public void CanGetLateADeveloper(int harvestUserId, string slackUserId, int capacityInDays)
{
_harvestGatewayStub.TimeSheets = Enumerable.Repeat(
new TimeSheet { Hours = 7, UserId = harvestUserId }, 5
new TimeSheet { Hours = 7, UserId = harvestUserId }, capacityInDays
).ToArray();

var clock = new ClockStub(
Expand Down Expand Up @@ -227,21 +229,24 @@ public void Setup()
Id = 1337,
FirstName = "Fred",
LastName = "Flintstone",
Email = "fred@fred.com"
Email = "fred@fred.com",
WeeklyHours = 35
},
new HarvestDeveloper
{
Id = 123,
FirstName = "Joe",
LastName = "Bloggs",
Email = "Joe@Bloggs.com"
Email = "Joe@Bloggs.com",
WeeklyHours = 35
},
new HarvestDeveloper
{
Id = 101,
FirstName = "Jimbob",
LastName = "BaconBath",
Email = "JBB@aol.com"
Email = "JBB@aol.com",
WeeklyHours = 35
}
}
};
Expand Down Expand Up @@ -289,7 +294,8 @@ public void CanHandleWhenNoMatchesAreFound()
Id = 101,
FirstName = "Jimbob",
LastName = "BaconBath",
Email = "JBB@aol.com"
Email = "JBB@aol.com",
WeeklyHours = 35
}
}
};
Expand Down Expand Up @@ -333,7 +339,8 @@ public void CanHandleWhenEmailsAreNotExact()
Id = 101,
FirstName = "Fred",
LastName = "Flintstone",
Email = "freddy@aol.com"
Email = "freddy@aol.com",
WeeklyHours = 35
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion CryptoTechReminderSystem/DomainObject/Developer.cs
Expand Up @@ -11,6 +11,6 @@ public class Developer
[JsonProperty("email")]
public string Email { get; set; }
[JsonProperty("weekly_capacity")]
public int Hours { get; set; }
public int WeeklyHours { get; set; }
}
}
2 changes: 1 addition & 1 deletion CryptoTechReminderSystem/Gateway/HarvestGateway.cs
Expand Up @@ -41,7 +41,7 @@ public IList<HarvestDeveloper> RetrieveDevelopers()
FirstName = developer["first_name"].ToString(),
LastName = developer["last_name"].ToString(),
Email = developer["email"].ToString(),
Hours = (int)developer["weekly_capacity"] / 3600
WeeklyHours = (int)developer["weekly_capacity"] / 3600
}
).ToList();
}
Expand Down
2 changes: 1 addition & 1 deletion CryptoTechReminderSystem/UseCase/GetLateDevelopers.cs
Expand Up @@ -41,7 +41,7 @@ public GetLateDevelopersResponse Execute()
var timeSheetForDeveloper = harvestGetTimeSheetsResponse.Where(sheet => sheet.UserId == harvestDeveloper.Id);
var sumOfHours = timeSheetForDeveloper.Sum(timeSheet => timeSheet.Hours);

if (sumOfHours < 35)
if (sumOfHours < harvestDeveloper.WeeklyHours)
{
var slackLateDeveloper = slackGetDevelopersResponse.SingleOrDefault(developer => RemoveTopLevelDomain(developer.Email) == RemoveTopLevelDomain(harvestDeveloper.Email));

Expand Down

0 comments on commit b7ee31f

Please sign in to comment.