예제 #1
0
        public void GetMerchants_Success()
        {
            App createdApp = _appService.CreateApp(new CreateAppRequest()).Content;
            IPaylikeMerchantService merchantService = new PaylikeMerchantService(createdApp.Key);

            for (int i = 0; i < 5; i++)
            {
                _createMerchantRequest.Name = "TestMerchant_" + DateTime.Now.Ticks.ToString();
                merchantService.CreateMerchant(_createMerchantRequest);
            }

            ApiResponse <List <Merchant> > merchantsResponse = merchantService.GetMerchants(new GetMerchantsRequest()
            {
                AppId = createdApp.Id,
                Limit = 3
            });

            Assert.AreEqual(3, merchantsResponse.Content.Count);

            var beforeMerchants = merchantService.GetMerchants(new GetMerchantsRequest()
            {
                AppId  = createdApp.Id,
                Before = merchantsResponse.Content[2].Id,
                Limit  = 2
            });

            Assert.AreEqual(2, beforeMerchants.Content.Count);

            var afterMerchants = merchantService.GetMerchants(new GetMerchantsRequest()
            {
                AppId = createdApp.Id,
                After = merchantsResponse.Content[2].Id,
                Limit = 2
            });

            Assert.AreEqual(2, beforeMerchants.Content.Count);

            var firstMerchantsIds  = merchantsResponse.Content.Select(m => m.Id);
            var beforeMerchantsIds = beforeMerchants.Content.Select(m => m.Id);
            var afterMerchantsIds  = afterMerchants.Content.Select(m => m.Id);

            var beforeIntersection = firstMerchantsIds.Intersect(beforeMerchantsIds);
            var afterIntersection  = firstMerchantsIds.Intersect(afterMerchantsIds);

            Assert.AreEqual(0, beforeIntersection.Count());
            Assert.AreEqual(2, afterIntersection.Count());
        }
예제 #2
0
        public void GetMerchants_WithoutPagination_Fails()
        {
            App createdApp = _appService.CreateApp(new CreateAppRequest()).Content;
            IPaylikeMerchantService merchantService = new PaylikeMerchantService(createdApp.Key);

            ApiResponse <List <Merchant> > merchantsResponse = merchantService.GetMerchants(new GetMerchantsRequest()
            {
                AppId = createdApp.Id
            });

            Assert.IsTrue(merchantsResponse.IsError);
            Assert.IsNotNull(merchantsResponse.ErrorContent);
            Assert.AreEqual(400, merchantsResponse.ResponseCode);
        }