Ejemplo n.º 1
0
        public static void Ctor_IList()
        {
            var collection = new TestCollection <int>(s_intArray);

            Assert.Same(s_intArray, collection.GetItems());
            Assert.Equal(s_intArray.Length, collection.Count);
        }
Ejemplo n.º 2
0
        public static void GetItems_CastableToList()
        {
            //
            // Although MSDN only documents that Collection<T>.Items returns an IList<T>,
            // apps have made it through the Windows Store that successfully cast the return value
            // of Items to List<T>.
            //
            // Thus, we must grumble and continue to honor this behavior.
            //

            TestCollection <int> c  = new TestCollection <int>();
            IList <int>          il = c.GetItems();

            // Avoid using the List<T> type so that we don't have to depend on the System.Collections contract
            Type type = il.GetType();

            Assert.Equal(1, type.GenericTypeArguments.Length);
            Assert.Equal(typeof(int), type.GenericTypeArguments[0]);
            Assert.Equal("System.Collections.Generic.List`1", string.Format("{0}.{1}", type.Namespace, type.Name));
        }
Ejemplo n.º 3
0
    public static void CreateFromIList()
    {
        var collection = new TestCollection <int>(s_intArray);

        Assert.Same(s_intArray, collection.GetItems());
    }
Ejemplo n.º 4
0
        public static void Ctor_IList()
        {
            var collection = new TestCollection <int>(s_intSet);

            Assert.Same(s_intSet, collection.GetItems());
        }