public void CreateGiftCardValue() { const int valueToAdd = 1000; ICreateGiftCardValue createInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ICreateGiftCardValue>(); ILookupUserLoyalty loyaltyInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ILookupUserLoyalty>(); IDestroyGiftCardValue destroyInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IDestroyGiftCardValue>(); Loyalty initialLoyalty = loyaltyInterface.GetLoyalty(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken, LevelUpTestConfiguration.Current.MerchantId); var createdGiftCard = createInterface.GiftCardAddValue(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, LevelUpTestConfiguration.Current.MerchantId, LevelUpTestConfiguration.Current.MerchantLocationId, LevelUpTestConfiguration.Current.ConsumerQrData, valueToAdd); Assert.AreEqual(createdGiftCard.AmountAddedInCents, valueToAdd); Loyalty postAdditionLoyalty = loyaltyInterface.GetLoyalty(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken, LevelUpTestConfiguration.Current.MerchantId); Assert.AreEqual(postAdditionLoyalty.PotentialCreditAmount - initialLoyalty.PotentialCreditAmount, valueToAdd); // Cleanup destroyInterface.GiftCardDestroyValue(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, LevelUpTestConfiguration.Current.MerchantId, LevelUpTestConfiguration.Current.ConsumerQrData, valueToAdd); Loyalty postDestructionLoyalty = loyaltyInterface.GetLoyalty(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken, LevelUpTestConfiguration.Current.MerchantId); Assert.AreEqual(postDestructionLoyalty.PotentialCreditAmount, initialLoyalty.PotentialCreditAmount); }
public void GetLoyaltyShouldSucceed() { const int merchant_Id = 456; const int merchant_earn_amount = 500; const int merchant_spend_amount = 5000; const int orders_count = 77; const int potential_credit_amount = 7350; const int savings_amount = 835; const int spend_remaining_amount = 427; const int total_volume_amount = 6317; const int user_id = 789; const bool merchant_loyalty_enabled = true; const decimal progress_percentage = 42.0m; string expectedRequestUrl = string.Format("https://sandbox.thelevelup.com/v14/merchants/{0}/loyalty", merchant_Id); RestResponse expectedResponse = new RestResponse { StatusCode = HttpStatusCode.OK, Content = string.Format("{{" + "\"loyalty\":{{" + "\"merchant_earn_amount\":{0}," + "\"merchant_id\":{1}," + "\"merchant_loyalty_enabled\":{2}," + "\"merchant_spend_amount\":{3}," + "\"orders_count\":{4}," + "\"potential_credit_amount\":{5}," + "\"progress_percentage\":{6}," + "\"savings_amount\":{7}," + "\"spend_remaining_amount\":{8}," + "\"total_volume_amount\":{9}," + "\"user_id\":{10}" + "}}" + "}}", merchant_earn_amount, merchant_Id, merchant_loyalty_enabled ? "true" : "false", merchant_spend_amount, orders_count, potential_credit_amount, progress_percentage, savings_amount, spend_remaining_amount, total_volume_amount, user_id) }; ILookupUserLoyalty client = ClientModuleUnitTestingUtilities.GetMockedLevelUpModule <ILookupUserLoyalty>( expectedResponse, expectedRequestUrl: expectedRequestUrl); var loyalty = client.GetLoyalty("not_checking_this", merchant_Id); Assert.AreEqual(loyalty.MerchantEarnAmount, merchant_earn_amount); Assert.AreEqual(loyalty.MerchantId, merchant_Id); Assert.AreEqual(loyalty.MerchantLoyaltyEnabled, merchant_loyalty_enabled); Assert.AreEqual(loyalty.MerchantSpendAmount, merchant_spend_amount); Assert.AreEqual(loyalty.OrdersCount, orders_count); Assert.AreEqual(loyalty.PotentialCreditAmount, potential_credit_amount); Assert.AreEqual(loyalty.ProgressPercentage, progress_percentage); Assert.AreEqual(loyalty.SavingsAmount, savings_amount); Assert.AreEqual(loyalty.SpendRemainingAmount, spend_remaining_amount); Assert.AreEqual(loyalty.TotalVolumeAmount, total_volume_amount); Assert.AreEqual(loyalty.UserId, user_id); }
public void GetLoyaltyShouldFailForBadStatusCode() { const int merchant_Id = 456; string expectedRequestUrl = string.Format("https://sandbox.thelevelup.com/v14/merchants/{0}/loyalty", merchant_Id); RestResponse expectedResponse = new RestResponse { StatusCode = HttpStatusCode.NotFound, }; ILookupUserLoyalty client = ClientModuleUnitTestingUtilities.GetMockedLevelUpModule <ILookupUserLoyalty>( expectedResponse, expectedRequestUrl: expectedRequestUrl); client.GetLoyalty("not_checking_this", merchant_Id); }
public void GetLoyalty() { ClientModuleIntegrationTestingUtilities.RemoveAnyGiftCardCreditOnConsumerUserAccount(); ILookupUserLoyalty loyaltyClient = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ILookupUserLoyalty>(); var initialLoyalty = loyaltyClient.GetLoyalty(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken, LevelUpTestConfiguration.Current.MerchantId); Assert.AreEqual(initialLoyalty.MerchantId, LevelUpTestConfiguration.Current.MerchantId); ClientModuleIntegrationTestingUtilities.PlaceOrderAtTestMerchantWithTestConsumer(); var finalLoyalty = loyaltyClient.GetLoyalty(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken, LevelUpTestConfiguration.Current.MerchantId); Assert.AreEqual(finalLoyalty.OrdersCount, initialLoyalty.OrdersCount + 1); }
public void GetLoyaltyShouldFailForBadStatusCode() { const int merchant_Id = 456; string expectedRequestUrl = string.Format(ClientModuleFunctionalTestingUtilities.SANDBOX_URL_PREFIX + "/v14/merchants/{0}/loyalty", merchant_Id); RestResponse expectedResponse = new RestResponse { StatusCode = HttpStatusCode.NotFound, }; Assert.Throws <LevelUpApiException>( () => { ILookupUserLoyalty client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModule <ILookupUserLoyalty>( expectedResponse, expectedRequestUrl: expectedRequestUrl); client.GetLoyalty("not_checking_this", merchant_Id); }, "GetLoyalty failed to throw an exception for an invalid returned http status code."); }