Exemplo n.º 1
0
        public void ObfuscationServiceIsNotNull()
        {
            var application = new Application("organizationId", "applicationId");
            var listener    = new RequestLogsApiListener(application);

            Assert.IsNotNull(listener.ObfuscationService);
        }
Exemplo n.º 2
0
        public void UseAsyncHasADefaultValue()
        {
            var application = new Application("organizationId", "applicationId");
            var listener    = new RequestLogsApiListener(application);

            Assert.IsTrue(listener.UseAsync);
        }
Exemplo n.º 3
0
        public void IgnoreSslCertificateHasADefaultValue()
        {
            var application = new Application("organizationId", "applicationId");
            var listener    = new RequestLogsApiListener(application);

            Assert.IsFalse(listener.IgnoreSslCertificate);
        }
Exemplo n.º 4
0
        public void ApiUrlHasADefaultValue()
        {
            var application = new Application("organizationId", "applicationId");
            var listener    = new RequestLogsApiListener(application);

            Assert.AreEqual(Constants.KissLogApiUrl, listener.ApiUrl);
        }
Exemplo n.º 5
0
        public void ValidatePropertiesReturnsFalseForNullApplicationId(string applicationId)
        {
            var application = new Application("organizationId", applicationId);
            var listener    = new RequestLogsApiListener(application);

            bool isValid = listener.ValidateProperties();

            Assert.IsFalse(isValid);
        }
Exemplo n.º 6
0
        public void ValidatePropertiesReturnsTrueForValidApiUrl(string apiUrl)
        {
            var application = new Application("organizationId", "applicationId");
            var listener    = new RequestLogsApiListener(application)
            {
                ApiUrl = apiUrl
            };

            bool isValid = listener.ValidateProperties();

            Assert.IsTrue(isValid);
        }
Exemplo n.º 7
0
        public void NullObfuscationServiceDoesNotThrowException()
        {
            var kisslogApi = new Mock <IPublicApi>();

            kisslogApi.Setup(p => p.CreateRequestLog(It.IsAny <CreateRequestLogRequest>(), It.IsAny <IEnumerable <File> >()))
            .Returns(new ApiResult <RequestLog>());

            var listener = new RequestLogsApiListener(new Application("organizationId", "applicationId"), kisslogApi.Object)
            {
                UseAsync           = false,
                ObfuscationService = null
            };

            FlushLogArgs flushLogArgs = CommonTestHelpers.Factory.CreateFlushLogArgs();

            listener.OnFlush(flushLogArgs);
        }
Exemplo n.º 8
0
        public void UseAsyncIsEvaluated(bool useAsync)
        {
            bool createRequestLog      = false;
            bool createRequestLogAsync = false;

            var kisslogApi = new Mock <IPublicApi>();

            kisslogApi.Setup(p => p.CreateRequestLog(It.IsAny <CreateRequestLogRequest>(), It.IsAny <IEnumerable <File> >())).Callback(() =>
            {
                createRequestLog = true;
            })
            .Returns(new ApiResult <RequestLog>());

            kisslogApi.Setup(p => p.CreateRequestLogAsync(It.IsAny <CreateRequestLogRequest>(), It.IsAny <IEnumerable <File> >())).Callback(() =>
            {
                createRequestLogAsync = true;
            })
            .Returns(Task.FromResult(new ApiResult <RequestLog>()));

            var listener = new RequestLogsApiListener(new Application("organizationId", "applicationId"), kisslogApi.Object)
            {
                UseAsync = useAsync
            };

            FlushLogArgs flushLogArgs = CommonTestHelpers.Factory.CreateFlushLogArgs();

            listener.OnFlush(flushLogArgs);

            if (useAsync == true)
            {
                Assert.IsFalse(createRequestLog);
                Assert.IsTrue(createRequestLogAsync);
            }
            else
            {
                Assert.IsTrue(createRequestLog);
                Assert.IsFalse(createRequestLogAsync);
            }
        }
Exemplo n.º 9
0
 public void ThrowsExceptionWhenApplicationIsNull()
 {
     var listener = new RequestLogsApiListener(null);
 }