Exemplo n.º 1
0
        public async void when_HttpResponse_is_OK_Face()
        {
            TencentOCROptions _tencentOptions = new TencentOCROptions
            {
                Apiurl     = "http://service.image.myqcloud.com/ocr/idcard",
                AppId      = "1111",
                SecretId   = "dsdasdsadsa",
                SecretKey  = "weqwewqe",
                Bucket     = "idcard",
                HttpClient = new HttpClient(),
            };
            var json = this.GetBelongAssemblyResourceText("Tencent_ocr_face_response.json");

            var httpClient = MockHttpClientBuilder.New
                             .AddJsonResponse(request => VerifyHttpRequestMessage(request), json)
                             .Build();

            _tencentOptions.HttpClient = httpClient;
            IIDCardClient tencentIDcard = new TencentIDCardClient(_tencentOptions, _clock);

            var response = await tencentIDcard.DetectAsync(idCardRequest);

            Assert.True(response.Success, response.Message);
            var idCard = response.Result;

            Assert.Equal("李四", idCard.Name);
            Assert.Equal("汉", idCard.Nation);
            Assert.Equal("2000/1/1", idCard.Birth);
            Assert.Equal("成都", idCard.Address);
            Assert.Equal("123456200001011234", idCard.Id);
            Assert.Equal(Gender.Male, idCard.Gender);
            Assert.Null(idCard.Authority);
            Assert.Null(idCard.StartDate);
            Assert.Null(idCard.EndDate);
        }
Exemplo n.º 2
0
        public void when_TencentOCROptions_SecretKey_isNull_DetectTencent()
        {
            TencentOCROptions _tencentOptions = new TencentOCROptions
            {
                Apiurl     = "http://service.image.myqcloud.com/ocr/idcard",
                AppId      = "1111",
                SecretId   = "dsdasdsadsa",
                SecretKey  = null,
                Bucket     = "idcard",
                HttpClient = new HttpClient(),
            };

            Assert.Throws <ArgumentNullException>(() => new TencentIDCardClient(_tencentOptions, new Clock()));
        }
Exemplo n.º 3
0
        public void when_TencentOCROptions_Apiurl_isNull_DetectTencent()
        {
            TencentOCROptions _tencentOptions = new TencentOCROptions
            {
                Apiurl     = null,
                AppId      = "1111",
                SecretId   = "dsdasdsadsa",
                SecretKey  = "weqwewqe",
                Bucket     = "idcard",
                HttpClient = new HttpClient(),
            };

            Assert.Throws <ArgumentNullException>(() => new TencentIDCardClient(_tencentOptions, new Clock()));
        }
Exemplo n.º 4
0
        public async void when_IDCardRequest_isNull_DetectTencent()
        {
            TencentOCROptions _tencentOptions = new TencentOCROptions
            {
                Apiurl     = "http://service.image.myqcloud.com/ocr/idcard",
                AppId      = "1111",
                SecretId   = "dsdasdsadsa",
                SecretKey  = "weqwewqe",
                Bucket     = "idcard",
                HttpClient = new HttpClient(),
            };
            IIDCardClient tencentIDcard = new TencentIDCardClient(_tencentOptions, new Clock());

            await Assert.ThrowsAsync <ArgumentNullException>(() => tencentIDcard.DetectAsync(null));
        }