public void ClosedDoorShouldReturnToClosedLocked() { using (var host = WorkflowServiceTestHost.Open("SecurityDoorService.xamlx", this.serviceAddress)) { try { // Arrange var proxy = new SecurityDoorServiceClient(this.binding, this.serviceAddress); // Authorize and unlock the door var response = proxy.AuthorizeKey(100, Guid.NewGuid(), TestTimeout, TestIntrusionThreshold); // Notify that the door is opened and unlocked proxy.NotifyDoorStatus(100, true, false); // Notify that the door is closed and locked proxy.NotifyDoorStatus(100, false, true); proxy.Close(); host.Close(); // Wait for the host to close before checking the tracking data Assert.IsTrue(WorkflowServiceTestHost.WaitForHostClosed(1000)); // Verify the authorize was successful Assert.IsTrue(response.Authorized); // Verify the timeout occured by the states that occur in the tracking AssertState.OccursInOrder( Constants.SecurityDoorStateMachine, host.Tracking.Records, States.ClosedLocked, States.ClosedUnlocked, States.Open, States.ClosedLocked); // Verify that the Closed transition was triggered host.Tracking.Assert.Exists(Transitions.ReceiveDoorClosed, ActivityInstanceState.Closed); } finally { host.Tracking.Trace(); } } }
public void ValidKeyShouldAuthorize() { using (var host = WorkflowServiceTestHost.Open("SecurityDoorService.xamlx", this.serviceAddress)) { try { var proxy = new SecurityDoorServiceClient(this.binding, this.serviceAddress); var response = proxy.AuthorizeKey(100, Guid.NewGuid(), TestTimeout, TestIntrusionThreshold); proxy.Close(); host.Close(); // Wait for the host to close before checking the tracking data Assert.IsTrue(WorkflowServiceTestHost.WaitForHostClosed(1000)); // Verify that the door was unlocked AssertState.OccursInOrder( Constants.SecurityDoorStateMachine, host.Tracking.Records, States.ClosedLocked, States.ClosedUnlocked); // Verify the key was authorized Assert.IsTrue(response.Authorized); } finally { host.Tracking.Trace(); } } }
public void VerifyTimeoutIfNotOpened() { using (var host = WorkflowServiceTestHost.Open("SecurityDoorService.xamlx", this.serviceAddress)) { try { // Arrange var proxy = new SecurityDoorServiceClient(this.binding, this.serviceAddress); // Authorize and unlock the door var response = proxy.AuthorizeKey(100, Guid.NewGuid(), TestTimeout, TestIntrusionThreshold); proxy.Close(); // Wait for timeout Thread.Sleep(this.TestTimeout.Add(TimeSpan.FromSeconds(1))); // By this time the timeout should have occurred. host.Close(); // Wait for the host to close before checking the tracking data Assert.IsTrue(WorkflowServiceTestHost.WaitForHostClosed(1000)); // Verify the authorize was successful Assert.IsTrue(response.Authorized); // Verify the timeout occured by the states that occur in the tracking AssertState.OccursInOrder( Constants.SecurityDoorStateMachine, host.Tracking.Records, States.ClosedLocked, States.ClosedUnlocked, States.ClosedLocked); // Verify that the UnlockedTimeout transition was triggered host.Tracking.Assert.Exists(Transitions.UnlockedTimeout, ActivityInstanceState.Closed); } finally { host.Tracking.Trace(); } } }
public void RepeatedInvalidKeyShouldAlertIntrusion() { using (var host = WorkflowServiceTestHost.Open("SecurityDoorService.xamlx", this.serviceAddress)) { try { var proxy = new SecurityDoorServiceClient(this.binding, this.serviceAddress); for (var i = 0; i < TestIntrusionThreshold; i++) { proxy.AuthorizeKey(100, Guid.Empty,TimeSpan.FromMilliseconds(1), TestIntrusionThreshold); } proxy.Close(); host.Close(); // Wait for the host to close before checking the tracking data Assert.IsTrue(WorkflowServiceTestHost.WaitForHostClosed(1000)); // Verify that the door was unlocked AssertState.OccursInOrder( Constants.SecurityDoorStateMachine, host.Tracking.Records, States.ClosedLocked, States.IntrusionDetect, States.ClosedLocked, States.IntrusionDetect, States.Alert); } finally { host.Tracking.Trace(); } } }