Beispiel #1
0
        public void Build_FromValidToNull_ThrowsNullReferenceException()
        {
            // Set and encode from

            byte[] from_bytes = Encoding.UTF8.GetBytes("valid");
            byte[] to_bytes   = null;

            // Build the patch
            Patch  patch    = new Patch();
            Action patching = () => patch.Build(from_bytes, to_bytes);

            //assert
            Assert.Throws <NullReferenceException>(patching);
        }
Beispiel #2
0
        public void Build_FromNullToValid_ThrowsNullReferenceException()
        {
            // Set and encode from
            byte[] from_bytes = null;

            // Set and encode to
            string to       = "valid";
            var    to_bytes = Encoding.UTF8.GetBytes(to);

            // Build the patch
            Patch  patch    = new Patch();
            Action patching = () => patch.Build(from_bytes, to_bytes);

            //assert
            Assert.Throws <NullReferenceException>(patching);
        }
Beispiel #3
0
        public void Build_WeirdCase2()
        {
            // Set and encode from
            string from       = "joker";
            var    from_bytes = Encoding.UTF8.GetBytes(from);

            // Set and encode to
            string to       = "i";
            var    to_bytes = Encoding.UTF8.GetBytes(to);

            // Build the patch
            Patch patch = new Patch();

            patch.Build(from_bytes, to_bytes);

            // Apply the patch
            byte[] expectedPatched = to_bytes;
            byte[] actualPatched   = patch.Apply(from_bytes);

            // Test for equality
            Assert.Equal(expectedPatched, actualPatched);
        }