示例#1
0
        public void TC1_Divide9by0()
        {
            IUSD_CLP_ExchangeRateFeed feed = this.prvActualUSDValue();
            ICalculator calc1 = new calc(feed);

            Assert.That(() => calc1.Divide(9, 0), Throws.TypeOf <DivideByZeroException>());
        }
示例#2
0
        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);
        }
示例#3
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);
        }
示例#4
0
        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);
        }
示例#5
0
        //[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));
        }
示例#6
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>()));
        }
示例#7
0
 public Calculator(IUSD_CLP_ExchangeRateFeed feed)
 {
     this._feed = feed;
 }
示例#8
0
 public void TC2_DivideByZero()
 {
     IUSD_CLP_ExchangeRateFeed feed = this.prvGetMockExchangeRateFeed();
     ICalculator calculator         = new Calculator(feed);
     int         actualResult       = calculator.Divide(9, 0);
 }
示例#9
0
 public calc(IUSD_CLP_ExchangeRateFeed feed)
 {          //constructor
     this._feed = feed;
 }