public void TC1_Divide9by0() { IUSD_CLP_ExchangeRateFeed feed = this.prvActualUSDValue(); ICalculator calc1 = new calc(feed); Assert.That(() => calc1.Divide(9, 0), Throws.TypeOf <DivideByZeroException>()); }
public void TC1_Divide9by3() { IUSD_CLP_ExchangeRateFeed feed = this.prvActualUSDValue(); ICalculator calc1 = new calc(feed); int res = calc1.Divide(9, 3); Assert.AreEqual(3, res); }
public void TC3_ConvertUSDtoCLPTest() { IUSD_CLP_ExchangeRateFeed feed = this.prvGetMockExchangeRateFeed(); ICalculator calculator = new Calculator(feed); int actualResult = calculator.ConvertUSDtoCLP(1); int expectedResult = 500; Assert.AreEqual(expectedResult, actualResult); }
public void TC1_Divide9By3() { IUSD_CLP_ExchangeRateFeed feed = this.prvGetMockExchangeRateFeed(); ICalculator calculator = new Calculator(feed); int actualResult = calculator.Divide(9, 3); int expectedResult = 3; Assert.AreEqual(expectedResult, actualResult); }
//[ExpectedException(typeof(System.DivideByZeroException))] public void TC2_DivideByZero() { IUSD_CLP_ExchangeRateFeed feed = this.prvGetMockExchangeRateFeed(); ICalculator calculator = new Calculator(feed); //int actualResult = calculator.Divide(9, 0); //int actualResult = Assert.Throws <DivideByZeroException>(() => calculator.Divide(9, 0)); }
public void TC3_ConvertUSDtoCLPTest() { IUSD_CLP_ExchangeRateFeed feed = this.prvGetMockExchangeRateFeed(); ICalculator calculator = new Calculator(feed); int actualResult = calculator.ConvertUSDtoCLP(1); int expectedResult = 500; Assert.AreEqual(expectedResult, actualResult); //https://www.codeproject.com/Articles/796014/KickStart-your-Unit-Testing-using-Moq //To verify that a method was called, use the Verify method on the mock object; //mockCustomerRepository.Verify(t => t.Add(It.IsAny<Customer>())); }
public Calculator(IUSD_CLP_ExchangeRateFeed feed) { this._feed = feed; }
public void TC2_DivideByZero() { IUSD_CLP_ExchangeRateFeed feed = this.prvGetMockExchangeRateFeed(); ICalculator calculator = new Calculator(feed); int actualResult = calculator.Divide(9, 0); }
public calc(IUSD_CLP_ExchangeRateFeed feed) { //constructor this._feed = feed; }