Exemplo n.º 1
0
        public void GetUserNumericalInputPrintsErrorMessageWhenInputIsOtherThanInteger()
        {
            // Arrange
            IGetInput    InputMock  = Substitute.For <IGetInput>();
            IPrintOutput OutputMock = Substitute.For <IPrintOutput>();

            // As the console stays in a loop if an invallid call is received, we are forcing a return with a second valid call
            InputMock.GetUserInput().Returns("h", "3");

            Target.Input  = InputMock;
            Target.Output = OutputMock;

            // Act
            var result = RunHelper.RunStaticMethod(typeof(CalcConsoleClient), "GetUserNumericalInput", null);

            // Assert
            OutputMock.Received().PrintUserOutput("Please Enter a valid numerical value!");
        }
Exemplo n.º 2
0
        public void GetUserOperationInputOnlyAcceptsValidOperations()
        {
            // Arrange
            IGetInput    InputMock  = Substitute.For <IGetInput>();
            IPrintOutput OutputMock = Substitute.For <IPrintOutput>();

            // As the console stays in a loop if an invallid call is received, we are forcing a return with a second valid call
            InputMock.GetUserInput().Returns("hello", "add");

            Target.Input  = InputMock;
            Target.Output = OutputMock;

            // Act
            var result = RunHelper.RunStaticMethod(typeof(CalcConsoleClient), "GetUserOperationInput", null);

            // Assert
            // Failed 4 times, one per invalid input
            OutputMock.Received(1);
            OutputMock.Received().PrintUserOutput("Please Enter a valid operation!");
        }
Exemplo n.º 3
0
        public void GetUserNumericalInputPrintsErrorIfIntIsOutOfRange()
        {
            // Arrange
            IGetInput    InputMock  = Substitute.For <IGetInput>();
            IPrintOutput OutputMock = Substitute.For <IPrintOutput>();

            // As the console stays in a loop if an invalid call is received, we are forcing a return with a second valid call
            InputMock.GetUserInput().Returns("2147483999", "4");

            Target.Input  = InputMock;
            Target.Output = OutputMock;

            // Act
            var result = RunHelper.RunStaticMethod(typeof(CalcConsoleClient), "GetUserNumericalInput", null);

            // Assert
            // Failed 4 times, one per invalid input
            OutputMock.Received(1);
            OutputMock.Received().PrintUserOutput("Please Enter a valid numerical value!");
        }
Exemplo n.º 4
0
        public void GetUserNumericalInputBlocksExecutionUntilValidValueIsFound()
        {
            // Arrange
            IGetInput    InputMock  = Substitute.For <IGetInput>();
            IPrintOutput OutputMock = Substitute.For <IPrintOutput>();

            // As the console stays in a loop if an invallid call is received, we are forcing a return with a second valid call
            InputMock.GetUserInput().Returns("a", "b", "c", "&", "3");

            Target.Input  = InputMock;
            Target.Output = OutputMock;

            // Act
            var result = RunHelper.RunStaticMethod(typeof(CalcConsoleClient), "GetUserNumericalInput", null);

            // Assert
            // Failed 4 times, one per invalid input
            OutputMock.Received(4);
            OutputMock.Received().PrintUserOutput("Please Enter a valid numerical value!");
        }
Exemplo n.º 5
0
 public BronzeCard(IPrintOutput printOutput, double turnover) : base(printOutput, turnover)
 {
 }
Exemplo n.º 6
0
 public Card(IPrintOutput printOutput, double turnover)
 {
     this.Turnover    = turnover;
     this.PrintOutput = printOutput;
 }
Exemplo n.º 7
0
 public GoldCard(IPrintOutput printOutput, double turnover) : base(printOutput, turnover)
 {
     this.DiscountRate = 2;
 }
Exemplo n.º 8
0
 public SilverCard(IPrintOutput printOutput, double turnover) : base(printOutput, turnover)
 {
 }