public void Given_input_is_one_hundred_fizzbuzzCalculator_called_100_times() { //Given I have the number 100 int input = 100; //And I have a character seperqtor as , char seperator = ','; //And I have a fizzbuzzconverter object Mock <IFizzBuzzCalculator> mock = new Mock <IFizzBuzzCalculator>(); //When I call fizzbuzzflow.calculatefizzbuzz IFizzBuzzFlow fizzBuzzFlow = new FizzBuzzFlow(mock.Object); fizzBuzzFlow.CalculateFizzBuzz(input, seperator); //Then I will verify that fizzbuzzconverter object is called 100 times mock.Verify(m => m.Calculate(It.IsAny <int>()), Times.Exactly(100)); }
public void Given_input_is_one_fizz_buzz_calculator_is_called_once() { //Given I have the number 1 int input = 1; //And I have a fizzbuzzconverter object Mock <IFizzBuzzCalculator> mock = new Mock <IFizzBuzzCalculator>(); //And I have a seperator Object Mock <ISeparator> separator = new Mock <ISeparator>(); //When I call fizzbuzzflow.cwlculatefizzbuzz IFizzBuzzFlow fizzBuzzFlow = new FizzBuzzFlow(mock.Object, separator.Object); fizzBuzzFlow.CalculateFizzBuzz(input); //Then I will verify that fizzbuzzconverter object is caalled once mock.Verify(m => m.Calcuate(input), Times.Once); }
public void Given_input_is_hundred_fizz_buzz_calculator_is_called_hundred_times() { //Given I have the number 100 int input = 100; //And I have a fizzbuzzconverter object Mock <IFizzBuzzCalculator> mock = new Mock <IFizzBuzzCalculator>(); //And I have a seperator Object Mock <ISeparator> separator = new Mock <ISeparator>(); //When I call fizzbuzzflow.cwlculatefizzbuzz IFizzBuzzFlow fizzBuzzFlow = new FizzBuzzFlow(mock.Object, separator.Object); fizzBuzzFlow.CalculateFizzBuzz(input); //Then I will verify that fizzbuzzconverter object is called twice mock.Verify(m => m.Calcuate(It.IsAny <int>()), Times.Exactly(100)); }
public void Given_input_is_one_return_one() { //Given I have the number 1 int input = 1; //And I have a character seperqtor as , char seperator = ','; //And I have a fizzbuzzconverter object which returns 1 Mock <IFizzBuzzCalculator> mock = new Mock <IFizzBuzzCalculator>(); mock.Setup(fb => fb.Calculate(1)).Returns("1"); //When I call fizzbuzzflow.cwlculatefizzbuzz IFizzBuzzFlow fizzBuzzFlow = new FizzBuzzFlow(mock.Object); string result = fizzBuzzFlow.CalculateFizzBuzz(input, seperator); //Then I will get back 1 Assert.AreEqual("1", result); }
public void Given_input_is_two_return_two() { //Given I have the number 2 var input = 2; //And I have a fizzbuzzconverter object which returns 1 then 2 Mock <IFizzBuzzCalculator> mock = new Mock <IFizzBuzzCalculator>(); //And I have a seperator Object Mock <ISeparator> separator = new Mock <ISeparator>(); mock.Setup(fb => fb.Calcuate(1)).Returns("1"); mock.Setup(fb => fb.Calcuate(2)).Returns("2"); //When I call fizzbuzzflow.cwlculatefizzbuzz IFizzBuzzFlow fizzBuzzFlow = new FizzBuzzFlow(mock.Object, separator.Object); string result = fizzBuzzFlow.CalculateFizzBuzz(input); //Then I will get back 1,2 Assert.AreEqual("1,2", result); }