Esempio n. 1
0
        public void EqualsIsCaseInsensitiveForCharsets()
        {
            var m1 = new MimeType("text", "plain", SingletonMap("charset", "UTF-8"));
            var m2 = new MimeType("text", "plain", SingletonMap("charset", "utf-8"));

            Assert.Equal(m1, m2);
            Assert.Equal(m2, m1);
            Assert.Equal(0, m1.CompareTo(m2));
            Assert.Equal(0, m2.CompareTo(m1));
        }
Esempio n. 2
0
        public void CompareTo()
        {
            var audioBasic      = new MimeType("audio", "basic");
            var audio           = new MimeType("audio");
            var audioWave       = new MimeType("audio", "wave");
            var audioBasicLevel = new MimeType("audio", "basic", SingletonMap("level", "1"));

            // equal
            Assert.Equal(0, audioBasic.CompareTo(audioBasic));
            Assert.Equal(0, audio.CompareTo(audio));
            Assert.Equal(0, audioBasicLevel.CompareTo(audioBasicLevel));

            Assert.True(audioBasicLevel.CompareTo(audio) > 0);

            var expected = new List <MimeType>();

            expected.Add(audio);
            expected.Add(audioBasic);
            expected.Add(audioBasicLevel);
            expected.Add(audioWave);

            var result = new List <MimeType>(expected);
            var rnd    = new Random();

            // shuffle & sort 10 times
            for (var i = 0; i < 10; i++)
            {
                Shuffle(result, rnd);
                result.Sort();

                for (var j = 0; j < result.Count; j++)
                {
                    Assert.Same(expected[j], result[j]);
                }
            }
        }
Esempio n. 3
0
        public void CompareToCaseSensitivity()
        {
            var m1 = new MimeType("audio", "basic");
            var m2 = new MimeType("Audio", "Basic");

            Assert.Equal(0, m1.CompareTo(m2));
            Assert.Equal(0, m2.CompareTo(m1));

            m1 = new MimeType("audio", "basic", SingletonMap("foo", "bar"));
            m2 = new MimeType("audio", "basic", SingletonMap("Foo", "bar"));
            Assert.Equal(0, m1.CompareTo(m2));
            Assert.Equal(0, m2.CompareTo(m1));

            m1 = new MimeType("audio", "basic", SingletonMap("foo", "bar"));
            m2 = new MimeType("audio", "basic", SingletonMap("foo", "Bar"));
            Assert.True(m1.CompareTo(m2) != 0);
            Assert.True(m2.CompareTo(m1) != 0);
        }