Skip to content

Commit

Permalink
Added Shouldly and updated all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pkskelly committed Jun 22, 2021
1 parent 8cbf6e7 commit c8dffe2
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 50 deletions.
1 change: 1 addition & 0 deletions src/CandidateManager.Tests/CandidateManager.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<PackageReference Include="MSTest.TestAdapter" Version="2.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.1" />
<PackageReference Include="coverlet.collector" Version="1.3.0" />
<PackageReference Include="Shouldly" Version="4.0.3" />
<PackageReference Include="System.Text.Json" Version="5.0.2" />
</ItemGroup>

Expand Down
121 changes: 71 additions & 50 deletions src/CandidateManager.Tests/CandidateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using CandidateManager.Core.Interfaces;
using CandidateManager.Core.Processors;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Shouldly;

namespace CandidateManager.Tests
{
Expand All @@ -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);
}
}
}

0 comments on commit c8dffe2

Please sign in to comment.