Ejemplo n.º 1
0
        public void FormatWithTags_80Characters_SingleLine()
        {
            var line     = Token.Create(80);
            var result   = Symmetric.FormatWithTags(line);
            var expected = new List <string>()
            {
                Symmetric.BEGIN_TAG,
                line,
                Symmetric.END_TAG
            };

            CollectionAssert.AreEqual(expected, result);
        }
Ejemplo n.º 2
0
        public void RemoveTags_RemoveLeadingTrailingNoise()
        {
            var line1 = Token.Create(20);
            var line2 = Token.Create(20);
            var line3 = Token.Create(20);
            var lines = new List <string>()
            {
                Token.Create(20), Symmetric.BEGIN_TAG, line1, line2, line3, Symmetric.END_TAG, Token.Create(20)
            };

            var result = Symmetric.RemoveTags(lines);

            Assert.AreEqual(string.Concat(line1, line2, line3), result);
        }
Ejemplo n.º 3
0
        public void RemoveTags_Joins()
        {
            var line1 = Token.Create(20);
            var line2 = Token.Create(20);
            var line3 = Token.Create(20);
            var lines = new List <string>()
            {
                Symmetric.BEGIN_TAG, line1, line2, line3, Symmetric.END_TAG
            };

            var result = Symmetric.RemoveTags(lines);

            Assert.AreEqual(string.Concat(line1, line2, line3), result);
        }
Ejemplo n.º 4
0
        private static bool _Run()
        {
            bool          result   = true;
            ICodeDocument document = CodeDocument.Create();
            ICodeLine     codeline = CodeLine.Create(document);

            document.AddBefore(codeline);

            result = result && (document.Cursor == codeline);

            IToken tokenFirst = Token.Create(Location.Create("filename", 0, 0, 10), "first", TokenKind.LiteralString);

            codeline.AddBefore(tokenFirst);  // codeline = [(first)]
            result = result && (codeline.Cursor == tokenFirst);
            IToken tokenAfter = Token.Create(Location.Create("filename", 0, 0, 10), "after", TokenKind.LiteralInteger);

            codeline.AddAfter(tokenAfter);                      // codeline = (first)[(after)]
            result = result && (codeline.Cursor == tokenAfter); // we set cursor to added item

            IToken tokenBefore = Token.Create(Location.Create("filename", 0, 0, 10), "before", TokenKind.LiteralFloat);

            codeline.AddBefore(tokenBefore); // codeline = (first)[(before)](after)
            result = result && (codeline.Cursor == tokenBefore);

            codeline.MoveCursorPrev(); // codeline = [(first)](before)(aft
            result = result && (codeline.Cursor == tokenFirst);
            codeline.MoveCursorNext(); // codeline - (first)[(before)](after)
            result = result && (codeline.Cursor == tokenBefore);
            codeline.MoveCursorNext(); // codeline = (first)(before)[(after)]
            result = result && (codeline.Cursor == tokenAfter);

            // now test saturation
            foreach (int i in F.range(0, 6))
            {
                codeline.MoveCursorPrev();
            }
            result = result && (codeline.Cursor == tokenFirst);
            foreach (int i in F.range(0, 6))
            {
                codeline.MoveCursorNext();
            }
            result = result && (codeline.Cursor == tokenAfter);
            return(result);
        }
Ejemplo n.º 5
0
 public void RemoveTags_EndTagOnly()
 {
     try
     {
         var line1 = Token.Create(20);
         var line2 = Token.Create(20);
         var line3 = Token.Create(20);
         var lines = new List <string>()
         {
             line1, line2, line3, Symmetric.END_TAG
         };
         var result = Symmetric.RemoveTags(lines);
     }
     catch (Exception ex)
     {
         Assert.AreEqual("Unexpected format", ex.Message);
         throw;
     }
 }
        public void Connect_Incorrect_ID()
        {
            var addAccount     = new Account(0, false, 0, "test_user1", Passhash.PasswordToPasshash("Str0ngPassw0rd123"), new EmailAddress("*****@*****.**"), Token.Create(), IPAddress.Any);
            var connectAccount = new Account(1, false, 0, "test_user1", Passhash.PasswordToPasshash("Str0ngPassw0rd123"), new EmailAddress("*****@*****.**"), Token.Create(), IPAddress.Any);
            var isThrowed      = false;

            try { Connect(addAccount, connectAccount); }
            catch { isThrowed = true; }
            Assert.IsTrue(isThrowed);
        }
        public void Connect_Correct()
        {
            var account = new Account(0, false, 0, "test_user1", Passhash.PasswordToPasshash("Str0ngPassw0rd123"), new EmailAddress("*****@*****.**"), Token.Create(), IPAddress.Any);

            Connect(account, account);
        }