public static void MyClassInitialize(TestContext testContext)
        {
            ObjectMessageMap.Clear();

            try
            {
                ObjectMessageMap.SetResourceManager(TestResources.ResourceManager);

                // Configurations for all Exceptions
                ObjectMessageMap.Configure <Exception>(cfg =>
                {
                    // Basic simple configuration
                    cfg.For <EndpointNotFoundException>().UseMessage("SERVER_NOT_FOUND");

                    // Nested Configurations with no sub property accessor
                    cfg.For <BaseException>().Configure(cfg2 =>
                    {
                        cfg2.For <PermissionException>().UseMessage("PERMISSION_DENIED");
                        cfg2.For <NotFoundException>().UseMessage("EXCEPTION_NOT_FOUND").WithValue(ex => ObjectMessageMap.GetMessage(ex.EntityType));

                        // Nested Configuration with sub property accessor.
                        cfg2.For <MyCommunicationException>().Configure <Exception>(ex => ex.InnerException, cfg3 =>
                        {
                            // Default Configuration with sub property accessor and type change
                            cfg3.Default().Configure <int>(ex => ex.Data.Count, cfg4 =>
                            {
                                cfg4.For(0).UseMessage("COMMUNICATION_ERROR_0").WithValue(value => string.Format("Count: {0:d}", value));
                                cfg4.For(1).UseMessage("COMMUNICATION_ERROR_1").WithValue(value => string.Format("Count: {0:d}", value));
                                cfg4.For(2).UseMessage("COMMUNICATION_ERROR_2").WithValue(value => string.Format("Count: {0:d}", value));
                            });

                            cfg3.For <ChannelTerminatedException>().UseMessage("SERVER_ERROR");
                            cfg3.For <EndpointNotFoundException>().UseMessage("SERVER_NOT_FOUND2").WithValue(ex => ex.HelpLink);
                            cfg3.For <ServerTooBusyException>().UseMessage(ex => TestResources.SERVER_TO_BUSY);
                        });
                    });

                    // Sub Configuration with Conditionals and a Default
                    cfg.For <AppReturnedErrorException>()
                    .When(ex => ex.ErrorCode == ErrorCodes.Success).UseMessage("RESULT_SUCCESS").WithValue(ex => ex.AppDisplayName)
                    .When(ex => ex.ErrorCode == ErrorCodes.ApplicationSpecificError)
                    .UseMessage(ex => ex.Message)
                    .WithValue(ex => ex.ErrorLogEntryId)
                    .WithValue(ex => ex.AppDisplayName)
                    .WithValue(ex => ex.InstanceDisplayName)
                    .Default().Configure <ErrorCodes>(ex => ex.ErrorCode, cfg2 =>
                    {
                        cfg2.For(ErrorCodes.NoLicenses).UseMessage("NO_LICENSES");
                        cfg2.For(ErrorCodes.AccessDenied).UseMessage("ACCESS_DENIED");
                    });

                    // Sub Configuration with no Default
                    cfg.For <DataException>().Configure(cfg2 =>
                    {
                        cfg2.For <ReadOnlyException>().UseMessage("READ_ONLY");
                        cfg2.For <InvalidConstraintException>().UseMessage("INVALID_CONSTRAINT");
                    });

                    // Default for main Exception configuration
                    cfg.Default().UseMessage("UNKNOWN_SERVER_ERROR").WithValue(ex => ex.Message).WithValue(ex => ex.Source);
                });

                // Another call to ObjectMessageMap to configure entity object.
                // TODO[SN] - When Entity object have a base class, then this should be that class and not object.
                ObjectMessageMap.Configure <object>(cfg =>
                {
                    cfg.For <TestUser>().UseMessage("EntityUser");
                    cfg.For <ApplicationInstance>().UseMessage("ENTITY_APPLICATION_INSTANCE");

                    cfg.For <BaseObject>().Configure(cfg2 =>
                    {
                        cfg2.For <Object1>()
                        .When(obj => obj.Value > 100).UseMessage("OVER_LIMIT")
                        .When(obj => obj.Value < 1).UseMessage("UNDER_LIMIT")
                        .Default().UseMessage("JUST_RIGHT");
                        cfg2.For <Object2>()
                        .When(obj => obj.Value > 1000).UseMessage("OVER_LIMIT")
                        .When(obj => obj.Value < 100).UseMessage("UNDER_LIMIT")
                        .Default().UseMessage(obj => TestResources.JUST_RIGHT);
                        cfg2.For <Object3>()
                        .When(obj => obj.Value > 5000).UseMessage("OVER_LIMIT")
                        .When(obj => obj.Value < 1000).UseMessage("UNDER_LIMIT")
                        .Default().Configure(cfg3 =>
                        {
                            cfg.For <Object3>().UseMessage("JUST_RIGHT");
                        });
                        cfg2.For <Object4>()
                        .When(obj => obj.Value > 1000).Configure(cfg3 =>
                        {
                            cfg3.For <Object4>().Configure <int>(obj => obj.Value, cfg4 =>
                            {
                                cfg4.For(5000).UseMessage(obj => "Bullseye!");
                                cfg4.Default().UseMessage(obj => "Missed");
                            });
                        });
                        cfg2.For <Object5>()
                        .When(obj => obj.Value > 1000).UseMessage("OVER_LIMIT")
                        .When(obj => obj.Value < 100).Configure <int>(obj => obj.Value, cfg3 =>
                        {
                            cfg3.For(50).UseMessage(value => "Bullseye!");
                        });

                        cfg2.For <Object6>()
                        .When(obj => obj.Value > 1000).UseMessage("OVER_LIMIT")
                        .Default().UseMessage("JUST_RIGHT");
                    });

                    cfg.For <Customer>().Default().UseMessage("ENTITY_CUSTOMER");

                    cfg.Default().UseMessage(obj => obj.ToString());
                });

                // Another call to ObjectMessageMap to configure enumerated types.
                ObjectMessageMap.Configure <Enum>(cfg =>
                {
                    cfg.For <UserType>("ENUM_USER_TYPE").Configure(cfg2 =>
                    {
                        cfg2.For(UserType.Unknown).UseMessage("ENUM_USER_TYPE_UNKNOWN");
                        cfg2.For(UserType.CustomerAdministrator).UseMessage(userType => "Customer Administrator");
                        cfg2.For(UserType.User).UseMessage(userType => ObjectMessageMap.GetMessage(typeof(TestUser)));
                    });

                    cfg.For <OwnerType>().UseMessage("ENUM_OWNER_TYPE");
                    cfg.For <MyTestEnum>().UseMessage(obj => "My Test Type");

                    cfg.For <UserConfigureStatus>(status => "Configuration Status").Configure(cfg2 =>
                    {
                        cfg2.For(UserConfigureStatus.Configured).UseMessage(status => "Configured");
                        cfg2.For(UserConfigureStatus.NotConfigured).UseMessage(status => "Not Configured");
                    });

                    cfg.Default().Configure(cfg2 =>
                    {
                        cfg2.For <ActorRole>().UseMessage("ENUM_ACTOR");
                    });
                });
            }
            catch (Exception ex)
            {
                string s = ex.Message;
                throw;
            }
        }
 public static void MyClassCleanup()
 {
     ObjectMessageMap.Clear();
 }