public void CanCreateGivenValidOperation()
 {
     OperationDescription operation =
         GetOperationDescription("AddCustomer", typeof(ITestService));
     ValidationParameterInspector inspector = new ValidationParameterInspector(operation, string.Empty);
     Assert.AreEqual(1, inspector.InputValidators.Count);
 }
Example #2
0
        public void CanCreateGivenValidOperation()
        {
            OperationDescription operation =
                GetOperationDescription("AddCustomer", typeof(ITestService));
            ValidationParameterInspector inspector = new ValidationParameterInspector(operation, string.Empty);

            Assert.AreEqual(1, inspector.InputValidators.Count);
        }
Example #3
0
        public void ShouldNotThrowOnValidInput()
        {
            string opName = "AddCustomer";
            ValidationParameterInspector inspector = GetInspector(opName, typeof(ITestService));

            AddCustomerRequest request = new AddCustomerRequest("Jane", "Doe", "987-65-4321");

            inspector.BeforeCall(opName, new object[] { request });
        }
Example #4
0
        public void ShouldThrowValidationFaultInBeforeCallOnInvalidInput()
        {
            string opName = "AddCustomer";
            ValidationParameterInspector inspector = GetInspector(opName, typeof(ITestService));

            AddCustomerRequest request = new AddCustomerRequest("Jane", "Doe", "Invalid SSN");

            inspector.BeforeCall(opName, new object[] { request });
        }
Example #5
0
        public void ShouldPassParameterValidationWithGoodInputs()
        {
            string opName   = "LookupById";
            string implName = "LookupById";

            Type[] opParams = new Type[] { typeof(int), typeof(string) };
            ValidationParameterInspector inspector =
                GetInspector(opName, opParams, implName, typeof(ITestService));

            inspector.BeforeCall(opName, new object[] { 42, "My Text" });
        }
Example #6
0
        public void ShouldPassMultipleInputValidations()
        {
            string opName = "PlaceOrder";
            ValidationParameterInspector inspector = GetInspector(opName, typeof(ITestService));

            string               customerId   = "AGoodCustomer";
            TaxInfo              taxInfo      = new TaxInfo("123434", "WA");
            ItemInfo             itemInfo     = new ItemInfo("Item002", "A Fictitious book", 2);
            CustomerDiscountInfo discountInfo = new CustomerDiscountInfo(customerId, .15);

            inspector.BeforeCall(opName,
                                 new object[] { customerId, taxInfo, itemInfo, discountInfo });
        }
Example #7
0
        public void ShouldRunValidatorsSpecifiedAsParameterAttributes()
        {
            string opName   = "LookupById";
            string implName = "LookupById";

            Type[] opParams = new Type[] { typeof(int), typeof(string) };
            ValidationParameterInspector inspector =
                GetInspector(opName, opParams, implName, typeof(ITestService));

            try
            {
                inspector.BeforeCall(opName, new object[] { -1, null });
                Assert.Fail("Expected exception did not occur");
            }
            catch (FaultException <ValidationFault> e)
            {
                ValidationFault yourFault = e.Detail;
                Assert.IsFalse(yourFault.IsValid);
                Assert.AreEqual(3, yourFault.Details.Count);
            }
        }
Example #8
0
        public void ShouldHaveProperFailureReportsInFault()
        {
            string opName = "PlaceOrder";
            ValidationParameterInspector inspector = GetInspector(opName, typeof(ITestService));

            string               customerId   = "AGoodCustomer";
            TaxInfo              taxInfo      = new TaxInfo("123434", "Not a state");
            ItemInfo             itemInfo     = new ItemInfo("1", "A Fictitious book", -2);
            CustomerDiscountInfo discountInfo = new CustomerDiscountInfo(customerId, .15);

            try
            {
                inspector.BeforeCall(opName,
                                     new object[] { customerId, taxInfo, itemInfo, discountInfo });
                Assert.Fail("Should not have gotten here, was expecting ValidationFault");
            }
            catch (FaultException <ValidationFault> e)
            {
                ValidationFault yourFault = e.Detail;
                Assert.AreEqual(3, yourFault.Details.Count);
            }
        }