Ejemplo n.º 1
0
        public static void RegisterComponents()
        {
            var container = new UnityContainer();

            var configurationProvider = new ConfigurationProvider();

            container.RegisterFactory <IWebApiExceptionLogger>(f =>
                                                               GoogleWebApiExceptionLogger.Create(
                                                                   configurationProvider.ProjectId,
                                                                   configurationProvider.ServiceName,
                                                                   configurationProvider.ServiceVersion));

            container.RegisterType <IFluentBlaiseApi, FluentBlaiseApi>();
            container.RegisterType <IConfigurationProvider, ConfigurationProvider>();
            container.RegisterType <IParkService, ParkService>();
            container.RegisterType <ISurveyService, SurveyService>();

#if DEBUG
            var credentialKey = ConfigurationManager.AppSettings["GOOGLE_APPLICATION_CREDENTIALS"];

            Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", credentialKey);
#endif

            GlobalConfiguration.Configuration.DependencyResolver = new UnityDependencyResolver(container);
        }
Ejemplo n.º 2
0
        public void Log_NoContext()
        {
            var mockContextLogger = new Mock <IContextExceptionLogger>();
            var logger            = new GoogleWebApiExceptionLogger(mockContextLogger.Object);

            logger.Log(_exception);
            mockContextLogger.Verify(lb => lb.Log(_exception, It.IsNotNull <HttpActionContextWrapper>()));
        }
Ejemplo n.º 3
0
        public async Task LogAsync_NoContext()
        {
            var mockContextLogger = new Mock <IContextExceptionLogger>();
            var logger            = new GoogleWebApiExceptionLogger(mockContextLogger.Object);

            mockContextLogger.Setup(lb => lb.LogAsync(
                                        It.IsAny <Exception>(), It.IsAny <IContextWrapper>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(true));

            await logger.LogAsync(_exception);

            mockContextLogger.Verify(lb => lb.LogAsync(_exception, It.IsNotNull <HttpActionContextWrapper>(), It.IsAny <CancellationToken>()));
        }
Ejemplo n.º 4
0
        public string ThrowCatchWithGoogleWebApiLogger(string id)
        {
            var exceptionLogger = GoogleWebApiExceptionLogger.Create(TestEnvironment.GetTestProjectId(), EntryData.Service, EntryData.Version);
            var message         = EntryData.GetMessage(nameof(ThrowCatchWithGoogleWebApiLogger), id);

            try
            {
                throw new Exception(message);
            }
            catch (Exception e)
            {
                exceptionLogger.Log(e, ActionContext);
            }
            return(message);
        }
        public string ThrowCatchWithGoogleWebApiLogger(string id)
        {
            var exceptionLogger = GoogleWebApiExceptionLogger.Create(ProjectId, Service, Version);
            var message         = GetMessage(nameof(ThrowCatchWithGoogleWebApiLogger), id);

            try
            {
                throw new Exception(message);
            }
            catch (Exception e)
            {
                exceptionLogger.Log(e, ActionContext);
            }
            return(message);
        }