public void CalculateSum_Should_Return_Sum_of_Numbers_In_String() { string numbers = "1;2%3"; char[] delimiterArray = new char[] { ';', '%' }; int sum = sumCalculator.CalculateSum(numbers, delimiterArray); Assert.AreEqual(6, sum); }
static void Main(string[] args) { // create an object and upcast it to the combined interface ICombinedCalculator calc = new Calculator(); // upcast to the base interfaces and call the method that each defines IProductCalculator prodCalc = calc; int prodResult = prodCalc.CalculateProduct(10, 10); ISumCalculator sumCalc = calc; int calcResult = sumCalc.CalculateSum(10, 10); ISubtractionCalculator subCalc = calc; int subResult = subCalc.CalculateSubtraction(10, 2); // explicitly cast from one base interface to another prodCalc = (IProductCalculator)subCalc; // wait for input before exiting Console.WriteLine("Press enter to finish"); Console.ReadLine(); }