public void TestSingleCorrectCompany()
        {
            string nipToCheck = VerifyCompany.Common.Test.Lib.CompanyGenerator.GetCorrectNIP();
            var a = _client.VerifyCompanies(nipToCheck, DateTime.Now).GetAwaiter().GetResult();
            Assert.IsNotNull(a.Result.RequestId);
            Assert.IsNotNull(a.Result.RequestDateTime);
            Assert.IsNotNull(a.Result.Entries);

            Entry result = a.Result.Entries.FirstOrDefault();
            Assert.AreEqual(nipToCheck, result.Identifier);
            Assert.AreEqual(nipToCheck, result.Subjects[0].Nip);
            Assert.AreEqual("Czynny", result.Subjects[0].StatusVat);
        }
Esempio n. 2
0
        /// <summary>
        /// The API has the limit of 10 requests and 30 companies in one
        /// </summary>
        public void TestTooManyRequests()
        {
            Random        r           = new Random((int)DateTime.Now.ToBinary());
            List <string> nipsToCheck = VerifyCompany.Common.Test.Lib.CompanyGenerator.GetCorrectNIPs();

            List <string> nipsInString = new List <string>();
            int           max          = nipsToCheck.Count;

            for (int i = 0; i < 11; i++)
            {
                string nipChunkToCheck = string.Empty;
                for (int j = 0; j < 30; j++)
                {
                    nipChunkToCheck += nipsToCheck[r.Next(0, max)] + ",";
                }
                nipChunkToCheck.Remove(nipChunkToCheck.Length - 1);
                nipsInString.Add(nipChunkToCheck);
            }

            for (int i = 0; i < 10; i++)
            {
                var b = _client.VerifyCompanies(nipsInString[i], DateTime.Now).GetAwaiter().GetResult();
                Assert.IsNotNull(b.Result.RequestId);
                Assert.IsNotNull(b.Result.RequestDateTime);
                Assert.IsNotNull(b.Result.Entries);
                //Assert.AreEqual(30, b.Result.Subjects.Count);
            }

            _client.VerifyCompanies(nipsInString[10], DateTime.Now).GetAwaiter().GetResult();
            _client.VerifyCompanies(nipsInString[9], DateTime.Now).GetAwaiter().GetResult();
            _client.VerifyCompanies(nipsInString[8], DateTime.Now).GetAwaiter().GetResult();
            _client.VerifyCompanies(nipsInString[7], DateTime.Now).GetAwaiter().GetResult();
            _client.VerifyCompanies(nipsInString[6], DateTime.Now).GetAwaiter().GetResult();
            _client.VerifyCompanies(nipsInString[5], DateTime.Now).GetAwaiter().GetResult();
            _client.VerifyCompanies(nipsInString[4], DateTime.Now).GetAwaiter().GetResult();
            _client.VerifyCompanies(nipsInString[3], DateTime.Now).GetAwaiter().GetResult();
            _client.VerifyCompanies(nipsInString[2], DateTime.Now).GetAwaiter().GetResult();
            _client.VerifyCompanies(nipsInString[1], DateTime.Now).GetAwaiter().GetResult();
            _client.VerifyCompanies(nipsInString[0], DateTime.Now).GetAwaiter().GetResult();
        }