Esempio n. 1
0
        public void WorksWithPropertyInjection()
        {
            // --- Arrange
            var ltManager = new PerCallLifetimeManager
            {
                ServiceObjectType = typeof(SampleObject),
                Properties        = new PropertySettingsCollection(new List <PropertySettings>
                {
                    new PropertySettings("Property1", "23"),
                    new PropertySettings("Property2", "hey")
                })
            };

            // --- Act
            var instance1 = ltManager.GetObject() as SampleObject;
            var instance2 = ltManager.GetObject() as SampleObject;

            // --- Assert
            instance1.ShouldNotBeNull();
            instance2.ShouldNotBeNull();
            // ReSharper disable PossibleNullReferenceException
            instance1.Property1.ShouldEqual(23);
            instance1.Property2.ShouldEqual("hey");
            instance2.Property1.ShouldEqual(23);
            instance2.Property2.ShouldEqual("hey");
            // ReSharper restore PossibleNullReferenceException
            instance1.ShouldNotBeSameAs(instance2);
        }
Esempio n. 2
0
        public void WorksWithTypeOnly()
        {
            // --- Arrange
            var ltManager = new PerCallLifetimeManager {
                ServiceObjectType = typeof(SampleObject)
            };

            // --- Act
            var instance1 = ltManager.GetObject() as SampleObject;
            var instance2 = ltManager.GetObject() as SampleObject;

            // --- Assert
            instance1.ShouldNotBeNull();
            instance2.ShouldNotBeNull();
            // ReSharper disable PossibleNullReferenceException
            instance1.Property1.ShouldEqual(SampleObject.DEFAULT_INT);
            instance1.Property2.ShouldEqual(SampleObject.DEFAULT_STRING);
            instance2.Property1.ShouldEqual(SampleObject.DEFAULT_INT);
            instance2.Property2.ShouldEqual(SampleObject.DEFAULT_STRING);
            // ReSharper restore PossibleNullReferenceException
            instance1.ShouldNotBeSameAs(instance2);
        }
Esempio n. 3
0
        public void WorksWithConstructorParams1()
        {
            // --- Arrange
            var ltManager = new PerCallLifetimeManager
            {
                ServiceObjectType      = typeof(SampleObject),
                ConstructionParameters = new object[] { 23, "hey" }
            };

            // --- Act
            var instance1 = ltManager.GetObject() as SampleObject;
            var instance2 = ltManager.GetObject() as SampleObject;

            // --- Assert
            instance1.ShouldNotBeNull();
            instance2.ShouldNotBeNull();
            // ReSharper disable PossibleNullReferenceException
            instance1.Property1.ShouldEqual(23);
            instance1.Property2.ShouldEqual("hey");
            instance2.Property1.ShouldEqual(23);
            instance2.Property2.ShouldEqual("hey");
            // ReSharper restore PossibleNullReferenceException
            instance1.ShouldNotBeSameAs(instance2);
        }