public void YotiClientEngine_PerformAmlCheckAsync_Other() { var keyPair = GetKeyPair(); string sdkId = "fake-sdk-id"; FakeHttpRequester httpRequester = new FakeHttpRequester((httpClient, httpMethod, uri, headers, byteContent) => { return(Task.FromResult(new Response { Success = false, StatusCode = (int)HttpStatusCode.Forbidden, Content = "{Content}" })); }); YotiClientEngine engine = new YotiClientEngine(httpRequester); AmlProfile amlProfile = TestTools.Aml.CreateStandardAmlProfile(); AggregateException aggregateException = Assert.ThrowsException <AggregateException>(() => { AmlResult amlResult = engine.PerformAmlCheck(sdkId, keyPair, YotiConstants.DefaultYotiApiUrl, amlProfile); }); Assert.IsTrue(Exceptions.IsExceptionInAggregateException <AmlException>(aggregateException)); }
public async Task YotiClientEngine_PerformAmlCheckAsync() { var keyPair = GetKeyPair(); string sdkId = "fake-sdk-id"; FakeHttpRequester httpRequester = new FakeHttpRequester((httpClient, httpMethod, uri, headers, byteContent) => { return(Task.FromResult(new Response { Success = true, StatusCode = 200, Content = "{\"on_fraud_list\":true,\"on_pep_list\":false,\"on_watch_list\":false}" })); }); YotiClientEngine engine = new YotiClientEngine(httpRequester); AmlProfile amlProfile = TestTools.Aml.CreateStandardAmlProfile(); AmlResult amlResult = await engine.PerformAmlCheckAsync(sdkId, keyPair, YotiConstants.DefaultYotiApiUrl, amlProfile); Assert.IsNotNull(amlResult); Assert.IsTrue(amlResult.IsOnFraudList()); Assert.IsFalse(amlResult.IsOnPepList()); Assert.IsFalse(amlResult.IsOnWatchList()); }
public static AmlProfile CreateStandardAmlProfile() { AmlAddress amlAddress = CreateStandardAmlAddress(); var amlProfile = new AmlProfile( givenNames: "Edward Richard George", familyName: "Heath", amlAddress: amlAddress); return(amlProfile); }
public void AmlBadRequestShouldThrowException(HttpStatusCode httpStatusCode) { Mock <HttpMessageHandler> handlerMock = SetupMockMessageHandler( httpStatusCode, "{\"status\":\"bad\""); var engine = new YotiClientEngine(new HttpClient(handlerMock.Object)); AmlProfile amlProfile = TestTools.Aml.CreateStandardAmlProfile(); Assert.ThrowsExceptionAsync <AmlException>(async() => { await engine.PerformAmlCheckAsync(SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl), amlProfile); }); }
public void NullAmlAddressShouldThrowException() { YotiClient client = CreateYotiClient(); var amlProfile = new AmlProfile( givenNames: "Edward Richard George", familyName: "Heath", amlAddress: null); var aggregateException = Assert.ThrowsException <AggregateException>(() => { client.PerformAmlCheck(amlProfile: amlProfile); }); Assert.IsTrue(TestTools.Exceptions.IsExceptionInAggregateException <JsonSerializationException>(aggregateException)); }
public void GettersShouldRetrieveProfile() { const string givenNames = "Edward Richard George"; const string familyName = "Heath"; AmlAddress amlAddress = TestTools.Aml.CreateStandardAmlAddress(); const string ssn = "AAA-GG-SSSS"; var amlProfile = new AmlProfile( givenNames: givenNames, familyName: familyName, amlAddress: amlAddress, ssn: ssn); Assert.AreEqual(givenNames, amlProfile.GetGivenNames()); Assert.AreEqual(familyName, amlProfile.GetFamilyName()); Assert.AreEqual(amlAddress, amlProfile.GetAmlAddress()); Assert.AreEqual(ssn, amlProfile.GetSsn()); }
public void YotiClient_PerformAmlCheck_NullFamilyName_ThrowsException() { string sdkId = "fake-sdk-id"; var privateStreamKey = GetValidKeyStream(); YotiClient client = new YotiClient(sdkId, privateStreamKey); AmlProfile amlProfile = new AmlProfile( givenNames: "Edward Richard George", familyName: null, amlAddress: TestTools.Aml.CreateStandardAmlAddress()); AggregateException aggregateException = Assert.ThrowsException <AggregateException>(() => { AmlResult amlResult = client.PerformAmlCheck(amlProfile: amlProfile); }); Assert.IsTrue(Exceptions.IsExceptionInAggregateException <JsonSerializationException>(aggregateException)); }
public async Task PerformAmlCheckAsyncShouldReturnCorrectValues() { Mock <HttpMessageHandler> handlerMock = SetupMockMessageHandler( HttpStatusCode.OK, "{\"on_fraud_list\":true,\"on_pep_list\":false,\"on_watch_list\":false}"); var engine = new YotiClientEngine(new HttpClient(handlerMock.Object)); AmlProfile amlProfile = TestTools.Aml.CreateStandardAmlProfile(); AmlResult amlResult = await engine.PerformAmlCheckAsync( SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl), amlProfile); Assert.IsNotNull(amlResult); Assert.IsTrue(amlResult.IsOnFraudList()); Assert.IsFalse(amlResult.IsOnPepList()); Assert.IsFalse(amlResult.IsOnWatchList()); }