Exemplo n.º 1
0
        public void RevokeAppFromMerchant_Success()
        {
            App createdApp = _appService.CreateApp(new CreateAppRequest()).Content;

            _appService.SetApiKey(createdApp.Key);

            IPaylikeMerchantService merchantService = new PaylikeMerchantService(createdApp.Key);
            Merchant merchant = merchantService.CreateMerchant(_createMerchantRequest).Content;

            AddAppToMerchantRequest addRequest = new AddAppToMerchantRequest()
            {
                MerchanId = merchant.Id,
                AppId     = createdApp.Id
            };

            merchantService.AddAppToMerchant(addRequest);
            var revokeResponse = merchantService.RevokeAppFromMerchant(new RevokeAppFromMerchantRequest()
            {
                MerchanId = merchant.Id,
                AppId     = createdApp.Id
            });

            Assert.IsNull(revokeResponse.Content);
            Assert.IsFalse(revokeResponse.IsError);
            Assert.AreEqual(204, revokeResponse.ResponseCode);
        }
Exemplo n.º 2
0
        public void GetMerchantApps_Success()
        {
            App createdApp = _appService.CreateApp(new CreateAppRequest()).Content;

            _appService.SetApiKey(createdApp.Key);

            IPaylikeMerchantService merchantService = new PaylikeMerchantService(createdApp.Key);
            Merchant merchant = merchantService.CreateMerchant(_createMerchantRequest).Content;

            for (int i = 0; i < 4; i++)
            {
                createdApp = _appService.CreateApp(new CreateAppRequest()).Content;
                merchantService.AddAppToMerchant(new AddAppToMerchantRequest()
                {
                    MerchantId = merchant.Id,
                    AppId      = createdApp.Id
                });
            }

            ApiResponse <List <App> > appsResponse = merchantService.GetMerchantApps(new GetMerchantAppsRequest()
            {
                MerchantId = merchant.Id,
                Limit      = 3
            });

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

            var beforeApps = merchantService.GetMerchantApps(new GetMerchantAppsRequest()
            {
                MerchantId = merchant.Id,
                Before     = appsResponse.Content[2].Id,
                Limit      = 2
            });

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

            var afterApps = merchantService.GetMerchantApps(new GetMerchantAppsRequest()
            {
                MerchantId = merchant.Id,
                After      = appsResponse.Content[2].Id,
                Limit      = 2
            });

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

            var firstAppsIds  = appsResponse.Content.Select(m => m.Id);
            var beforeAppsIds = beforeApps.Content.Select(m => m.Id);
            var afterAppsIds  = afterApps.Content.Select(m => m.Id);

            var beforeIntersection = firstAppsIds.Intersect(beforeAppsIds);
            var afterIntersection  = firstAppsIds.Intersect(afterAppsIds);

            Assert.AreEqual(0, beforeIntersection.Count());
            Assert.AreEqual(2, afterIntersection.Count());
        }