Exemplo n.º 1
0
        public void Multiply_Integers_ReturnsMultiplication(int start, int by, int expectedResult)
        {
            ISimpleCalculator calc = generateCalculator();
            int result             = calc.Multiply(start, by);

            Assert.AreEqual(expectedResult, result);
        }
Exemplo n.º 2
0
        public void Divide_Integers_ReturnsDivision(int start, int by, int expectedResult)
        {
            ISimpleCalculator calc = generateCalculator();
            int result             = calc.Divide(start, by);

            Assert.AreEqual(expectedResult, result);
        }
Exemplo n.º 3
0
        public void Subtract_Integers_ReturnsSubtraction(int start, int amount, int expectedResult)
        {
            ISimpleCalculator calc = generateCalculator();
            int result             = calc.Subtract(start, amount);

            Assert.AreEqual(expectedResult, result);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            var builder = new ContainerBuilder();

            //builder.RegisterType<DiagnosticConsole>().As<IDiagnostic>(); //Outputs to Console
            //builder.RegisterType<NullDiagnostic>().As<IDiagnostic>();      //Null, does not output at all
            //builder.RegisterType<DiagnosticEF>().As<IDiagnostic>();
            builder.RegisterType <DiagnosticSP>().As <IDiagnostic>();

            //builder.RegisterType<SimpleCalculator>().As<ISimpleCalculator>();
            builder.RegisterType <HttpCalculator>().As <ISimpleCalculator>();

            var container          = builder.Build();
            ISimpleCalculator calc = container.Resolve <ISimpleCalculator>();//new SimpleCalculator();

            string           operation;
            Tuple <int, int> numbers;
            int result;
            var validInputs = new List <string> {
                "a", "s", "m", "d"
            };

            while (true)
            {
                Console.WriteLine($"\nPlease select an operation: Add (a), Subtract (s), Multiply (m), Divide (d)" +
                                  $"\nTo exit type \"exit\"");
                operation = Console.ReadLine();

                if (operation == "exit")
                {
                    break;
                }

                if (validSelection(operation, validInputs))
                {
                    Console.WriteLine("\nPlease enter two numbers seperated by a comma (ex. 5,6):");
                    numbers = processNumbers(Console.ReadLine());
                    try
                    {
                        result = processOperation(operation, numbers, calc);
                        Console.WriteLine($"\nThe result of {numbers.Item1} {operation} {numbers.Item2} is {result}");
                    }
                    catch (HttpRequestException e)
                    {
                        Console.WriteLine(e.Message);
                    }
                }
                else
                {
                    Console.WriteLine("That is not a valid input\n");
                }
            }
        }
Exemplo n.º 5
0
Arquivo: Program.cs Projeto: Piusn/hol
        static void Main(string[] args)
        {
            #region CSharpCalculatorComponent
            ICSharpCalculatorComponentCalculator cSharpCalculatorComponentCalculator = (ICSharpCalculatorComponentCalculator) new CSharpCalculatorComponentCalculator();
            int result = cSharpCalculatorComponentCalculator.Sub(9, 8);
            #endregion

            //Using COM interop
            ISimpleCalculator a = (ISimpleCalculator) new Calculator();
            var interopresult   = a.Add(4, 66);

            ATLSimpleCalculatorComponentLib.ISimpleCalculator calc = new ATLSimpleCalculatorComponentLib.Calculator();
            result = calc.Add(4, 6);

            Console.WriteLine(result);
        }
Exemplo n.º 6
0
 public TaxCalculator(ISimpleCalculator calc)
 {
     _calc = calc;
 }
 public void Setup()
 {
     Calculator = new SimpleCalculator();
     MockLogger = new Mock <ILogger>(MockBehavior.Strict);
 }
Exemplo n.º 8
0
 public CalculatorService(ISimpleCalculator simpleCalculator)
 {
     _simpleCalculator = simpleCalculator;
 }
Exemplo n.º 9
0
 public CalculatorController(ILogger <CalculatorController> logger, ISimpleCalculator calculator)
 {
     _logger     = logger;
     _calculator = calculator;
 }
 /// <summary>
 /// Get SimpleCalculator from IoC container
 /// </summary>
 /// <param name="simplecalculator"></param>
 public SimpleCalculatorController(ISimpleCalculator simplecalculator)
 {
     _calculator = simplecalculator;
 }
 public void InitializeCalculator() 
 {
     calculator = new SimpleCalculator();
 }
Exemplo n.º 12
0
 public Service1(ISimpleCalculator calculator)
 {
     this.calc = calculator;
 }
Exemplo n.º 13
0
 //default CTOR
 public Service1()
 {
     this.calc = new SimpleCalculator();
 }
Exemplo n.º 14
0
 public SimpleCalculatorMock(ISimpleCalculator simpleCalculator)
 {
     _simpleCalculator = simpleCalculator;
 }
Exemplo n.º 15
0
        public void Divide_DivideByZero_DivideByZeroException(int start, int by)
        {
            ISimpleCalculator calc = generateCalculator();

            Assert.Throws <DivideByZeroException>(() => calc.Divide(5, 0));
        }
 public ShippingCalculator(ISimpleCalculator calculator)
 {
     _calculator = calculator;
 }
Exemplo n.º 17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CalculatorController" /> class.
 /// </summary>
 /// <param name="contribution"></param>
 public CalculatorController(ISimpleCalculator iCalculator)
 {
     _iCalculator = iCalculator;
 }
Exemplo n.º 18
0
 public ShippingCalculator(ISimpleCalculator calculator)
 {
     _calculator = calculator;
 }
Exemplo n.º 19
0
        private static int processOperation(string operation, Tuple <int, int> numbers, ISimpleCalculator calc)
        {
            switch (operation)
            {
            case "a":
                return(calc.Add(numbers.Item1, numbers.Item2));

            case "s":
                return(calc.Subtract(numbers.Item1, numbers.Item2));

            case "m":
                return(calc.Multiply(numbers.Item1, numbers.Item2));

            case "d":
                return(calc.Divide(numbers.Item1, numbers.Item2));

            default:
                return(0);
            }
        }
Exemplo n.º 20
0
 public Form1()
 {
     InitializeComponent();
     currentNumber = string.Empty;
     calc          = new SimpleCalculator();
 }
Exemplo n.º 21
0
 public TaxCalculator(ISimpleCalculator calc)
 {
     _calc = calc;
 }