Exemplo n.º 1
0
        /// <summary>
        /// Creates mock test client
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        protected Client CreateMockTestClientRequest(string fileName)
        {
            var mockPath = GetMockFilePath(fileName);
            var response = MockFileToString(mockPath);
            //Create a mock interface
            var clientInterfaceMock = new Mock <IClient>();
            var confMock            = MockPaymentDataRequest.CreateConfingMock();

            clientInterfaceMock.Setup(x => x.Request(It.IsAny <string>(),
                                                     It.IsAny <string>(), confMock)).Returns(response);
            var clientMock = new Client(It.IsAny <Config>())
            {
                HttpClient = clientInterfaceMock.Object,
                Config     = confMock
            };

            return(clientMock);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates mock test client errors
        /// </summary>
        /// <param name="status"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        protected Client CreateMockTestClientForErrors(int status, string fileName)
        {
            var mockPath = GetMockFilePath(fileName);
            var response = MockFileToString(mockPath);
            //Create a mock interface
            var clientInterfaceMock = new Mock <IClient>();
            var confMock            = MockPaymentDataRequest.CreateConfingMock();
            var httpClientException = new HttpClientException(status, "An error occured", new Dictionary <string, List <string> >(), response);

            clientInterfaceMock.Setup(x => x.Request(It.IsAny <string>(),
                                                     It.IsAny <string>(), confMock)).Throws(httpClientException);

            var clientMock = new Client(It.IsAny <Config>())
            {
                HttpClient = clientInterfaceMock.Object,
                Config     = confMock
            };

            return(clientMock);
        }