Пример #1
0
        public void ShouldNotInvokeAnyOperations()
        {
            //Arrange
            string input      = "Example string";
            var    operation1 = new Mock <ITransformable>();
            var    operation2 = new Mock <ITransformable>();

            var list = new List <ITransformable>
            {
                operation1.Object,
                operation2.Object
            };

            var operationManager = new Mock <IOperationsManagable>();

            operationManager.Setup(x => x.GetEnumerator()).Returns(list.GetEnumerator());

            var transformString = new TransformString(operationManager.Object);

            //Act
            transformString.TransfromString(input);

            //Assert
            operation1.Verify(x => x.HasOpeation(input));
            operation2.Verify(x => x.HasOpeation(input));

            operation1.Verify(x => x.Transform(input), Times.Never());
            operation2.Verify(x => x.Transform(input), Times.Never());
        }
Пример #2
0
        public void Initialize()
        {
            var operationManager = new OperationsManager();

            operationManager.RegisterOperation(new ReverseOperation());
            operationManager.RegisterOperation(new SortOperation());

            this.cut = new TransformString(operationManager);
        }
Пример #3
0
        public void ShouldThrowContainsAnyChar()
        {
            //Arrange
            IOperationsManagable manager = null;
            var cut = new TransformString(manager);

            //Act
            cut.TransfromString(null);
        }
Пример #4
0
        public void ShouldReturnsInput()
        {
            //Arrange
            IOperationsManagable manager = null;
            var          cut             = new TransformString(manager);
            const string input           = "This is the [expected (input)]";

            //Act
            var result = cut.TransfromString(input);

            //Assert
            Assert.AreEqual(input, result);
        }
Пример #5
0
        static void Main(string[] args)
        {
            var exmapleString = "Tests of [a ([(sample test1)] supplied)] by MeMFIS [Test1 Test2 (test3 test4)]";

            Console.WriteLine($"The input string before conversion:{exmapleString}");


            var operationManager = new OperationsManager();

            operationManager.RegisterOperation(new ReverseOperation());
            operationManager.RegisterOperation(new SortOperation());

            var test = new TransformString(operationManager);

            var result = test.TransfromString(exmapleString);

            Console.WriteLine($"The output string after conversion:{result}");
            Console.ReadLine();
        }
Пример #6
0
 /// <summary>
 /// Raises the <see cref="TransformString"/> event.
 /// </summary>
 /// <param name="args">The event arguments.</param>
 protected virtual void OnTransformString(TransformStringEventArgs args)
 => TransformString?.Invoke(this, args);
Пример #7
0
 /// <summary>
 ///     Allows transforming of strings
 ///
 ///     Note this handler is internal and not meant to be overridden
 ///     as the TransformString Event has to be hooked up in order
 ///     for this handler to even fire to avoid the overhead of string
 ///     conversion on every pass through.
 /// </summary>
 /// <param name="responseText"></param>
 /// <returns></returns>
 private string OnTransformCompleteString(string responseText)
 {
     TransformString?.Invoke(responseText);
     return(responseText);
 }