public void HasClientNugetPackagePushAuthorizationsReturnsNoErrorMessageAndAndCompliesSLA()
        {
            #region arrange
            int requestsQtty = 100;
            int expectedSLA  = requestsQtty / 2;
            int errorCount   = 0;
            var watch        = new Stopwatch();


            var theClient = HasClientFactory.CreateApiClient(GetClientSettings());
            var effectiveAuthorization = EffectiveAuthorizationFactory.Create(_tenantId);
            var timestamp = DateTime.Now;
            #endregion arrange

            #region act
            watch.Start();
            for (int i = 0; i < requestsQtty; i++)
            {
                var grantResponseGranted = theClient.PushEffectiveAuthorizationGrantedAsync(effectiveAuthorization, timestamp).Result;

                if (!grantResponseGranted.IsSuccess)
                {
                    errorCount++;
                }
            }
            watch.Stop();
            var seconds = watch.Elapsed.Seconds;
            #endregion act

            //assert
            Assert.AreEqual(0, errorCount, $"{errorCount} errors on {requestsQtty} requests");
            Assert.IsTrue(seconds < expectedSLA, "Average requests timing exceeds expected SLA");
        }
        public void Client_PushEffectiveAuthorizationGranted_Valid_Event_Returns_CreatedEvent_Id()
        {
            //arrange
            var theClient = HasClientFactory.CreateApiClient(GetClientSettings());
            var effectiveAuthorization = EffectiveAuthorizationFactory.Create(_tenantId);

            //act
            var grantResponseGranted = theClient.PushEffectiveAuthorizationGranted(effectiveAuthorization, DateTime.Now);

            Assert.AreEqual(true, grantResponseGranted.IsSuccess);
            Assert.AreEqual(true, Guid.TryParse(grantResponseGranted.Message, out Guid id));
        }
        public async Task Client_PushEffectiveAuthorizationGrantedAsynk_Unauthorized_Returns_ErrorMessage()
        {
            //arrange
            var settings = GetClientSettings(_endppoint, _clientId, "InvalidSecret", _authenticationUrl, _xClientIdHeader);

            var theClient = HasClientFactory.CreateApiClient(settings);
            var effectiveAuthorization = EffectiveAuthorizationFactory.Create(_tenantId);

            //act
            var eventResponse = await theClient.PushEffectiveAuthorizationGrantedAsync(effectiveAuthorization, DateTime.Now);

            Assert.AreEqual(false, eventResponse.IsSuccess);
            Assert.AreEqual("Authentication failed!. Please check provided Authority url and credentials", eventResponse.Message);
        }