public void OMM_Exception_SubConfiguration_WithSubAccessor_WithMessageLambda()
        {
            MyCommunicationException ex = new MyCommunicationException("ServerTooBusy", new ServerTooBusyException());
            string value = ObjectMessageMap.GetMessage(ex);

            Assert.AreEqual(TestResources.SERVER_TO_BUSY, value);
        }
        public void OMM_Exception_SubConfiguration_WithSubAccessor_SimpleMapping()
        {
            MyCommunicationException ex = new MyCommunicationException("ChannelTerminated", new ChannelTerminatedException());
            string value = ObjectMessageMap.GetMessage(ex);

            Assert.AreEqual(TestResources.SERVER_ERROR, value);
        }
        public void OMM_Enum_HasTypeNameAccessor_SubValueConfigurations_HasAccessor_NotConfigured()
        {
            UserConfigureStatus status = UserConfigureStatus.NotConfigured;
            string typeName1           = ObjectMessageMap.GetMessage(status);
            string typeName2           = ObjectMessageMap.GetMessage(UserConfigureStatus.NotConfigured);

            Assert.AreEqual(typeName1, typeName2);
            Assert.AreEqual("Not Configured", typeName1);
        }
        public void OMM_Exception_SubConfiguration_WithConditional_Default_SubValueConfiguration_NoLicenses()
        {
            AppReturnedErrorException ex = new AppReturnedErrorException("")
            {
                ErrorCode = ErrorCodes.NoLicenses
            };
            string value = ObjectMessageMap.GetMessage(ex);

            Assert.AreEqual(TestResources.NO_LICENSES, value);
        }
        public void OMM_Exception_SubConfiguration_WithConditional_Default_SubValueConfiguration_AccessDenied()
        {
            AppReturnedErrorException ex = new AppReturnedErrorException("")
            {
                ErrorCode = ErrorCodes.AccessDenied
            };
            string value = ObjectMessageMap.GetMessage(ex);

            Assert.AreEqual(TestResources.ACCESS_DENIED, value);
        }
        public void OMM_EntityType_SimpleMapping_Resources()
        {
            TestUser user = new TestUser();

            string value1 = ObjectMessageMap.GetMessage(user);
            string value2 = ObjectMessageMap.GetMessage(typeof(TestUser));

            Assert.AreEqual(TestResources.EntityUser, value1);
            Assert.AreEqual(value1, value2);
        }
        public void OMM_SubConfig_NotFound_NoDefault()
        {
            DuplicateNameException user = new DuplicateNameException();

            string value1 = ObjectMessageMap.GetMessage(user);
            string value2 = ObjectMessageMap.GetMessage(typeof(DuplicateNameException));

            Assert.AreEqual("", value1);
            Assert.AreEqual(value1, value2);
        }
        public void OMM_Exception_Simple_MappedToResourcese_NoSubConfiguration()
        {
            EndpointNotFoundException ex = new EndpointNotFoundException();
            string value1 = ObjectMessageMap.GetMessage(ex);
            string value2 = ObjectMessageMap.GetMessage(typeof(EndpointNotFoundException));

            Assert.AreEqual(value1, value2);

            Assert.AreEqual(TestResources.SERVER_NOT_FOUND, value1);
        }
        public void OMM_Enum_UserType_MappedToResources_EnumValue_Lambda_RecursiveCallback()
        {
            UserType userType = UserType.User;

            string value1 = ObjectMessageMap.GetMessage(userType);
            string value2 = ObjectMessageMap.GetMessage(UserType.User);

            Assert.AreEqual(value1, value2);
            Assert.AreEqual(TestResources.EntityUser, value1);
        }
        public void OMM_Enum_UserType_MappedToResources_EnumValue_WithLambda()
        {
            UserType userType = UserType.CustomerAdministrator;

            string value1 = ObjectMessageMap.GetMessage(userType);
            string value2 = ObjectMessageMap.GetMessage(UserType.CustomerAdministrator);

            Assert.AreEqual(value1, value2);
            Assert.AreEqual("Customer Administrator", value1);
        }
        public void OMM_EntityType_SimpleMapping_Default_Resources()
        {
            Customer customer = new Customer();

            string value1 = ObjectMessageMap.GetMessage(customer);
            string value2 = ObjectMessageMap.GetMessage(customer.GetType());

            Assert.AreEqual(TestResources.ENTITY_CUSTOMER, value1);
            Assert.AreEqual(TestResources.ENTITY_CUSTOMER, value2);
        }
        public void OMM_EntityType_SimpleMapping_Default_MessageLambda()
        {
            UnMappedObject unMappedObj = new UnMappedObject();

            string value1 = ObjectMessageMap.GetMessage(unMappedObj);
            string value2 = ObjectMessageMap.GetMessage(unMappedObj.GetType());

            Assert.AreEqual(unMappedObj.ToString(), value1);
            Assert.AreEqual(unMappedObj.ToString(), value2);
        }
        public void OMM_Enum_UserType_MappedToResources_EnumType_MappedToResources()
        {
            UserType userType = UserType.Unknown;

            string value1 = ObjectMessageMap.GetMessage(userType);
            string value2 = ObjectMessageMap.GetMessage(UserType.Unknown);

            Assert.AreEqual(value1, value2);
            Assert.AreEqual(TestResources.ENUM_USER_TYPE_UNKNOWN, value1);
        }
        public void OMM_Exception_SubConfiguration_MappedToResourcese()
        {
            PermissionException ex = new PermissionException();
            string value1          = ObjectMessageMap.GetMessage(ex);
            string value2          = ObjectMessageMap.GetMessage(typeof(PermissionException));

            Assert.AreEqual(value1, value2);

            Assert.AreEqual(TestResources.PERMISSION_DENIED, value1);
        }
        public void OMM_EntityType_SimpleMapping_Resources_SecondEntry()
        {
            ApplicationInstance user = new ApplicationInstance();

            string value1 = ObjectMessageMap.GetMessage(user);
            string value2 = ObjectMessageMap.GetMessage(typeof(ApplicationInstance));

            Assert.AreEqual(TestResources.ENTITY_APPLICATION_INSTANCE, value1);
            Assert.AreEqual(value1, value2);
        }
        public void OMM_Exception_SubConfiguration_WithSubAccessor_SimpleMapping_WithFormatData()
        {
            string myLink = DataGenerator.RandomString(15);
            MyCommunicationException ex = new MyCommunicationException("EndpointNotFound", new EndpointNotFoundException()
            {
                HelpLink = myLink
            });
            string value = ObjectMessageMap.GetMessage(ex);

            Assert.AreEqual(string.Format(TestResources.SERVER_NOT_FOUND2, myLink), value);
        }
        public void OMM_Exception_SubConfiguration_WithSubAccessor_Default_WithValueConfig()
        {
            PermissionException inner = new PermissionException();

            inner.Data.Add("key1", "value1");
            inner.Data.Add("key2", "value2");
            MyCommunicationException ex = new MyCommunicationException("ServerTooBusy", inner);
            string value = ObjectMessageMap.GetMessage(ex);

            Assert.AreEqual(string.Format(TestResources.COMMUNICATION_ERROR_2, "Count: 2"), value);
        }
        public void OMM_Exception_SubConfiguration_MappedToResourcese_WithData_Recursive()
        {
            NotFoundException ex1 = new NotFoundException(typeof(TestUser));
            NotFoundException ex2 = new NotFoundException(typeof(ApplicationInstance));

            string message1 = ObjectMessageMap.GetMessage(ex1);
            string message2 = ObjectMessageMap.GetMessage(ex2);

            Assert.AreEqual(string.Format(TestResources.EXCEPTION_NOT_FOUND, TestResources.EntityUser), message1);
            Assert.AreEqual(string.Format(TestResources.EXCEPTION_NOT_FOUND, TestResources.ENTITY_APPLICATION_INSTANCE), message2);
        }
        public void OMM_Exception_SubConfiguration_Default_WithData()
        {
            string errorMessage       = DataGenerator.RandomString(50);
            string errorSource        = DataGenerator.RandomString(25);
            ServerTooBusyException ex = new ServerTooBusyException(errorMessage)
            {
                Source = errorSource
            };
            string value = ObjectMessageMap.GetMessage(ex);

            Assert.AreEqual(string.Format(TestResources.UNKNOWN_SERVER_ERROR, errorMessage, errorSource), value);
        }
        public void OMM_Exception_SubConfiguration_WithConditional_WhenMatched_ResourceMessage_WithData()
        {
            string appName = DataGenerator.RandomString(25);
            AppReturnedErrorException ex = new AppReturnedErrorException("")
            {
                ErrorCode      = ErrorCodes.Success,
                AppDisplayName = appName
            };
            string value = ObjectMessageMap.GetMessage(ex);

            Assert.AreEqual(string.Format(TestResources.RESULT_SUCCESS, appName), value);
        }
        public void OMM_SubConfig_Object_Conditional_Default_UseMessage_ValueNotFound()
        {
            Object5 obj = new Object5()
            {
                Value = 51
            };

            string value1 = ObjectMessageMap.GetMessage(obj);
            string value2 = ObjectMessageMap.GetMessage(typeof(Object5));

            Assert.AreEqual("", value1);
            Assert.AreEqual("", value2);
        }
        public void OMM_SubConfig_Object_Conditional_SubConfigure_NoNewType()
        {
            Object4 obj = new Object4()
            {
                Value = 5000
            };

            string value1 = ObjectMessageMap.GetMessage(obj);
            string value2 = ObjectMessageMap.GetMessage(typeof(Object4));

            Assert.AreEqual("Bullseye!", value1);
            Assert.AreEqual("", value2);
        }
        public void OMM_SubConfig_Object_ConditionalDefault_SubConfigure_NoNewType()
        {
            Object3 obj = new Object3()
            {
                Value = 3254
            };

            string value1 = ObjectMessageMap.GetMessage(obj);
            string value2 = ObjectMessageMap.GetMessage(typeof(Object3));

            Assert.AreEqual(TestResources.JUST_RIGHT, value1);
            Assert.AreEqual(TestResources.JUST_RIGHT, value2);
        }
        public void OMM_SubConfig_Object_ConditionalDefault_UseMessage_Accessor()
        {
            Object2 obj = new Object2()
            {
                Value = 99
            };

            string value1 = ObjectMessageMap.GetMessage(obj);
            string value2 = ObjectMessageMap.GetMessage(obj.GetType());

            Assert.AreEqual(TestResources.UNDER_LIMIT, value1);
            Assert.AreEqual("", value2);
        }
        public void OMM_SubConfig_Object_ConditionalDefault_UseMessage()
        {
            Object1 obj = new Object1()
            {
                Value = 101
            };

            string value1 = ObjectMessageMap.GetMessage(obj);
            string value2 = ObjectMessageMap.GetMessage(typeof(Object1));

            Assert.AreEqual(TestResources.OVER_LIMIT, value1);
            Assert.AreEqual("", value2);
        }
        public void OMM_SubConfig_Object_Conditional_Default_UseMessage()
        {
            Object6 obj = new Object6()
            {
                Value = 50
            };

            string value1 = ObjectMessageMap.GetMessage(obj);
            string value2 = ObjectMessageMap.GetMessage(typeof(Object6));

            Assert.AreEqual(TestResources.JUST_RIGHT, value1);
            Assert.AreEqual("", value2);
        }
        public void OMM_Exception_SubConfiguration_WithConditional_WhenMatched_LambdaMessage_WithManyDatas()
        {
            string appName               = DataGenerator.RandomString(8);
            string instanceName          = DataGenerator.RandomString(19);
            string logEntryId            = DataGenerator.RandomString(25);
            string errorMessage          = "You had an error. LogEntryID: {0}, Applicaiton: {1}, Instance: {2}";
            AppReturnedErrorException ex = new AppReturnedErrorException(errorMessage)
            {
                ErrorCode           = ErrorCodes.ApplicationSpecificError,
                AppDisplayName      = appName,
                InstanceDisplayName = instanceName,
                ErrorLogEntryId     = logEntryId
            };
            string value = ObjectMessageMap.GetMessage(ex);

            Assert.AreEqual(string.Format(errorMessage, logEntryId, appName, instanceName), value);
        }
        public void OMM_Enum_HasTypeNameAccessor_WithSubValueConfigurations()
        {
            string typeName = ObjectMessageMap.GetMessage(typeof(UserConfigureStatus));

            Assert.AreEqual("Configuration Status", typeName);
        }
        public void OMM_Enum_UserType_MappedToResources_WithMappedEnumTypes()
        {
            string value = ObjectMessageMap.GetMessage(typeof(UserType));

            Assert.AreEqual(TestResources.ENUM_USER_TYPE, value);
        }
        public void OMM_Enum_TypeName_LambdaCallback_Via_UseMessage_NoTypeValueConfiguration()
        {
            string value = ObjectMessageMap.GetMessage(typeof(OwnerType));

            Assert.AreEqual(TestResources.ENUM_OWNER_TYPE, value);
        }