public void SetUp()
        {
            _mockRemoteErrorReportStorage = new Mock<IErrorReportStorage>();
            _mockLocalErrorReportStorage = new Mock<IErrorReportStorage>();
            _mockServiceProvider = new Mock<IServiceLocator>();
            _queue = new ErrorQueue();
            _mockServiceProvider.Setup(m => m.GetServices<IErrorReportStorage>())
                                .Returns(new List<IErrorReportStorage> { _mockRemoteErrorReportStorage.Object, _mockLocalErrorReportStorage.Object });
            _mockServiceProvider.Setup(m => m.GetService<IErrorQueue>())
                                .Returns(_queue);

            GlobalConfig.ServiceLocator = _mockServiceProvider.Object;

            _subject = new ErrorHandler();
        }
Esempio n. 2
0
        private static void InitServices()
        {
            var serviceContainer = new SimpleServiceContainer();

            GlobalConfig.ServiceLocator = serviceContainer;
            GlobalConfig.ErrorReportSerializer = new FormErrorReportSerializer();

            var errorReportQueue = new ErrorQueue();
            serviceContainer.AddService(typeof(IWebRequestCreate), new WebRequestFactory());
            serviceContainer.AddService(typeof(IErrorReportSerializer), (container, type) => GlobalConfig.ErrorReportSerializer);
            serviceContainer.AddService(typeof(IReportRequestBuilder), (container, type) => new ReportRequestBuilder());
            serviceContainer.AddService(typeof(IErrorReportStorage), (container, type) => new RemoteErrorReportStorage());
            serviceContainer.AddService(typeof(IErrorReportStorage), (container, type) => new LocalErrorReportStorage());
            serviceContainer.AddService(typeof(IErrorQueue), errorReportQueue);

            var errorHandler = new ErrorHandler();
            serviceContainer.AddService(typeof(IErrorHandler), errorHandler);
        }