コード例 #1
0
        public void ContainsExactlyThrowsExceptionWhenItemsAreMissing()
        {
            var heroes = new[] { "Luke", "Yoda", "Chewie" };

            Check.ThatCode(() =>
            {
                Check.That(heroes).ContainsExactly("Luke", "Yoda");
            })
            .Throws<FluentCheckException>()
            .WithMessage(Environment.NewLine+ "The checked enumerable does not contain exactly the expected value(s). There are extra items starting at index #2." + Environment.NewLine + "The checked enumerable:" + Environment.NewLine + "\t[\"Luke\", \"Yoda\", \"Chewie\"] (3 items)" + Environment.NewLine + "The expected value(s):" + Environment.NewLine + "\t[\"Luke\", \"Yoda\"] (2 items)");
        }
コード例 #2
0
        public void ContainsExactlyWithArraysThrowsExceptionWhenSameItemsInWrongOrder()
        {
            var integers = new[] { 1, 2, 3, 4, 5, 666 };

            Check.ThatCode(() =>
            {
                Check.That(integers).ContainsExactly(666, 3, 1, 2, 4, 5);
            })
            .Throws<FluentCheckException>()
            .WithMessage(Environment.NewLine+ "The checked enumerable does not contain exactly the expected value(s). First difference is at index #0." + Environment.NewLine + "The checked enumerable:" + Environment.NewLine + "\t[1, 2, 3, 4, 5, 666] (6 items)" + Environment.NewLine + "The expected value(s):" + Environment.NewLine + "\t[666, 3, 1, 2, 4, 5] (6 items)");

        }
コード例 #3
0
        public void ContainsExactlyWithArraysThrowsExceptionWithClearStatusWhenFails()
        {
            var integers = new[] { 1, 2, 3, 4, 5, 666 };

            Check.ThatCode(() =>
            {
                Check.That(integers).ContainsExactly(42, 42, 42);
            })
            .Throws<FluentCheckException>()
            .WithMessage(Environment.NewLine+ "The checked enumerable does not contain exactly the expected value(s). First difference is at index #0." + Environment.NewLine + "The checked enumerable:" + Environment.NewLine + "\t[1, 2, 3, 4, 5, 666] (6 items)" + Environment.NewLine + "The expected value(s):" + Environment.NewLine + "\t[42, 42, 42] (3 items)");

        }
コード例 #4
0
 public void ContainsExactlyWorksWithArrayOfStrings()
 {
     var guitarHeroes = new[] { "Hendrix", "Paco de Lucia", "Django Reinhardt", "Baden Powell" };
     Check.That(guitarHeroes).ContainsExactly("Hendrix", "Paco de Lucia", "Django Reinhardt", "Baden Powell");
 }
コード例 #5
0
 public void ContainsExactlyWorksWithArrayOfInt()
 {
     var integers = new[] { 1, 2, 3, 4, 5, 666 };
     Check.That(integers).ContainsExactly(1, 2, 3, 4, 5, 666);
 }
コード例 #6
0
        public void ContainsExactlyWithArraysThrowsExceptionWithClearStatusWhenFailsWithStrings()
        {
            var guitarHeroes = new[] { "Hendrix", "Paco de Lucia", "Django Reinhardt", "Baden Powell" };
            
            Check.ThatCode(() =>
            {
                Check.That(guitarHeroes).ContainsExactly("Hendrix, Paco de Lucia, Django Reinhardt, Baden Powell");
            })
            .Throws<FluentCheckException>()
            .WithMessage(Environment.NewLine+ "The checked enumerable does not contain exactly the expected value(s). First difference is at index #0." + Environment.NewLine + "The checked enumerable:" + Environment.NewLine + "\t[\"Hendrix\", \"Paco de Lucia\", \"Django Reinhardt\", \"Baden Powell\"] (4 items)" + Environment.NewLine + "The expected value(s):" + Environment.NewLine + "\t[\"Hendrix, Paco de Lucia, Django Reinhardt, Baden Powell\"] (1 item)");

        }