public FractionResponse Subtract(int numerator1, int denominator1, int numerator2, int denominator2)
        {
            FractionModel fraction1 = new FractionModel
            {
                Numerator = numerator1,
                Denominator = denominator1
            };

            FractionModel fraction2 = new FractionModel
            {
                Numerator = numerator2,
                Denominator = denominator2
            };

            FractionRequest fractionRequest = new FractionRequest
            {
                Fraction1 = fraction1,
                Fraction2 = fraction2
            };

            var request = new RestRequest("api/Fractions/Subtract", Method.POST) { RequestFormat = DataFormat.Json };
            request.AddBody(fractionRequest);

            var response = _client.Execute<FractionResponse>(request);

            if (response.StatusCode != HttpStatusCode.OK)
                throw new Exception(response.ErrorMessage);

            return response.Data;
        }
        public void SetUp()
        {
            _model = new FractionModel
            {
                Numerator = 3,
                Denominator = 7
            };

            _domain = new Fraction(5, 17);
        }
        public void ShouldSubtractTwoFractionsCallingFractionServiceWebApi()
        {
            FractionModel fraction = new FractionModel { Numerator = 1, Denominator = 6 };

            FractionResponse fractionResponse = new FractionResponse { Fraction = fraction };

            var response = new RestResponse<FractionResponse> { Data = fractionResponse, StatusCode = HttpStatusCode.OK };

            _restClient.Expect(
                rc =>
                    rc.Execute<FractionResponse>(
                        Arg<RestRequest>.Matches(
                            rr => rr.Method == Method.POST && rr.Resource.Equals("api/Fractions/Subtract"))))
                .Return(response);

            var result = _client.Subtract(1, 2, 1, 3);

            _restClient.VerifyAllExpectations();

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.Fraction.Numerator);
            Assert.AreEqual(6, result.Fraction.Denominator);
        }
 public static Fraction Map(FractionModel model)
 {
     return new Fraction(model.Numerator, model.Denominator);
 }
        public FractionResponse Power(int numerator, int denominator, int power)
        {
            FractionModel fraction = new FractionModel
            {
                Numerator = numerator,
                Denominator = denominator
            };

            FractionPowerRequest fractionRequest = new FractionPowerRequest
            {
                Fraction = fraction,
                Power = power
            };

            var request = new RestRequest("api/Fractions/Power", Method.POST) { RequestFormat = DataFormat.Json };
            request.AddBody(fractionRequest);

            var response = _client.Execute<FractionResponse>(request);

            if (response.StatusCode != HttpStatusCode.OK)
                throw new Exception(response.ErrorMessage);

            return response.Data;
        }