-
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.
Added Shouldly and updated all tests
- Loading branch information
Showing
2 changed files
with
72 additions
and
50 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
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
using CandidateManager.Core.Interfaces; | ||
using CandidateManager.Core.Processors; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Shouldly; | ||
|
||
namespace CandidateManager.Tests | ||
{ | ||
|
@@ -15,133 +16,153 @@ public class CandidateTests | |
[TestMethod] | ||
public void ShouldThrowWithEmptyName() | ||
{ | ||
Assert.ThrowsException<ArgumentException>(() => new Candidate("", "[email protected]", "999-0000","ThreeWill")); | ||
Assert.ThrowsException<ArgumentNullException>(() => new Candidate(null, "[email protected]","999-0000","ThreeWill")); | ||
Should.Throw<ArgumentException>(() => new Candidate("", "[email protected]","999-0000","ThreeWill")); | ||
Should.Throw<ArgumentNullException>(() => new Candidate(null, "[email protected]","999-0000","ThreeWill")); | ||
} | ||
|
||
[TestMethod] | ||
public void ShouldThrowWithEmptyOrNullPhone() | ||
{ | ||
Assert.ThrowsException<ArgumentException>(() => new Candidate("Pete Skelly", "", "999-0000", "ThreeWill")); | ||
Assert.ThrowsException<ArgumentNullException>(() => new Candidate("Pete Skelly", null, "999-0000", "ThreeWill")); | ||
Should.Throw<ArgumentException>(() => new Candidate("Pete Skelly", "", "999-0000", "ThreeWill")); | ||
Should.Throw<ArgumentNullException>(() => new Candidate("Pete Skelly", null, "999-0000", "ThreeWill")); | ||
} | ||
|
||
[TestMethod] | ||
public void ShouldThrowWithNullOrEmptyEmail() | ||
{ | ||
Assert.ThrowsException<ArgumentException>(() => new Candidate("Pete Skelly", "", "555-9999", "ThreeWill")); | ||
Assert.ThrowsException<ArgumentNullException>(() => new Candidate("Pete Skelly", null, "555-9999", "ThreeWill")); | ||
|
||
Should.Throw<ArgumentException>(() => new Candidate("Pete Skelly", "", "555-9999", "ThreeWill")); | ||
Should.Throw<ArgumentNullException>(() => new Candidate("Pete Skelly", null, "555-9999", "ThreeWill")); | ||
|
||
} | ||
|
||
[TestMethod] | ||
public void ShouldThrowWithNullOrEmptyCompany() | ||
{ | ||
Assert.ThrowsException<ArgumentException>(() => new Candidate("Pete Skelly", "", "555-9999", "")); | ||
Assert.ThrowsException<ArgumentNullException>(() => new Candidate("Pete Skelly", null, "555-9999", null)); | ||
Should.Throw<ArgumentException>(() => new Candidate("Pete Skelly", "", "555-9999", "")); | ||
Should.Throw<ArgumentNullException>(() => new Candidate("Pete Skelly", null, "555-9999", null)); | ||
} | ||
|
||
[TestMethod] | ||
public void DeserilaizesThreeWillIngest() | ||
{ | ||
//Arrange | ||
string curDir = Directory.GetCurrentDirectory(); | ||
string filePath = Path.Combine(curDir, "../../../ThreeWillFlowInput.json"); | ||
string flowMessage = File.ReadAllText(filePath); | ||
JsonSerializerOptions options = new() { | ||
WriteIndented = true, | ||
PropertyNameCaseInsensitive = true | ||
}; | ||
FlowIngest flowInput = JsonSerializer.Deserialize<FlowIngest>(flowMessage,options); | ||
Assert.AreEqual(flowInput.Recruiter, "[email protected]"); | ||
Assert.AreEqual(flowInput.Company, "ThreeWill"); | ||
Assert.AreEqual(flowInput.FileName, "8e294c8c-b3a2-43f8-8d91-51acf75fc5e4.docx"); | ||
|
||
//Act | ||
FlowIngest flowInput = flowMessage.FromJson<FlowIngest>(); | ||
|
||
//Assert | ||
flowInput.Recruiter.ShouldBe("[email protected]"); | ||
flowInput.Company.ShouldBe("ThreeWill"); | ||
flowInput.FileName.ShouldBe("8e294c8c-b3a2-43f8-8d91-51acf75fc5e4.docx"); | ||
|
||
} | ||
|
||
[TestMethod] | ||
public void DeserilaizesThompsonIngest() | ||
{ | ||
//Arrange | ||
string curDir = Directory.GetCurrentDirectory(); | ||
string filePath = Path.Combine(curDir, "../../../ThompsonFlowInput.json"); | ||
string flowMessage = File.ReadAllText(filePath); | ||
|
||
//Act | ||
FlowIngest flowInput = flowMessage.FromJson<FlowIngest>(); | ||
Assert.AreEqual(flowInput.Recruiter, "[email protected]"); | ||
Assert.AreEqual(flowInput.Company, "Thompson"); | ||
Assert.AreEqual(flowInput.FileName, "5085578f-e0c1-4dd6-9d5e-80b7d2615d66.doc"); | ||
|
||
//Assert | ||
flowInput.Recruiter.ShouldBe("[email protected]"); | ||
flowInput.Company.ShouldBe("Thompson"); | ||
flowInput.FileName.ShouldBe("5085578f-e0c1-4dd6-9d5e-80b7d2615d66.doc"); | ||
} | ||
|
||
[TestMethod] | ||
public void DeserilaizesHireNetworksIngest() | ||
{ | ||
//Arrange | ||
string curDir = Directory.GetCurrentDirectory(); | ||
string filePath = Path.Combine(curDir, "../../../HireNetworksFloInput.json"); | ||
string flowMessage = File.ReadAllText(filePath); | ||
|
||
//Act | ||
FlowIngest flowInput = flowMessage.FromJson<FlowIngest>(); | ||
Assert.AreEqual(flowInput.Recruiter, "[email protected]"); | ||
Assert.AreEqual(flowInput.Company, "HireNetworks"); | ||
Assert.AreEqual(flowInput.FileName, "87048d1a-985a-4705-8eed-6f1562a98ea3.docx"); | ||
|
||
//Assert | ||
flowInput.Recruiter.ShouldBe("[email protected]"); | ||
flowInput.Company.ShouldBe("HireNetworks"); | ||
flowInput.FileName.ShouldBe("87048d1a-985a-4705-8eed-6f1562a98ea3.docx"); | ||
} | ||
|
||
|
||
[TestMethod] | ||
public void DoesDeserilaizeThreeWillCandidate() | ||
{ | ||
//Arrange | ||
string curDir = Directory.GetCurrentDirectory(); | ||
string filePath = Path.Combine(curDir, "../../../ThreeWillFlowInput.json"); | ||
string flowMessage = File.ReadAllText(filePath); | ||
FlowIngest flowInput = flowMessage.FromJson<FlowIngest>(); | ||
Assert.AreEqual("[email protected]", flowInput.Recruiter); | ||
Assert.AreEqual("ThreeWill", flowInput.Company); | ||
Assert.AreEqual("8e294c8c-b3a2-43f8-8d91-51acf75fc5e4.docx", flowInput.FileName); | ||
|
||
|
||
//Act | ||
FlowIngest flowInput = flowMessage.FromJson<FlowIngest>(); | ||
ICandidateProcessor processor = CandidateProcessorFactory.CreateCandidateProcessor(flowInput.Company); | ||
|
||
Assert.IsInstanceOfType(processor, typeof(ThreeWillCandidateProcessor)); | ||
Candidate candidate = processor.Process(flowInput.BodyHtml); | ||
Assert.AreEqual("ThreeWill", candidate.Company); | ||
Assert.AreEqual("Timm Peddie", candidate.Name); | ||
Assert.AreEqual("(415) 484-3004", candidate.Phone); | ||
Assert.AreEqual("[email protected]", candidate.EmailAddress); | ||
|
||
//Assert | ||
processor.ShouldBeAssignableTo<ThreeWillCandidateProcessor>(); | ||
candidate.Company.ShouldBe("ThreeWill"); | ||
candidate.Name.ShouldBe("Timm Peddie"); | ||
candidate.Phone.ShouldBe("(415) 484-3004"); | ||
candidate.EmailAddress.ShouldBe("[email protected]"); | ||
|
||
} | ||
|
||
[TestMethod] | ||
public void DoesDeserilaizeThompsonCandidate() | ||
{ | ||
|
||
//Arrange | ||
string curDir = Directory.GetCurrentDirectory(); | ||
string filePath = Path.Combine(curDir, "../../../ThompsonFlowInput.json"); | ||
string flowMessage = File.ReadAllText(filePath); | ||
FlowIngest flowInput = flowMessage.FromJson<FlowIngest>(); | ||
Assert.AreEqual("[email protected]", flowInput.Recruiter); | ||
Assert.AreEqual("Thompson", flowInput.Company); | ||
Assert.AreEqual("5085578f-e0c1-4dd6-9d5e-80b7d2615d66.doc", flowInput.FileName); | ||
|
||
//Act | ||
FlowIngest flowInput = flowMessage.FromJson<FlowIngest>(); | ||
ICandidateProcessor processor = CandidateProcessorFactory.CreateCandidateProcessor(flowInput.Company); | ||
|
||
Assert.IsInstanceOfType(processor, typeof(ThompsonCandidateProcessor)); | ||
Candidate candidate = processor.Process(flowInput.BodyHtml); | ||
Assert.AreEqual("Thompson", candidate.Company); | ||
Assert.AreEqual("Sean Jones", candidate.Name); | ||
Assert.AreEqual("(508) 410-5429", candidate.Phone); | ||
Assert.AreEqual("[email protected]", candidate.EmailAddress); | ||
|
||
//Assert | ||
processor.ShouldBeAssignableTo<ThompsonCandidateProcessor>(); | ||
candidate.Company.ShouldBe("Thompson"); | ||
candidate.Name.ShouldBe("Sean Jones"); | ||
candidate.Phone.ShouldBe("(508) 410-5429"); | ||
candidate.EmailAddress.ShouldBe("[email protected]"); | ||
|
||
} | ||
|
||
[TestMethod] | ||
public void DoesDeserilaizeStratfieldCandidate() | ||
{ | ||
|
||
//Arrange | ||
string curDir = Directory.GetCurrentDirectory(); | ||
string filePath = Path.Combine(curDir, "../../../StratfieldFlowInput.json"); | ||
string flowMessage = File.ReadAllText(filePath); | ||
|
||
//Act | ||
FlowIngest flowInput = flowMessage.FromJson<FlowIngest>(); | ||
Assert.AreEqual("[email protected]", flowInput.Recruiter); | ||
Assert.AreEqual("Stratfield", flowInput.Company); | ||
Assert.AreEqual("8b4a016a-a33d-416d-811c-204c4795b86a.docx", flowInput.FileName); | ||
|
||
ICandidateProcessor processor = CandidateProcessorFactory.CreateCandidateProcessor(flowInput.Company); | ||
Assert.IsInstanceOfType(processor, typeof(StratfieldCandidateProcessor)); | ||
Candidate candidate = processor.Process(flowInput.BodyHtml); | ||
Assert.AreEqual("Stratfield", candidate.Company); | ||
Assert.AreEqual("Jean-Patrick Guichard", candidate.Name); | ||
Assert.AreEqual(Constants.FIELD_DEFAULT, candidate.Phone); | ||
Assert.AreEqual(Constants.FIELD_DEFAULT, candidate.EmailAddress); | ||
|
||
//Assert | ||
processor.ShouldBeAssignableTo<StratfieldCandidateProcessor>(); | ||
candidate.Company.ShouldBe("Stratfield"); | ||
candidate.Name.ShouldBe("Jean-Patrick Guichard"); | ||
candidate.Phone.ShouldBe(Constants.FIELD_DEFAULT); | ||
candidate.EmailAddress.ShouldBe(Constants.FIELD_DEFAULT); | ||
} | ||
} | ||
} |