public void GetDefaultFaultTypeForDefinedErrorCodeWithIncorrectFaultTypeWhenGetUserErrorInfoIsCalled()
        {
            using (new InstanceMethodCallIsolator<UserErrorConfigSection>(UnitTestConstant.SimulationMethodName.UserMessageConfigSectionGetErrorsMethodName,
                delegate
                {
                    // Simulate non-empty configuration with invalid fault type value.
                    UserErrorCollection collection = new UserErrorCollection();
                    collection[EventCode.DatabaseEvent.Validation.ActivityCategoryNotFound] = new UserErrorElement
                    {
                        ErrorCode = EventCode.DatabaseEvent.Validation.ActivityCategoryNotFound,
                        UserMessage = "Unable to update the specified activity category.",
                        FaultType = "UnknownFault"
                    };
                    collection[EventCode.BusinessLayerEvent.Error.WorkflowDefinitionByNameVersionNotFound] = new UserErrorElement
                    {
                        ErrorCode = EventCode.BusinessLayerEvent.Error.WorkflowDefinitionByNameVersionNotFound,
                        UserMessage = "Workflow not found.",
                        FaultType = "InvalidFault"
                    };
                    collection[EventCode.BusinessLayerEvent.Validation.CallerNameRequired] = new UserErrorElement
                    {
                        ErrorCode = EventCode.BusinessLayerEvent.Validation.CallerNameRequired,
                        UserMessage = "Caller name required.",
                        FaultType = "JunkFault"
                    };
                    return collection;
                }))
                {
                UserErrorInfo errorInfo = UserErrorInfo.GetUserErrorInfo(EventCode.BusinessLayerEvent.Error.WorkflowDefinitionByNameVersionNotFound);
                Assert.AreEqual(FaultType.ServiceFault, errorInfo.FaultType);

                errorInfo = UserErrorInfo.GetUserErrorInfo(EventCode.BusinessLayerEvent.Validation.CallerNameRequired);
                Assert.AreEqual(FaultType.ServiceFault, errorInfo.FaultType);
            }
        }
Exemplo n.º 2
0
 internal static InstanceMethodCallIsolator<UserErrorConfigSection> GetValidConfigurationWithMixedCaseFaultType()
 {
     return new InstanceMethodCallIsolator<UserErrorConfigSection>(UnitTestConstant.SimulationMethodName.UserMessageConfigSectionGetErrorsMethodName,
                   delegate
                   {
                       UserErrorCollection collection = new UserErrorCollection();
                       collection[EventCode.DatabaseEvent.Validation.ActivityCategoryNotFound] = new UserErrorElement
                       {
                           ErrorCode = EventCode.DatabaseEvent.Validation.ActivityCategoryNotFound,
                           UserMessage = "Unable to update the specified activity category.",
                           FaultType = "servicefault"
                       };
                       collection[EventCode.BusinessLayerEvent.Error.WorkflowDefinitionByNameVersionNotFound] = new UserErrorElement
                       {
                           ErrorCode = EventCode.BusinessLayerEvent.Error.WorkflowDefinitionByNameVersionNotFound,
                           UserMessage = "Workflow not found.",
                           FaultType = "pUbliShingfAuLt"
                       };
                       collection[EventCode.BusinessLayerEvent.Validation.CallerNameRequired] = new UserErrorElement
                       {
                           ErrorCode = EventCode.BusinessLayerEvent.Validation.CallerNameRequired,
                           UserMessage = "Caller name required.",
                           FaultType = "VALIDATIONFAULT"
                       };
                       return collection;
                   });
 }
Exemplo n.º 3
0
 internal static InstanceMethodCallIsolator<UserErrorConfigSection> GetValidConfiguration()
 {
     return new InstanceMethodCallIsolator<UserErrorConfigSection>(UnitTestConstant.SimulationMethodName.UserMessageConfigSectionGetErrorsMethodName,
                    delegate
                    {
                        // Simulate valid non-empty configuration.
                        UserErrorCollection collection = new UserErrorCollection();
                        collection[EventCode.DatabaseEvent.Validation.ActivityCategoryNotFound] = new UserErrorElement
                        {
                            ErrorCode = EventCode.DatabaseEvent.Validation.ActivityCategoryNotFound,
                            UserMessage = UnitTestConstant.UserErrorMessage.ActivityCategoryNotFound,
                            FaultType = "ServiceFault"
                        };
                        collection[EventCode.BusinessLayerEvent.Error.WorkflowDefinitionByNameVersionNotFound] = new UserErrorElement
                        {
                            ErrorCode = EventCode.BusinessLayerEvent.Error.WorkflowDefinitionByNameVersionNotFound,
                            UserMessage = UnitTestConstant.UserErrorMessage.WorkflowDefinitionByNameVersionNotFound,
                            FaultType = "PublishingFault"
                        };
                        collection[EventCode.BusinessLayerEvent.Validation.CallerNameRequired] = new UserErrorElement
                        {
                            ErrorCode = EventCode.BusinessLayerEvent.Validation.CallerNameRequired,
                            UserMessage = UnitTestConstant.UserErrorMessage.CallerNameRequired,
                            FaultType = "ValidationFault"
                        };
                        return collection;
                    });
 }
