예제 #1
0
        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);
        }
예제 #2
0
        public void TestKeyNameAssigned()
        {
            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();

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

            Assert.IsNotNull(sample.String1);
            Assert.IsNotNull(sample.String2);

            Assert.AreEqual("SampleClass;String1", sample.String1.KeyName);
            Assert.AreEqual("key", sample.String2.KeyName);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }