public void PropertyOverrideWithDefaultInConfig()
        {
            TestTypeInConfig overrideObject = new TestTypeInConfig(666);

            IUnityContainer container = ConfigurationFixtureBase.GetContainer(@"ConfigFiles\PropertyOverride.config",
                "PropertyOverrideContainer");

            var defaultResult = container.Resolve<TestTypeInConfig>("MyTestTypeToOverride");
            PropertyOverrides overrides = new PropertyOverrides();
            overrides.Add("X", 9999);
            overrides.Add("Y", "Overridden");
            var overriddenResult = container.Resolve<TestTypeInConfig>("MyTestTypeToOverride", overrides);

            Assert.AreEqual<int>(101, defaultResult.Value);
            Assert.AreEqual<int>(-111, defaultResult.X);
            Assert.AreEqual<string>("DefaultFromConfigFile", defaultResult.Y);
            Assert.AreEqual<int>(101, overriddenResult.Value);
            Assert.AreEqual<int>(9999, overriddenResult.X);
            Assert.AreEqual<string>("Overridden", overriddenResult.Y);
        }
        public void PropertyOverrideWithCode()
        {
            TestTypeInConfig overrideObject = new TestTypeInConfig();

            IUnityContainer container = new UnityContainer();

            container.RegisterType <TestTypeInConfig>(new InjectionProperty("X", -111),
                                                      new InjectionProperty("Y", "default"), new InjectionConstructor());
            var defaultResult           = container.Resolve <TestTypeInConfig>();
            PropertyOverrides overrides = new PropertyOverrides();

            overrides.Add("X", 9999);
            overrides.Add("Y", "Overridden");
            var overriddenResult = container.Resolve <TestTypeInConfig>(overrides);

            Assert.AreEqual <int>(-111, defaultResult.X);
            Assert.AreEqual <string>("default", defaultResult.Y);
            Assert.AreEqual <int>(9999, overriddenResult.X);
            Assert.AreEqual <string>("Overridden", overriddenResult.Y);
        }
        public void PropertyOverrideWithDefaultInConfig()
        {
            TestTypeInConfig overrideObject = new TestTypeInConfig(666);

            IUnityContainer container = ConfigurationFixtureBase.GetContainer(@"ConfigFiles\PropertyOverride.config",
                                                                              "PropertyOverrideContainer");

            var defaultResult           = container.Resolve <TestTypeInConfig>("MyTestTypeToOverride");
            PropertyOverrides overrides = new PropertyOverrides();

            overrides.Add("X", 9999);
            overrides.Add("Y", "Overridden");
            var overriddenResult = container.Resolve <TestTypeInConfig>("MyTestTypeToOverride", overrides);

            Assert.AreEqual <int>(101, defaultResult.Value);
            Assert.AreEqual <int>(-111, defaultResult.X);
            Assert.AreEqual <string>("DefaultFromConfigFile", defaultResult.Y);
            Assert.AreEqual <int>(101, overriddenResult.Value);
            Assert.AreEqual <int>(9999, overriddenResult.X);
            Assert.AreEqual <string>("Overridden", overriddenResult.Y);
        }
        public void PropertyOverrideWithCode()
        {
            TestTypeInConfig overrideObject = new TestTypeInConfig();

            IUnityContainer container = new UnityContainer();

            container.RegisterType<TestTypeInConfig>(new InjectionProperty("X", -111),
                new InjectionProperty("Y", "default"), new InjectionConstructor());
            var defaultResult = container.Resolve<TestTypeInConfig>();
            PropertyOverrides overrides = new PropertyOverrides();
            overrides.Add("X", 9999);
            overrides.Add("Y", "Overridden");
            var overriddenResult = container.Resolve<TestTypeInConfig>(overrides);

            Assert.AreEqual<int>(-111, defaultResult.X);
            Assert.AreEqual<string>("default", defaultResult.Y);
            Assert.AreEqual<int>(9999, overriddenResult.X);
            Assert.AreEqual<string>("Overridden", overriddenResult.Y);
        }