Exemplo n.º 4
0
 internal static InstanceMethodCallIsolator<UserErrorConfigSection> GetEmptyConfiguration()
 {
     return new InstanceMethodCallIsolator<UserErrorConfigSection>(UnitTestConstant.SimulationMethodName.UserMessageConfigSectionGetErrorsMethodName,
                   delegate
                   {
                       UserErrorCollection collection = new UserErrorCollection();
                       return collection;
                   });
 }
        public void GetMatchingFaultTypeIfConfiguredInMixedCaseCharsWhenGetUserErrorInfoIsCalled()
        {
            using (new InstanceMethodCallIsolator<UserErrorConfigSection>(UnitTestConstant.SimulationMethodName.UserMessageConfigSectionGetErrorsMethodName,
                           delegate
                           {
                               // Simulate empty configuration with fault type value in mixed case (inconsistent upper/lower casing).
                               UserErrorCollection collection = new UserErrorCollection();
                               collection[EventCode.DatabaseEvent.Validation.ActivityCategoryNotFound] = new UserErrorElement
                               {
                                   ErrorCode = EventCode.DatabaseEvent.Validation.ActivityCategoryNotFound,
                                   UserMessage = "Unable to update the specified activity category.",
                                   FaultType = "servicefault"
                               };
                               collection[EventCode.BusinessLayerEvent.Error.WorkflowDefinitionByNameVersionNotFound] = new UserErrorElement
                               {
                                   ErrorCode = EventCode.BusinessLayerEvent.Error.WorkflowDefinitionByNameVersionNotFound,
                                   UserMessage = "Workflow not found.",
                                   FaultType = "pUbliShingfAuLt"
                               };
                               collection[EventCode.BusinessLayerEvent.Validation.CallerNameRequired] = new UserErrorElement
                               {
                                   ErrorCode = EventCode.BusinessLayerEvent.Validation.CallerNameRequired,
                                   UserMessage = "Caller name required.",
                                   FaultType = "VALIDATIONFAULT"
                               };
                               return collection;
                           }))
            {
                UserErrorInfo errorInfo = UserErrorInfo.GetUserErrorInfo(EventCode.DatabaseEvent.Validation.ActivityCategoryNotFound);
                Assert.AreEqual(FaultType.ServiceFault, errorInfo.FaultType);

                errorInfo = UserErrorInfo.GetUserErrorInfo(EventCode.BusinessLayerEvent.Error.WorkflowDefinitionByNameVersionNotFound);
                Assert.AreEqual(FaultType.PublishingFault, errorInfo.FaultType);

                errorInfo = UserErrorInfo.GetUserErrorInfo(EventCode.BusinessLayerEvent.Validation.CallerNameRequired);
                Assert.AreEqual(FaultType.ValidationFault, errorInfo.FaultType);
            }
        }
 public void ReturnGeneralServiceIfConfiguredFaultTypeIsInvalidWhenGetFaultExceptionIsCalled()
 {
     using (new InstanceMethodCallIsolator<UserErrorConfigSection>(UnitTestConstant.SimulationMethodName.UserMessageConfigSectionGetErrorsMethodName,
                   delegate
                   {
                       UserErrorCollection collection = new UserErrorCollection();
                       collection[EventCode.DatabaseEvent.Validation.ActivityCategoryNotFound] = new UserErrorElement
                       {
                           ErrorCode = EventCode.DatabaseEvent.Validation.ActivityCategoryNotFound,
                           UserMessage = "Unable to update the specified activity category.",
                           FaultType = "UnknownFault"
                       };
                       collection[EventCode.BusinessLayerEvent.Error.WorkflowDefinitionByNameVersionNotFound] = new UserErrorElement
                       {
                           ErrorCode = EventCode.BusinessLayerEvent.Error.WorkflowDefinitionByNameVersionNotFound,
                           UserMessage = "Workflow not found.",
                           FaultType = "InvalidFault"
                       };
                       collection[EventCode.BusinessLayerEvent.Validation.CallerNameRequired] = new UserErrorElement
                       {
                           ErrorCode = EventCode.BusinessLayerEvent.Validation.CallerNameRequired,
                           UserMessage = "Caller name required.",
                           FaultType = "JunkFault"
                       };
                       return collection;
                   }))
     {
         FaultException exception = FaultExceptionUtility.GetFaultException(EventCode.DatabaseEvent.Validation.ActivityCategoryNotFound);
         Assert.IsTrue(exception is FaultException<ServiceFault>);
         FaultException<ServiceFault> faultException = exception as FaultException<ServiceFault>;
         Assert.AreEqual(UnitTestConstant.UserErrorMessage.ActivityCategoryNotFound, faultException.Detail.ErrorMessage);
         Assert.AreEqual(EventCode.DatabaseEvent.Validation.ActivityCategoryNotFound, faultException.Detail.ErrorCode);
     }
 }