Пример #1
0
        public void GetCurrentBalanceTest()
        {
            var testJObject = new JObject()
            {
                new JProperty("statusCode", "0"),
                new JProperty("message", "Success"),
                new JProperty("accountDetail", new JObject()
                {
                    new JProperty("currentBalance", "123")
                })
            };

            var messageHandler = new FakeHttpMessageHandler(new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(JsonConvert.SerializeObject(testJObject), Encoding.UTF8, "application/json")
            });

            var mockServiceClient   = new MockServiceClient(messageHandler);
            var mockGraphService    = new MockGraphService();
            var mockB2CGraphService = new MockB2CGraphService();
            var serviceId           = new ServiceId(mockGraphService, mockB2CGraphService, _mockServiceClientServiceId);

            var accountDetails = new AccountDetails(serviceId, mockServiceClient);
            var input          = new JObject()
            {
                new JProperty("token", "123"),
                new JProperty("serviceUrl", ServiceUrl.Url)
            };
            var expectedOutput = new JObject()
            {
                new JProperty("statusCode", "0"),
                new JProperty("message", "Success"),
                new JProperty("currentBalance", "123")
            };

            var response    = accountDetails.GetCurrentBalance(input);
            var responseObj = JObject.Parse(response);

            foreach (var item in responseObj)
            {
                Assert.True(expectedOutput.ContainsKey(item.Key));
                var value = expectedOutput.GetValue(item.Key);
                Assert.Equal(value, item.Value);
            }
        }