Пример #1
0
        public void DepositCatchesUnexpectedResponse()
        {
            // Arrange
            string   responseMessage      = "!@#$%^&*() -- not a valid json message, that will cause an exception -- !@#$%^&*()";
            var      httpMock             = Mocks.GetMockedHttp(HttpStatusCode.InternalServerError, responseMessage);
            MGClient client               = Mocks.GetMockedMGClient(httpClient: httpMock);
            var      DepositRequest       = Mocks.GetFullDepositRequest();
            string   expectedErrorMessage = "Unexpected character encountered while parsing value: !. Path '', line 0, position 0.: \n" +
                                            "Raw Response: !@#$%^&*() -- not a valid json message, that will cause an exception -- !@#$%^&*()";

            // Act
            MGDepositResult actual = client.InitDeposit(DepositRequest).Result;

            // Assert
            Assert.IsFalse(actual.IsSuccess);
            Assert.AreEqual(expectedErrorMessage, actual.Message);
        }
Пример #2
0
        public void DepositUnsuccessful()
        {
            // Arrange
            MGDepositResult expectedResult = new MGDepositResult()
            {
                IsSuccess = false,
                Code      = "400",
                Message   = "endpoint currency mismatch",
                Data      = null,
            };
            string   responseMessage = "{ \"code\": \"400\", \"message\": \"endpoint currency mismatch\" } ";
            var      httpMock        = Mocks.GetMockedHttp(HttpStatusCode.BadRequest, responseMessage);
            MGClient client          = Mocks.GetMockedMGClient(httpClient: httpMock);
            var      DepositRequest  = Mocks.GetFullDepositRequest();

            // Act
            MGDepositResult actual = client.InitDeposit(DepositRequest).Result;

            // Assert
            Assert.IsFalse(actual.IsSuccess);
            Assert.AreEqual(expectedResult.Data, actual.Data);
            Assert.AreEqual(expectedResult.Code, actual.Code);
            Assert.AreEqual(expectedResult.Message, actual.Message);
        }