public void WhenConvertUSDoGBPUnitTimesRate() { //Arrange Calculator3 calc = new Calculator3(); var mockFeed = new Mock <ICurencyConverter3>(); mockFeed.Setup(x => x.GetGBPRate()).Returns(500); // Act int result = calc.ConvertUSDtoGBP(mockFeed.Object, 1); // Assert Assert.AreEqual(500, result); }
public void EvaluateTest() { // arrange string expresie = "1 ? 2"; CalculatorParser cp = new CalculatorParser(expresie); Operatie operatie = null; /// instructiune switch care foloseste type pattern /// valabil doar in C# v7.0 sau mai mare. switch (cp.Operatie) { case Add op: operatie = Operatii.Add; break; case Subtract op: operatie = Operatii.Subtract; break; case Multiply op: operatie = Operatii.Multiply; break; case Divide op: operatie = Operatii.Divide; break; default: break; } if (operatie == null) { return; } Calculator3 c3 = new Calculator3(cp.Op1, cp.Op2, operatie); // act c3.Evaluate(); int expected = -1; int actual = c3.Value; // assert Assert.AreEqual(expected, actual); }