コード例 #1
0
        public void GivenAnUriWithSpecialCharactersThenItIsEncoded()
        {
            EncodeUriCommand command = new EncodeUriCommand();

            // Given
            command.Input = "http://www.domaine.fr/une action?fichier=mon_fichier.txt";

            // When
            command.Execute();

            // Then
            Assert.AreEqual("http%3a%2f%2fwww.domaine.fr%2fune+action%3ffichier%3dmon_fichier.txt", command.Result);
        }
コード例 #2
0
        public void GivenAnUriWithoutSpecialCharactersThenItReturnsTheSameUri()
        {
            EncodeUriCommand command = new EncodeUriCommand();

            // Given
            command.Input = "www.domaine.fr";

            // When
            command.Execute();

            // Then
            Assert.AreEqual("www.domaine.fr", command.Result);
        }
コード例 #3
0
        public void GivenAnUriWithSpecialCharactersWhenEncodedAndUndoThenItReturnsTheSameUri()
        {
            const string expected = "http://www.domaine.fr/une action?fichier=mon_fichier.txt";

            EncodeUriCommand command = new EncodeUriCommand();

            // Given
            command.Input = expected;

            // When
            command.Execute();
            command.Undo();

            // Then
            Assert.AreEqual(expected, command.Result);
        }
コード例 #4
0
        public void GivenTwoHandledCommandsWhenUndoTwiceThenTheCommandsAreUndone()
        {
            const string expected1 = "chien chat";
            const string expected2 = "http://www.domaine.fr/une action?fichier=mon_fichier.txt";

            // Given
            SpaceToPipeCommand command1 = new SpaceToPipeCommand();
            command1.Input = expected1;
            EncodeUriCommand command2 = new EncodeUriCommand();
            command2.Input = expected2;

            CommandProcessor.Instance.Do(command1);
            CommandProcessor.Instance.Do(command2);

            // When
            CommandProcessor.Instance.Undo();
            CommandProcessor.Instance.Undo();

            // Then
            Assert.AreEqual(expected1, command1.Result);
            Assert.AreEqual(expected2, command2.Result);
        }
コード例 #5
0
        public void GivenTwoHandledCommandsWhenUndoTwiceAndRedoTwiceThenCommandsAreReExecuted()
        {
            const string expected1 = "chien chat";
            const string expected2 = "http://www.domaine.fr/une action?fichier=mon_fichier.txt";

            // Given
            SpaceToPipeCommand command1 = new SpaceToPipeCommand();
            command1.Input = expected1;
            EncodeUriCommand command2 = new EncodeUriCommand();
            command2.Input = expected2;

            CommandProcessor.Instance.Do(command1);
            CommandProcessor.Instance.Do(command2);

            // When
            CommandProcessor.Instance.Undo();
            CommandProcessor.Instance.Undo();
            CommandProcessor.Instance.Redo();
            CommandProcessor.Instance.Redo();

            // Then
            Assert.AreEqual("chien|chat", command1.Result);
            Assert.AreEqual("http%3a%2f%2fwww.domaine.fr%2fune+action%3ffichier%3dmon_fichier.txt", command2.Result);
        }