public void GetObjectWithoutSupplyingASourceList()
        {
            ListFactoryObject lfo = new ListFactoryObject();

            lfo.IsSingleton = false;
            lfo.GetObject();
        }
        public void GetObjectWithoutSupplyingASourceList()
        {
            ListFactoryObject lfo = new ListFactoryObject();

            lfo.IsSingleton = false;
            Assert.Throws <ArgumentException>(() => lfo.GetObject(), "The 'SourceList' property cannot be null (Nothing in Visual Basic.NET).");
        }
        public void GetObjectReallyDoesPopulateANewIListInstanceWithTheElementsOfTheSourceList()
        {
            // man, that has got to be my second longest ever test name :D ...
            IList source = new TestObject[]
            {
                new TestObject("Rick", 30),
                new TestObject("Mark", 35),
                new TestObject("Griffin", 21),
            };

            ListFactoryObject lfo = new ListFactoryObject();

            lfo.SourceList = source;
            lfo.AfterPropertiesSet();

            IList list = (IList)lfo.GetObject();

            Assert.IsNotNull(list);
            Assert.AreEqual(source.Count, list.Count);
            for (int i = 0; i < list.Count; ++i)
            {
                TestObject dude         = (TestObject)list[i];
                TestObject originalDude = (TestObject)source[i];
                Assert.IsTrue(object.ReferenceEquals(dude, originalDude));
            }
        }
        public void SetTargetListTypeToNull()
        {
            ListFactoryObject lfo = new ListFactoryObject();

            Assert.Throws <ArgumentNullException>(() => lfo.TargetListType = null);
        }
        public void SetTargetListTypeToAbstractIListInterfaceType()
        {
            ListFactoryObject lfo = new ListFactoryObject();

            Assert.Throws <ArgumentException>(() => lfo.TargetListType = typeof(AbstractList), "The Type passed to the TargetListType property cannot be abstract (MustInherit in VisualBasic.NET); it must be a concrete class that implements the 'System.Collections.IList' interface.");
        }
        public void SetTargetListTypeToDerivedIListInterfaceType()
        {
            ListFactoryObject lfo = new ListFactoryObject();

            lfo.TargetListType = typeof(IExtendedList);
        }
		public void GetObjectReallyDoesPopulateANewIListInstanceWithTheElementsOfTheSourceList()
		{
			// man, that has got to be my second longest ever test name :D ...
			IList source = new TestObject[]
				{
					new TestObject("Rick", 30),
					new TestObject("Mark", 35),
					new TestObject("Griffin", 21),
				};

			ListFactoryObject lfo = new ListFactoryObject();
			lfo.SourceList = source;
			lfo.AfterPropertiesSet();

			IList list = (IList) lfo.GetObject();
			Assert.IsNotNull(list);
			Assert.AreEqual(source.Count, list.Count);
			for (int i = 0; i < list.Count; ++i)
			{
				TestObject dude = (TestObject) list[i];
				TestObject originalDude = (TestObject) source[i];
				Assert.IsTrue(object.ReferenceEquals(dude, originalDude));
			}
		}
		public void SetTargetListTypeToNull()
		{
			ListFactoryObject lfo = new ListFactoryObject();
			lfo.TargetListType = null;
		}
		public void SetTargetListTypeToDerivedIListInterfaceType()
		{
			ListFactoryObject lfo = new ListFactoryObject();
			lfo.TargetListType = typeof (IExtendedList);
		}
		public void SetTargetListTypeToAbstractIListInterfaceType()
		{
			ListFactoryObject lfo = new ListFactoryObject();
            Assert.Throws<ArgumentException>(() => lfo.TargetListType = typeof (AbstractList), "The Type passed to the TargetListType property cannot be abstract (MustInherit in VisualBasic.NET); it must be a concrete class that implements the 'System.Collections.IList' interface.");
		}
		public void SetTargetListTypeToDerivedIListInterfaceType()
		{
			ListFactoryObject lfo = new ListFactoryObject();
            Assert.Throws<ArgumentException>(() => lfo.TargetListType = typeof (IExtendedList), "The Type passed to the TargetListType property cannot be an interface; it must be a concrete class that implements the 'System.Collections.IList' interface.");
		}
		public void SetTargetListTypeToNonListType()
		{
			ListFactoryObject lfo = new ListFactoryObject();
            Assert.Throws<ArgumentException>(() => lfo.TargetListType = typeof (ICollection), "The Type passed to the TargetListType property must implement the 'System.Collections.IList' interface.");
		}
        public void SetTargetListTypeToNull()
        {
            ListFactoryObject lfo = new ListFactoryObject();

            lfo.TargetListType = null;
        }
        public void SetTargetListTypeToAbstractIListInterfaceType()
        {
            ListFactoryObject lfo = new ListFactoryObject();

            lfo.TargetListType = typeof(AbstractList);
        }
		public void SetTargetListTypeToNull()
		{
			ListFactoryObject lfo = new ListFactoryObject();
            Assert.Throws<ArgumentNullException>(() => lfo.TargetListType = null);
		}
예제 #16
0
		public void SetTargetListTypeToNonListType()
		{
			ListFactoryObject lfo = new ListFactoryObject();
			lfo.TargetListType = typeof (ICollection);
		}
		public void GetObjectWithoutSupplyingASourceList()
		{
			ListFactoryObject lfo = new ListFactoryObject();
			lfo.IsSingleton = false;
            Assert.Throws<ArgumentException>(() => lfo.GetObject(), "The 'SourceList' property cannot be null (Nothing in Visual Basic.NET).");
		}
예제 #18
0
		public void SetTargetListTypeToAbstractIListInterfaceType()
		{
			ListFactoryObject lfo = new ListFactoryObject();
			lfo.TargetListType = typeof (AbstractList);
		}
        public void SetTargetListTypeToNonListType()
        {
            ListFactoryObject lfo = new ListFactoryObject();

            Assert.Throws <ArgumentException>(() => lfo.TargetListType = typeof(ICollection), "The Type passed to the TargetListType property must implement the 'System.Collections.IList' interface.");
        }
예제 #20
0
		public void GetObjectWithoutSupplyingASourceList()
		{
			ListFactoryObject lfo = new ListFactoryObject();
			lfo.IsSingleton = false;
			lfo.GetObject();
		}
        public void SetTargetListTypeToDerivedIListInterfaceType()
        {
            ListFactoryObject lfo = new ListFactoryObject();

            Assert.Throws <ArgumentException>(() => lfo.TargetListType = typeof(IExtendedList), "The Type passed to the TargetListType property cannot be an interface; it must be a concrete class that implements the 'System.Collections.IList' interface.");
        }
        public void CollectionFactoryDefaults()
        {
            ListFactoryObject listFactory = new ListFactoryObject();
            listFactory.SourceList = new ArrayList();
            listFactory.AfterPropertiesSet();
            Assert.IsTrue(listFactory.GetObject() is ArrayList);

            SetFactoryObject setFactory = new SetFactoryObject();
            setFactory.SourceSet = new HybridSet();
            setFactory.AfterPropertiesSet();
            Assert.IsTrue(setFactory.GetObject() is HybridSet);

            DictionaryFactoryObject dictionaryFactory = new DictionaryFactoryObject();
            dictionaryFactory.SourceDictionary = new Hashtable();
            dictionaryFactory.AfterPropertiesSet();
            Assert.IsTrue(dictionaryFactory.GetObject() is Hashtable);
        }
        public void SetTargetListTypeToNonListType()
        {
            ListFactoryObject lfo = new ListFactoryObject();

            lfo.TargetListType = typeof(ICollection);
        }