public void TestValuesAreCreated()
        {
            SessionStateBindingStrategy strategy = new SessionStateBindingStrategy();
            MockBuilderContext builderContext = new MockBuilderContext(strategy);
            MockSessionStateLocatorService sessionLocator = new MockSessionStateLocatorService();
            builderContext.Locator.Add(new DependencyResolutionLocatorKey(typeof (ISessionStateLocatorService), null),
                                       sessionLocator);

            SampleClass sample = new SampleClass();
            sample.String0 = "test";
            strategy.BuildUp(builderContext, typeof (SampleClass), sample, null);

            Assert.AreEqual("test", sample.String0);
            Assert.IsNotNull(sample.String1);
            Assert.IsNotNull(sample.String2);
        }
        public void BuildUpReturnsInstanceOfStateValueWithCorrespondantValueFromSessionWhenInjectingProperties()
        {
            Locator locator = new Locator();
            LifetimeContainer container = new LifetimeContainer();
            locator.Add(typeof (ILifetimeContainer), container);
            WCSFBuilder builder = new WCSFBuilder();
            builder.Policies.SetDefault<ISingletonPolicy>(new SingletonPolicy(true));
            MockSessionStateLocatorService stateLocator = new MockSessionStateLocatorService();
            locator.Add(new DependencyResolutionLocatorKey(typeof (ISessionStateLocatorService), null), stateLocator);

            stateLocator.SessionState["intKey"] = 5;
            SampleClass builtObject =
                builder.BuildUp(locator, typeof (SampleClass), Guid.NewGuid().ToString(), null) as SampleClass;

            Assert.IsNotNull(builtObject.MyIntValue);
            Assert.AreEqual(5, builtObject.MyIntValue.Value);
        }
        public void BuildUpReturnsNewInstanceOfStateValue()
        {
            Locator locator = new Locator();
            LifetimeContainer container = new LifetimeContainer();
            locator.Add(typeof (ILifetimeContainer), container);
            WCSFBuilder builder = new WCSFBuilder();
            builder.Policies.SetDefault<ISingletonPolicy>(new SingletonPolicy(true));
            MockSessionStateLocatorService stateLocator = new MockSessionStateLocatorService();
            locator.Add(new DependencyResolutionLocatorKey(typeof (ISessionStateLocatorService), null), stateLocator);

            SampleClass builtObject =
                builder.BuildUp(locator, typeof (SampleClass), Guid.NewGuid().ToString(), null) as SampleClass;

            Assert.IsNotNull(builtObject.MyStringValue);
        }
        public void ValuesArePulledFromSession()
        {
            SessionStateBindingStrategy strategy = new SessionStateBindingStrategy();
            MockBuilderContext builderContext = new MockBuilderContext(strategy);
            MockSessionStateLocatorService sessionLocator = new MockSessionStateLocatorService();
            sessionLocator.SessionState["key"] = "value";
            builderContext.Locator.Add(new DependencyResolutionLocatorKey(typeof (ISessionStateLocatorService), null),
                                       sessionLocator);

            SampleClass sample = new SampleClass();
            strategy.BuildUp(builderContext, typeof (SampleClass), sample, null);

            Assert.AreEqual("value", sample.String2.Value);
        }