public void ToStringTest()
        {
            var values   = HeaderValuesWithQualityCollection.Parse("application/xhtml+xml;q=0.999,text/html;q=1,application/xml;q=0.9,*/*;q=0.3,application/json;q=0.9");
            var newValue = values.ToString();

            Assert.That(newValue, Is.EqualTo("text/html,application/xhtml+xml;q=0.999,application/xml;q=0.9,application/json;q=0.9,*/*;q=0.3"));
        }
        public void AddTest()
        {
            var values = new HeaderValuesWithQualityCollection {
                "value1", { "value1", 0.999m }, "value2", "value2"
            };

            Assert.That(values.Count, Is.EqualTo(4));
        }
        public void IndexerTest()
        {
            var values = new HeaderValuesWithQualityCollection {
                "value1", { "value1", 0.999m }, "value2", "value2", { "value1", 0.998m }
            };

            Assert.That(values.Count, Is.EqualTo(5));
            Assert.That(values[0], Is.EqualTo(values.FirstOrDefault()));
            Assert.That(values[values.Count - 1], Is.EqualTo(values.LastOrDefault()));
        }
        public void ClearTest()
        {
            var values = new HeaderValuesWithQualityCollection {
                { "value1", 0.1m }
            };

            Assert.That(values, Is.Not.Empty);

            values.Clear();
            Assert.That(values, Is.Empty);
        }
        public void ParseTest()
        {
            var values = HeaderValuesWithQualityCollection.Parse("application/xhtml+xml;q=0.999,text/html,application/xml;q=0.9,*/*;q=0.3,application/json;q=0.9");

            Assert.That(values, Is.Not.Null);
            Assert.That(values.Count, Is.EqualTo(5));
            Assert.That(values.FirstOrDefault().Value, Is.EqualTo("text/html"));
            Assert.That(values.LastOrDefault().Value, Is.EqualTo("*/*"));

            values = HeaderValuesWithQualityCollection.Parse("");
            Assert.That(values, Is.Not.Null);
            Assert.That(values, Is.Empty);
        }
        public void RemoveTest()
        {
            var values = new HeaderValuesWithQualityCollection {
                "value1", { "Value1", 0.999m }, "value2", "vAlue2", { "valUe1", 0.998m }
            };

            Assert.That(values.Count, Is.EqualTo(5));

            values.Remove("value2");
            Assert.That(values.Count, Is.EqualTo(3));

            values.Remove(new HeaderValueWithQuality("value1", 0.999m));
            Assert.That(values.Count, Is.EqualTo(2));

            values.Remove("value1", 0.998m);
            Assert.That(values.Count, Is.EqualTo(1));
            Assert.That(values.FirstOrDefault(), Is.EqualTo(new HeaderValueWithQuality("value1")));
        }
 public void FormatExceptionTest(string value)
 {
     Assert.That(() => HeaderValuesWithQualityCollection.Parse(value), Throws.InstanceOf <FormatException>());
 }