public void InvokeOperation_ServerValidationException() { TestProvider_Scenarios provider = ServerTestHelper.CreateInitializedDomainService <TestProvider_Scenarios>(DomainOperationType.Invoke); DomainServiceDescription serviceDescription = DomainServiceDescription.GetDescription(typeof(TestProvider_Scenarios)); DomainOperationEntry throwValidationExceptionMethod = serviceDescription.GetInvokeOperation("ThrowValidationException"); Assert.IsNotNull(throwValidationExceptionMethod); IEnumerable <ValidationResult> validationErrors; object result = provider.Invoke(new InvokeDescription(throwValidationExceptionMethod, new object[0]), out validationErrors); Assert.IsNull(result); Assert.IsNotNull(validationErrors); Assert.AreEqual(1, validationErrors.Count()); Assert.AreEqual("Validation error.", validationErrors.ElementAt(0).ErrorMessage); }
public void InvokeOperation_ServerValidationError() { TestProvider_Scenarios provider = ServerTestHelper.CreateInitializedDomainService <TestProvider_Scenarios>(DomainOperationType.Invoke); DomainServiceDescription serviceDescription = DomainServiceDescription.GetDescription(typeof(TestProvider_Scenarios)); DomainOperationEntry incrementBid1ForAByMethod = serviceDescription.GetInvokeOperation("IncrementBid1ForABy"); Assert.IsNotNull(incrementBid1ForAByMethod); IEnumerable <ValidationResult> validationErrors; TestDomainServices.A inputA = new TestDomainServices.A() { BID1 = 1 }; object result = provider.Invoke(new InvokeDescription(incrementBid1ForAByMethod, new object[] { inputA, 2 }), out validationErrors); Assert.IsNull(result); Assert.IsNotNull(validationErrors); Assert.AreEqual(2, validationErrors.Count()); Assert.AreEqual("The field delta must be between 5 and 10.", validationErrors.ElementAt(0).ErrorMessage); Assert.AreEqual("The RequiredString field is required.", validationErrors.ElementAt(1).ErrorMessage); }