public void CanExecuteGetFromService_Add()
        {
            var service2PluginDefinition = new TestService2.Service2();

              var theRequest = new Service2Request() { Operation = "add", Num1 = 2, Num2 = 67 };

              var result = service2PluginDefinition.Get(theRequest);

              Assert.IsTrue(result.OperationResult.Equals(69));
        }
        public void CanExecuteGetFromService_Divide()
        {
            var service2PluginDefinition = new TestService2.Service2();

              var theRequest = new Service2Request() { Operation = "divide", Num1 = 9, Num2 = 3 };

              var result = service2PluginDefinition.Get(theRequest);

              Assert.IsTrue(result.OperationResult.Equals(3));
        }
        public void CanExecuteGetFromService_Exception()
        {
            var service2PluginDefinition = new TestService2.Service2();

              var theRequest = new Service2Request() { Operation = "exception_case", Num1 = 9, Num2 = 3 };

              var result = service2PluginDefinition.Get(theRequest);

              Assert.IsTrue(result.ResponseStatus.ErrorCode.Equals("-1"));
              Assert.IsTrue(result.OperationResult.Equals(0));
        }
        public Service2Response Get(Service2Request request)
        {
            var response = new Service2Response() { ResponseStatus = new ResponseStatus() };

              float operationResult = 0f;

              try
              {
            switch (request.Operation.ToLowerInvariant())
            {
              case "add":
            operationResult = request.Num1 + request.Num2;
            break;
              case "multiply":
            operationResult = request.Num1 * request.Num2;
            break;
              case "subtract":
            operationResult = request.Num1 - request.Num2;
            break;
              case "divide":
            operationResult = request.Num1 / request.Num2;
            break;
              default:
            throw new ArgumentException("No valid operation found for passed argument.");
            }

            response.OperationResult = operationResult;

              }
              catch (Exception ex)
              {
            response.ResponseStatus = new ResponseStatus("-1", ex.Message);
              }

              return response;
        }