Exemple #1
0
        public void SeeConsoleDump()
        {
            Conout.NewLine();
            Conout.Write("A"); Conout.Write("B");
            Conout.WriteLine();
            Conout.WriteLine("This is on another line");
            "This is on another line".In("general_info").WriteLine();


            "Message without parameters".See();
            "Message with parameter {0}".SeeArgs(1);
            "".SeeArgs(1, 2, 3, 4, 5);

            new { x = 10 }.In("objects").See();
            new { x = 10 }.In("objects").See("Header is shown in 'objects'");
            "Name is: {0}".In("people").SeeArgs("Jack");

            new { a = 1, b = 2 }.See();
            new { a = 1, b = 2 }.See("With header");
            new [] { 1, 2, 3 }.See();
            "Info text".Info();
            "Info text line".Info(5);

            "Warning text".Warning();
            "Warning text line".Warning(5);

            "Error text".Error();
            "Error text line".Error(5);
        }
Exemple #2
0
        public void InvalidBoundaryFromOutside()
        {
            var test = Encoding.UTF8.GetBytes(
                @"--7de23d3b1d07fe
Content-Disposition: form-data; name=""name1""

value 1
--7de23d3b1d07fe
Content-Disposition: form-data; name=""name2""

value 2
--7de23d3b1d07fe--
");
            string boundary = "8asd56sge";

            try
            {
                var mp = Multipart.ReadFromBytes(test, ref boundary);
                Aver.Fail("Invalid explicit boundary");
            }
            catch (Exception ex)
            {
                Conout.Write(ex.ToMessageWithType());
                Aver.IsTrue(ex.Message.Contains(StringConsts.MULTIPART_SPECIFIED_BOUNDARY_ISNT_FOUND_ERROR));
            }
        }
Exemple #3
0
        public void InvalidEOF()
        {
            var test = Encoding.UTF8.GetBytes(
                @"-----------------------------7de23d3b1d07fe
Content-Disposition: form-data; name=""field1""

value 1
-----------------------------7de23d3b1d07fe
Content-Disposition: form-data; name=""field2""

value 2--
");
            string boundary = null;

            try
            {
                var mp = Multipart.ReadFromBytes(test, ref boundary);
                Aver.Fail("Invalid EOF!");
            }
            catch (Exception e)
            {
                Conout.Write(e.ToMessageWithType());
                Aver.IsTrue(e.Message.Contains(StringConsts.MULTIPART_TERMINATOR_ISNT_FOUND_ERROR));
            }
        }
Exemple #4
0
        public void DuplicatedNames()
        {
            var test = Encoding.UTF8.GetBytes(
                @"-----------------------------7de23d3b1d07fe
Content-Disposition: form-data; name=""name""

value 1
-----------------------------7de23d3b1d07fe
Content-Disposition: form-data; name=""name""

value 2
-----------------------------7de23d3b1d07fe--
");
            string boundary = null;

            try
            {
                var mp = Multipart.ReadFromBytes(test, ref boundary);
                Aver.Fail("Repeated name!");
            }
            catch (Exception e)
            {
                Conout.Write(e.ToMessageWithType());
                Aver.IsTrue(e.Message.Contains("is already registered."));
            }
        }
Exemple #5
0
 public void TryCreateMultipart_NullParts()
 {
     try
     {
         var part = new Multipart(null);
         Aver.Fail("Invalid parts!");
     }
     catch (Exception e)
     {
         Conout.Write(e.ToMessageWithType());
         Aver.IsTrue(e.Message.Contains(StringConsts.MULTIPART_PARTS_COULDNT_BE_EMPTY_ERROR));
     }
 }
Exemple #6
0
 public void TryCreatePart_NullName()
 {
     try
     {
         var part = new Multipart.Part(null);
         Aver.Fail("Invalid name!");
     }
     catch (Exception e)
     {
         Conout.Write(e.ToMessageWithType());
         Aver.IsTrue(e.Message.Contains(StringConsts.MULTIPART_PART_EMPTY_NAME_ERROR));
     }
 }
Exemple #7
0
        public void EmptyPart()
        {
            var test = Encoding.UTF8.GetBytes(
                @"-----------------------------7de23d3b1d07fe
-----------------------------7de23d3b1d07fe--
");
            string boundary = null;

            try
            {
                var mp = Multipart.ReadFromBytes(test, ref boundary);
                Aver.Fail("Empty part!");
            }
            catch (Exception e)
            {
                Conout.Write(e.ToMessageWithType());
                Aver.IsTrue(e.Message.Contains(StringConsts.MULTIPART_PART_COULDNT_BE_EMPTY_ERROR));
            }
        }
Exemple #8
0
        public void NoDoubleEOLAfterHeader()
        {
            var test = Encoding.UTF8.GetBytes(
                @"-----------------------------7de23d3b1d07fe
Content-Disposition: form-data; name=""name""
value
-----------------------------7de23d3b1d07fe--
");
            string boundary = null;

            try
            {
                var mp = Multipart.ReadFromBytes(test, ref boundary);
                Aver.Fail("No double EOL after header!");
            }
            catch (Exception e)
            {
                Conout.Write(e.ToMessageWithType());
                Aver.IsTrue(e.Message.Contains(StringConsts.MULTIPART_DOUBLE_EOL_ISNT_FOUND_AFTER_HEADER_ERROR));
            }
        }
Exemple #9
0
        public void InvalidEOL()
        {
            var test = Encoding.UTF8.GetBytes(
                @"-----------------------------7de23d3b1d07fe
Content-Disposition: form-data; name=""name""

value-----------------------------7de23d3b1d07fe--
");
            string boundary = null;

            try
            {
                var mp = Multipart.ReadFromBytes(test, ref boundary);
                Aver.Fail("Invalid end of part!");
            }
            catch (Exception e)
            {
                Conout.Write(e.ToMessageWithType());
                Aver.IsTrue(e.Message.Contains(StringConsts.MULTIPART_PART_MUST_BE_ENDED_WITH_EOL_ERROR));
            }
        }
Exemple #10
0
        public void FullBoundaryNotStartWithHyphens()
        {
            var test = Encoding.UTF8.GetBytes(
                @"7de23d3b1d07fe
Content-Disposition: form-data; name=""name""

value 1
7de23d3b1d07fe--
");
            string boundary = null;

            try
            {
                var mp = Multipart.ReadFromBytes(test, ref boundary);
                Aver.Fail("Invalid boundary");
            }
            catch (Exception e)
            {
                Conout.Write(e.ToMessageWithType());
                Aver.IsTrue(e.Message.Contains(StringConsts.MULTIPART_BOUNDARY_SHOULD_START_WITH_HYPHENS));
            }
        }
Exemple #11
0
        public void TooShortBoundary()
        {
            var test = Encoding.UTF8.GetBytes(
                @"--
Content-Disposition: form-data; name=""name""

value 1
----
");
            string boundary = null;

            try
            {
                var mp = Multipart.ReadFromBytes(test, ref boundary);
                Aver.Fail("Invalid boundary");
            }
            catch (Exception e)
            {
                Conout.Write(e.ToMessageWithType());
                Aver.IsTrue(e.Message.Contains(StringConsts.MULTIPART_BOUNDARY_IS_TOO_SHORT));
            }
        }
Exemple #12
0
        public void EmptyName()
        {
            var test = Encoding.UTF8.GetBytes(
                @"-----------------------------7de23d3b1d07fe
Content-Disposition: form-data; name=""""

value
-----------------------------7de23d3b1d07fe--
");
            string boundary = null;

            try
            {
                var mp = Multipart.ReadFromBytes(test, ref boundary);
                Aver.Fail("Empty name!");
            }
            catch (Exception e)
            {
                Conout.Write(e.ToMessageWithType());
                Aver.IsTrue(e.Message.Contains(StringConsts.MULTIPART_PART_EMPTY_NAME_ERROR));
            }
        }