private void SendHumanScreenComplete(bool hire) { ApplicationServiceClient proxy = new ApplicationServiceClient(); try { // Create the result HumanScreeningResult result = new HumanScreeningResult() { AppID = Convert.ToInt32(LabelAppID.Text), HiringApproved = hire, }; // Wrap it in a request HumanScreeningCompletedRequest request = new HumanScreeningCompletedRequest(result); // Call the workflow service proxy.HumanScreeningCompleted(result); proxy.Close(); } catch (Exception) { proxy.Abort(); throw; } }
public void ShouldNotHireEductionLevelNone() { const string ExpectedName = "test"; const int ExpectedId = 123; var expectedResponse = string.Format(ServiceResources.JobApplicationProcessing, ExpectedName, ExpectedId); var xamlInjector = new XamlInjector("SubmitApplication.xamlx"); xamlInjector.ReplaceAll(typeof(NotifyApplicant), typeof(MockNotifyApplicant)); xamlInjector.ReplaceAll(typeof(RequestHumanScreening), typeof(MockRequestHumanScreening)); xamlInjector.ReplaceAll(typeof(SaveJobApplication), typeof(MockSaveJobApplication)); xamlInjector.ReplaceAll(typeof(UpdateHireApproved), typeof(MockUpdateHireApproved)); // Host the service var address = ServiceTest.GetUniqueEndpointAddress(); using (var host = WorkflowServiceTestHost.Open(xamlInjector.GetWorkflowService(), address)) { // Setup a proxy to use named pipes var proxy = new ApplicationServiceClient(ServiceTest.Pipe, address); try { // Submit an application var response = proxy.SubmitJobApplication(CreateApplicationRequest("none")); proxy.Close(); // The last thing to happen is for the Workflow Instance to be deleted from // the persistence store. // Wait for this before asserting tracking records Assert.IsTrue(host.WaitForInstanceDeleted()); // Close the host host.Close(); // Assert // Check that we got a response message Assert.AreEqual(expectedResponse, response.ResponseText); host.Tracking.Trace(); // Assert that the Auto Screen Education activity returned EducationPassed = false // Find this tracking record and assert the arguments // Activity <Auto Screen Education> state is Closed // { // Arguments // EducationPassed: False // Education: None // } // After the autoscreen the EducationPassed argument should be false var autoScreenEducation = host.Tracking.Records.Find("Auto Screen Education", ActivityInstanceState.Closed); Assert.IsFalse(autoScreenEducation.GetArgument<bool>(EducationpassedArgName)); // Assert that the Update No Hire activity was invoked // Find this activity state record // Activity <Update No Hire> state is Closed // { // Arguments // ApplicantID: 123 // HireApproved: False // } var updateNoHire = host.Tracking.Records.Find("Update No Hire", ActivityInstanceState.Closed); Assert.IsFalse(updateNoHire.GetArgument<bool>(HireApprovedArgName)); // Assert that the no-hire email notification was sent // Find this activity state record // Activity <MockNotifyApplicant> state is Closed // { // Arguments // Hire: False // Resume: HRApplicationServices.Contracts.ApplicantResume // } var notifyApplicant = host.Tracking.Records.Find("MockNotifyApplicant", ActivityInstanceState.Closed); Assert.IsFalse(notifyApplicant.GetArgument<bool>("Hire")); } catch (Exception) { proxy.Abort(); throw; } finally { host.Tracking.Trace(); } } }
public void ShouldCancelAfter2Nags() { const string expectedName = "test"; const int expectedId = 123; var expectedResponse = string.Format(ServiceResources.JobApplicationProcessing, expectedName, expectedId); var xamlInjector = new XamlInjector("SubmitApplication.xamlx"); xamlInjector.ReplaceAll(typeof(NotifyApplicant), typeof(MockNotifyApplicant)); xamlInjector.ReplaceAll(typeof(RequestHumanScreening), typeof(MockRequestHumanScreening)); xamlInjector.ReplaceAll(typeof(SaveJobApplication), typeof(MockSaveJobApplication)); xamlInjector.ReplaceAll(typeof(Delay), typeof(FakeDelay)); xamlInjector.ReplaceAll(typeof(UpdateHireApproved), typeof(MockUpdateHireApproved)); SubmitJobApplicationResponse response = null; // Host the service); using (var testHost = WorkflowServiceTestHost.Open(xamlInjector.GetWorkflowService(), _serviceAddress)) { // Setup a proxy to use named pipes var proxy = new ApplicationServiceClient(_binding, _serviceAddress); try { // Submit an application response = proxy.SubmitJobApplication(new SubmitJobApplicationRequest { RequestID = Guid.NewGuid(), Resume = new ApplicantResume { Education = "Masters", Email = "*****@*****.**", Name = "test", NumReferences = 0 } }); // Check that we got a response message Assert.AreEqual(expectedResponse, response.ResponseText); // Take no further action - application should cancel proxy.Close(); } catch (Exception) { testHost.Tracking.Trace(); proxy.Abort(); throw; } // The last thing to happen is for the Workflow Instance to be deleted from // the persistence store. // Wait for this before asserting tracking records Assert.IsTrue(WorkflowServiceTestHost.WaitForInstanceDeleted()); // Close the host testHost.Close(); Assert.IsTrue(WorkflowServiceTestHost.WaitForHostClosed()); // Assert testHost.Tracking.Trace(); // Find the cancel notification //Activity <MockNotifyApplicant> state is Closed //{ // Arguments // Cancel: True // Hire: False // Resume: HRApplicationServices.Contracts.ApplicantResume //} var notifyApplicant = testHost.Tracking.Records.FindActivityState("MockNotifyApplicant", ActivityInstanceState.Closed); Assert.IsNotNull(notifyApplicant); Assert.IsFalse(notifyApplicant.GetArgument<bool>("Hire")); Assert.IsTrue(notifyApplicant.GetArgument<bool>("Cancel")); } }
public void ShouldHireEducationLevelMasters() { const string expectedName = "test"; const int expectedId = 123; var expectedResponse = string.Format(ServiceResources.JobApplicationProcessing, expectedName, expectedId); var xamlInjector = new XamlInjector("SubmitApplication.xamlx"); xamlInjector.ReplaceAll(typeof(NotifyApplicant), typeof(MockNotifyApplicant)); xamlInjector.ReplaceAll(typeof(RequestHumanScreening), typeof(MockRequestHumanScreening)); xamlInjector.ReplaceAll(typeof(SaveJobApplication), typeof(MockSaveJobApplication)); xamlInjector.ReplaceAll(typeof(UpdateHireApproved), typeof(MockUpdateHireApproved)); SubmitJobApplicationResponse response = null; // Host the service); using (var testHost = WorkflowServiceTestHost.Open(xamlInjector.GetWorkflowService(), _serviceAddress)) { // Setup a proxy to use named pipes var proxy = new ApplicationServiceClient(_binding, _serviceAddress); try { // Submit an application response = proxy.SubmitJobApplication(new SubmitJobApplicationRequest { RequestID = Guid.NewGuid(), Resume = new ApplicantResume { Education = "Masters", Email = "*****@*****.**", Name = "test", NumReferences = 0 } }); // Check that we got a response message Assert.AreEqual(expectedResponse, response.ResponseText); var result = proxy.HumanScreeningCompleted(new HumanScreeningResult { AppID = expectedId, HiringApproved = true }); Assert.IsTrue(result.HasValue && result.Value); proxy.Close(); } catch (Exception) { //testHost.Tracking.Trace(); proxy.Abort(); throw; } // The last thing to happen is for the Workflow Instance to be deleted from // the persistence store. // Wait for this before asserting tracking records Assert.IsTrue(WorkflowServiceTestHost.WaitForInstanceDeleted()); // Close the host testHost.Close(); Assert.IsTrue(WorkflowServiceTestHost.WaitForHostClosed()); // Assert testHost.Tracking.Trace(1000); // Assert that the Auto Screen Education activity returned EducationPassed = false // Find this tracking record and assert the arguments //Activity <Auto Screen Education> state is Closed //{ // Arguments // EducationPassed: True // Education: Masters //} // After the autoscreen the EducationPassed argument should be true var autoScreenEducation = testHost.Tracking.Records.FindActivityState("Auto Screen Education", ActivityInstanceState.Closed); Assert.IsTrue(autoScreenEducation.GetArgument<bool>("EducationPassed")); // Assert that the Request Human Screening activity was invoked //Activity <Request Human Screening> state is Closed //{ // Arguments // ApplicationRequest: HRApplicationServices.Contracts.SubmitJobApplicationRequest // ApplicationID: 123 //} var requestHumanScreening = testHost.Tracking.Records.FindActivityState("Request Human Screening", ActivityInstanceState.Closed); Assert.IsNotNull(requestHumanScreening, "Could not find Request Human Screening"); Assert.AreEqual(expectedId, requestHumanScreening.GetArgument<int>("ApplicationID")); // Assert that the Update Hire activity was invoked // Find this activity state record //Activity <Update Hire Approved> state is Executing //{ // Arguments // ApplicantID: 123 // HireApproved: True //} var updateHire = testHost.Tracking.Records.FindActivityState("Update Hire Approved", ActivityInstanceState.Closed); Assert.IsTrue(updateHire.GetArgument<bool>("HireApproved")); Assert.AreEqual(expectedId, updateHire.GetArgument<int>("ApplicantID")); // Assert that the hire email notification was sent // Find this activity state record //Activity <MockNotifyApplicant> state is Closed //{ // Arguments // Hire: True // Resume: HRApplicationServices.Contracts.ApplicantResume //} //var notifyApplicant = testHost.Tracking.Records.FindActivityState("MockNotifyApplicant", // ActivityInstanceState.Closed); //Assert.IsNotNull(notifyApplicant); //Assert.IsTrue(notifyApplicant.GetArgument<bool>("Hire")); //Assert.AreEqual("test", notifyApplicant.GetArgument<ApplicantResume>("Resume").Name); } }