예제 #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!");
        }
예제 #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!");
        }
예제 #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!");
        }
예제 #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!");
        }
예제 #5
0
 public BronzeCard(IPrintOutput printOutput, double turnover) : base(printOutput, turnover)
 {
 }
예제 #6
0
 public Card(IPrintOutput printOutput, double turnover)
 {
     this.Turnover    = turnover;
     this.PrintOutput = printOutput;
 }
예제 #7
0
 public GoldCard(IPrintOutput printOutput, double turnover) : base(printOutput, turnover)
 {
     this.DiscountRate = 2;
 }
예제 #8
0
 public SilverCard(IPrintOutput printOutput, double turnover) : base(printOutput, turnover)
 {
 }