コード例 #1
0
        public void IsArray()
        {
            var ins1 = new string[] { "Vito", "AzulX", "guodf", "wxn401", "myFirstway" };
            var ins2 = new int[] { 1, 3, 5, 2, 4, 6 };
            var ins3 = new float[][] {
                new float[] { 1.2F, 1.2F, 1.3F, 1.4F },
                new float[] { 2.2F, 2.2F, 2.3F, 2.4F }
            };
            var ins4 = new decimal[3, 2, 4] {
                {
                    { 1M, 2M, 3M, 4M },
                    { 5M, 6M, 7M, 8M }
                },
                {
                    { 1M, 2M, 3M, 4M },
                    { 5M, 6M, 7M, 8M }
                },
                {
                    { 1M, 2M, 3M, 4M },
                    { 5M, 6M, 7M, 8M }
                }
            };

            var arrayTemp = new CloneArrayTemplate();

            Assert.True(arrayTemp.MatchType(ins1.GetType()));
            Assert.True(arrayTemp.MatchType(ins2.GetType()));
            Assert.True(arrayTemp.MatchType(ins3.GetType()));
            Assert.True(arrayTemp.MatchType(ins4.GetType()));
        }
コード例 #2
0
        public void NotArray()
        {
            var ins0 = new { Name = "Vito", Age = 17 };
            var ins1 = 1;
            var ins2 = 1L;
            var ins3 = "string";
            var ins4 = 1.3D;
            var ins5 = 1.4M;
            var ins6 = GenderEnum.Secrecy;
            var ins7 = new List <string>()
            {
                "Vito", "AzulX", "guodf", "wxn401", "myFirstway"
            };
            var ins8 = new List <int>()
            {
                1, 3, 5, 2, 4, 6
            };
            var ins9 = new List <int[, ]>()
            {
                new int[, ] {
                    { 1, 2 }, { 2, 3 }
                },
                new int[, ] {
                    { 1, 2 }, { 2, 3 }, { 2, 3 }
                },
                new int[, ] {
                    { 1, 2, 3 }, { 3, 4, 5 }
                }
            };
            var ins10 = new ArrayList()
            {
                "Vito", "AzulX", "guodf", "wxn401", "myFirstway", 1, 3, 5, 2, 4, 6, new { Name = "Vito", Age = 17 }
            };
            var ins11 = new Dictionary <string, string>()
            {
                { "Key1", "Value1" },
                { "Key2", "Value2" }
            };

            var arrayTemp = new CloneArrayTemplate();

            Assert.False(arrayTemp.MatchType(ins0.GetType()));
            Assert.False(arrayTemp.MatchType(ins1.GetType()));
            Assert.False(arrayTemp.MatchType(ins2.GetType()));
            Assert.False(arrayTemp.MatchType(ins3.GetType()));
            Assert.False(arrayTemp.MatchType(ins4.GetType()));
            Assert.False(arrayTemp.MatchType(ins5.GetType()));
            Assert.False(arrayTemp.MatchType(ins6.GetType()));
            Assert.False(arrayTemp.MatchType(ins7.GetType()));
            Assert.False(arrayTemp.MatchType(ins8.GetType()));
            Assert.False(arrayTemp.MatchType(ins9.GetType()));
            Assert.False(arrayTemp.MatchType(ins10.GetType()));
            Assert.False(arrayTemp.MatchType(ins11.GetType()));
        }