public void SendCommand_Receives_Generic_Error_Message() { const string errorMessage = "DOESNOTMATTER"; const string expectedMessage = "Error: Received an exception trying to perform the operation - please contact support"; const string serialNumber = "KNOWNSERIALNUMBER"; const string command = "Initialize"; string expectedJSON = "{ Code = 500, Message = " + expectedMessage + " }"; var performEquipmentOperationWasCalled = false; using (ShimsContext.Create()) { var myContext = new SIMPLTestContext(); var fakeUserDto = myContext.GetFakeUserDtoObject(); ShimCurrentUser.AsUserDto = () => fakeUserDto; ShimRosettianClient.AllInstances.PerformEquipmentOperationListOfEquipmentOperationDtoUserDto = delegate { performEquipmentOperationWasCalled = true; throw new Exception(errorMessage); }; var testCleanAndScreenController = new CleanAndScreenController(new RosettianClient(), null); var result = testCleanAndScreenController.SendCommand(serialNumber, command); Assert.IsNotNull(result, "Send Command result is null"); Assert.IsTrue(performEquipmentOperationWasCalled, "PerformEquipmentOperation was not called"); Assert.IsTrue(result is JsonResult, "Result is not a JSON Result"); var testJsonResult = result as JsonResult; Assert.AreEqual(expectedJSON, testJsonResult.Data.ToString(), string.Format("Resulting JSON is incorrect: Actual-{0} Expected-{1}", testJsonResult.Data.ToString(), expectedJSON)); } }
public void SendCommand_Receives_ProvisioningError_From_Triad() { const string errorMessage = "\n Provisioning error: details follow\n , ErrorMessage: Terminal state operation, defined by the operation code of the state component, failed., Controller Code:2005, Name:DAC 11, Type:GI DAC 6000"; const string expectedMessage = "Provisioning error: details follow<br/>ErrorMessage: Terminal state operation, defined by the operation code of the state component, failed.<br />Controller Code:2005, Name:DAC 11, Type:GI DAC 6000"; const string serialNumber = "KNOWNSERIALNUMBER"; const string command = "Initialize"; string expectedJSON = "{ Code = 500, Message = "+ expectedMessage + " }"; var performEquipmentOperationWasCalled = false; using (ShimsContext.Create()) { var myContext = new SIMPLTestContext(); var fakeUserDto = myContext.GetFakeUserDtoObject(); ShimCurrentUser.AsUserDto = () => fakeUserDto; ShimRosettianClient.AllInstances.PerformEquipmentOperationListOfEquipmentOperationDtoUserDto = delegate { performEquipmentOperationWasCalled = true; throw new Exception(errorMessage); }; var testCleanAndScreenController = new CleanAndScreenController(new RosettianClient(), null); var result = testCleanAndScreenController.SendCommand(serialNumber, command); Assert.IsNotNull(result, "Send Command result is null"); Assert.IsTrue(performEquipmentOperationWasCalled, "PerformEquipmentOperation was not called"); Assert.IsTrue(result is JsonResult, "Result is not a JSON Result"); var testJsonResult = result as JsonResult; Assert.AreEqual(expectedJSON, testJsonResult.Data.ToString(), string.Format("Resulting JSON is incorrect: Actual-{0} Expected-{1}", testJsonResult.Data.ToString(), expectedJSON)); } }