Пример #1
0
        public void New_WithLeftDifferentFromRight_CreatesTheInstanceCorretly()
        {
            var base64Duo = new Base64Duo(1, new Base64("VGV4dCB0byBiZSBjb21wYXJlZA=="), new Base64("VGV4dCB0byBiZSBjb252ZXJ0ZWQ="));

            Assert.AreEqual(1, base64Duo.Id);
            Assert.AreEqual("VGV4dCB0byBiZSBjb21wYXJlZA==", base64Duo.Left.ToString());
            Assert.AreEqual("VGV4dCB0byBiZSBjb252ZXJ0ZWQ=", base64Duo.Right.ToString());
        }
Пример #2
0
        public void New_WithRightPassed_CreatesTheInstanceCorretly()
        {
            var base64Duo = new Base64Duo(1, null, new Base64("VGV4dCB0byBiZSBjb252ZXJ0ZWQ="));

            Assert.AreEqual(1, base64Duo.Id);
            Assert.AreEqual("VGV4dCB0byBiZSBjb252ZXJ0ZWQ=", base64Duo.Right.ToString());
            Assert.AreEqual("", base64Duo.Left.ToString());
        }
Пример #3
0
        public void UnderlyinStringsAreEqual_LeftAndRightHaveDifferentStringsWithSameLength_False()
        {
            var left  = new Base64("dGVzdCBzdHJpbmc="); //test string
            var right = new Base64("VGVTdCBTdFJpTmc="); //TeSt StRiNg

            var base64Duo = new Base64Duo(1, left, right);

            Assert.IsFalse(base64Duo.UnderlyingStringsAreEqual());
        }
Пример #4
0
        public void ChangeRightValue_WithANewValidBase64_ChangesTheValueCorrectly()
        {
            var base64Duo = new Base64Duo(1, new Base64("VGV4dCB0byBiZSBjb252ZXJ0ZWQ="), null);

            base64Duo.ChangeRightValue(new Base64("VGV4dCB0byBiZSBjb21wYXJlZA=="));

            Assert.AreEqual("VGV4dCB0byBiZSBjb252ZXJ0ZWQ=", base64Duo.Left.ToString());
            Assert.AreEqual("VGV4dCB0byBiZSBjb21wYXJlZA==", base64Duo.Right.ToString());
        }
Пример #5
0
        public void Diff_LeftHasValueAndRightDont_ThrowsException()
        {
            var    left  = new Base64("dGVzdCBzdHJpbmc="); //test string
            Base64 right = null;

            var base64Duo = new Base64Duo(1, left, right);

            var errors = base64Duo.Diff();
        }
Пример #6
0
        public void UnderlyingStringsHasSameLenth_LeftAndRightHaveDifferentStringsWithDifferentLengths_False()
        {
            var left  = new Base64("dGVzdCBzdHJpbmc=");
            var right = new Base64("VGV4dCB0byBiZSBjb21wYXJlZA==");

            var base64Duo = new Base64Duo(1, left, right);

            Assert.IsFalse(base64Duo.UnderlyingStringsHasSameLenth());
        }
Пример #7
0
        public void UnderlyingStringsHasSameLenth_RighttHasAValueAndLeftDont_Fase()
        {
            Base64 left  = null;
            var    right = new Base64("dGVzdCBzdHJpbmc="); //test string

            var base64Duo = new Base64Duo(1, left, right);

            Assert.IsFalse(base64Duo.UnderlyingStringsHasSameLenth());
        }
Пример #8
0
        public void Diff_TwoDifferentBase64InstanceWithDifferentUnderlyingString_RerturnsCorrectNumberOfErrors()
        {
            var left  = new Base64("dGVzdCBzdHJpbmc="); //test string
            var right = new Base64("VGVTdCBTdFJpTmc="); //TeSt StRiNg

            var base64Duo = new Base64Duo(1, left, right);

            var errors = base64Duo.Diff();

            Assert.AreEqual(5, errors.Count());
        }
Пример #9
0
        public void Diff_TwoDifferentBase64InstanceWithSameUnderlyingString_RerturnsZeroErrors()
        {
            var left  = new Base64("VGV4dCB0byBiZSBjb21wYXJlZA==");
            var right = new Base64("VGV4dCB0byBiZSBjb21wYXJlZA==");

            var base64Duo = new Base64Duo(1, left, right);

            var errors = base64Duo.Diff();

            Assert.AreEqual(0, errors.Count());
        }
Пример #10
0
        public object Right(int id, Base64Request data)
        {
            var duo = context.Base64Duo.FirstOrDefault(d => d.Id == id);

            if (duo == null)
            {
                duo = new Base64Duo(id, null, new Base64(data.Data));
                context.Base64Duo.Add(duo);
            }
            else
            {
                duo.ChangeRightValue(new Base64(data.Data));
            }

            context.SaveChanges();

            return(Ok());
        }
Пример #11
0
        public void UnderlyinStringsAreEqual_LeftAndRightHaveTheSameUnderlyingString_True()
        {
            var base64Duo = new Base64Duo(1, new Base64("VGV4dCB0byBiZSBjb252ZXJ0ZWQ="), new Base64("VGV4dCB0byBiZSBjb252ZXJ0ZWQ="));

            Assert.IsTrue(base64Duo.UnderlyingStringsAreEqual());
        }