public void UnhandledInvokeOperationError() { CityDomainContext cities = new CityDomainContext(TestURIs.Cities); InvokeOperation invoke = new InvokeOperation("Echo", null, null, null, null); DomainOperationException expectedException = null; DomainOperationException ex = new DomainOperationException("Operation Failed!", OperationErrorStatus.ServerError, 42, "StackTrace"); try { invoke.Complete(ex); } catch (DomainOperationException e) { expectedException = e; } // verify the exception properties Assert.IsNotNull(expectedException); Assert.AreEqual(string.Format(Resource.DomainContext_InvokeOperationFailed, "Echo", ex.Message), expectedException.Message); Assert.AreEqual(ex.StackTrace, expectedException.StackTrace); Assert.AreEqual(ex.Status, expectedException.Status); Assert.AreEqual(ex.ErrorCode, expectedException.ErrorCode); Assert.AreEqual(false, invoke.IsErrorHandled); // now test again with validation errors expectedException = null; ValidationResult[] validationErrors = new ValidationResult[] { new ValidationResult("Foo", new string[] { "Bar" }) }; invoke = new InvokeOperation("Echo", null, null, null, null); try { invoke.Complete(validationErrors); } catch (DomainOperationException e) { expectedException = e; } // verify the exception properties Assert.IsNotNull(expectedException); Assert.AreEqual(string.Format(Resource.DomainContext_InvokeOperationFailed_Validation, "Echo"), expectedException.Message); }