private async Task <GetCardsInitResponse.Paycard> GetCard(string cardNumber) { GetCardsInitRequest request = new GetCardsInitRequest(this.sequence, this.sessionId); using (HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Post, "https://www.ipko.pl/secure/ikd3/api/paycards/init")) { requestMessage.Content = new StringContent(JsonConvert.SerializeObject(request)); requestMessage.Headers.Add("x-session-id", this.sessionId); requestMessage.Headers.Add("x-ias-ias_sid", this.sessionId); requestMessage.Headers.Add("x-http-method", "POST"); requestMessage.Headers.Add("x-http-method-override", "POST"); requestMessage.Headers.Add("x-method-override", "POST"); requestMessage.Headers.Add("x-requested-with", "XMLHttpRequest"); HttpResponseMessage httpResponseMessage = await this.client.SendAsync(requestMessage); string stringified = await httpResponseMessage.Content.ReadAsStringAsync(); GetCardsInitResponse response = (GetCardsInitResponse)JsonConvert.DeserializeObject(stringified, typeof(GetCardsInitResponse)); foreach (GetCardsInitResponse.Paycard paycard in response.response.paycard_list) { if (MaskedInputRecognizer.IsMatch(cardNumber, paycard.number)) { return(paycard); } } return(null); } }
public void NoSpaces_WhenBeginningAndLengthMatch_ButNotEndCase_IsMatchedFalse() { string masked = "44**********aa"; string unmasked = "441234567890AA"; Check.That(MaskedInputRecognizer.IsMatch(masked, unmasked)).IsFalse(); }
public void WithSpacesInMask_WhenBeginningEndAndLengthMatch_IsMatchedTrue() { string masked = "aa ***** ***** 1234"; string unmasked = "aa12345678901234"; Check.That(MaskedInputRecognizer.IsMatch(masked, unmasked)).IsTrue(); }
public void NoSpaces_WhenBeginningAndLengthMatch_ButNotEnd_IsMatchedFalse() { string masked = "aa**********6666"; string unmasked = "aa12345678901234"; Check.That(MaskedInputRecognizer.IsMatch(masked, unmasked)).IsFalse(); }
public void WhenNotMasked_Different_IsMatchedFalse() { string masked = "AA1234"; string unmasked = "aa1234"; Check.That(MaskedInputRecognizer.IsMatch(masked, unmasked)).IsFalse(); }
public void WithSpacesInRevealedParts_WhenBeginningEndMatch_ButNotLength_IsMatchedFalse() { string masked = "aa* * *** *** **12 34"; string unmasked = "a a 12 345 67890 1234"; Check.That(MaskedInputRecognizer.IsMatch(masked, unmasked)).IsTrue(); }
public void WhenNotMasked_Equal_IsMatchedTrue() { string masked = "aa1234"; string unmasked = "aa1234"; Check.That(MaskedInputRecognizer.IsMatch(masked, unmasked)).IsTrue(); Check.That(MaskedInputRecognizer.IsMatch(null, null)).IsTrue(); Check.That(MaskedInputRecognizer.IsMatch("", "")).IsTrue(); }
public void WhenOneIsNullOrEmpty_IsMatchedFalse() { string masked = ""; string unmasked = "aa1234"; Check.That(MaskedInputRecognizer.IsMatch(masked, unmasked)).IsFalse(); Check.That(MaskedInputRecognizer.IsMatch(masked, null)).IsFalse(); Check.That(MaskedInputRecognizer.IsMatch(null, unmasked)).IsFalse(); Check.That(MaskedInputRecognizer.IsMatch(null, "")).IsFalse(); }