Esempio n. 1
0
        public static DotMailerCoreClient CreateDotMailerCoreClient()
        {
            NewtonsoftJsonRestSerializer jsonSerializer = new NewtonsoftJsonRestSerializer();
            IEnumerable <string>         contentTypes   = new List <string>()
            {
                "application/json",
                "text/json",
                "text/x-json"
            };

            IOptions <DotMailerCoreOptions> options = Options.Create <DotMailerCoreOptions>(new DotMailerCoreOptions()
            {
                BaseUrl       = "https://api.dotmailer.com/v2/",
                Authenticator = new HttpBasicAuthenticator("*****@*****.**", "demo"),
                Deserializer  = jsonSerializer,
                ContentTypes  = contentTypes
            }
                                                                                            );


            InMemoryCache     inMemoryCache     = new InMemoryCache();
            NullLoggerFactory nullLoggerFactory = new NullLoggerFactory();


            DotMailerCoreClient dotMailerCoreClient = new DotMailerCoreClient(inMemoryCache, jsonSerializer, options, nullLoggerFactory);

            return(dotMailerCoreClient);
        }
        public async Task Invoke_NoHandlersAdded_DefaultDelegateCalled(NullLoggerFactory loggerFactory,
                                                                       Mock <IServiceProvider> serviceProviderMock, string exceptionMessage,
                                                                       string path, string method)
        {
            //Arrange
            var requestDelegate = new RequestDelegate(httpContext => throw new Exception(exceptionMessage));

            var httpContextMock = new HttpContextMock();

            httpContextMock.HttpResponseMock.SetupSet(m => m.StatusCode  = 500).Verifiable();
            httpContextMock.HttpResponseMock.SetupSet(m => m.ContentType = "application/problem+json").Verifiable();
            httpContextMock.HttpRequestMock.SetupGet(r => r.Path).Returns("/" + path);
            httpContextMock.HttpRequestMock.SetupGet(r => r.Method).Returns(method);
            var expectedResponse = new ProblemDetails()
            {
                Status = 500,
                Title  = exceptionMessage
            };
            var expectedBody = JObject.FromObject(expectedResponse);

            var middleware = new ExceptionMiddleware(requestDelegate, loggerFactory, serviceProviderMock.Object);
            await middleware.Invoke(httpContextMock.Object);

            //Assert
            httpContextMock.HttpResponseMock.Verify();
            JToken.DeepEquals(expectedBody, JObject.Parse(httpContextMock.HttpResponseMock.ActualBody));
        }
Esempio n. 3
0
        static async Task Main(string[] args)
        {
            NullLoggerFactory      nullLoggerFactory      = new NullLoggerFactory();
            SocketTransportOptions socketTransportOptions = new SocketTransportOptions();
            SocketTransportFactory socketTransportFactory = new SocketTransportFactory(
                new OptionsWrapper <SocketTransportOptions>(socketTransportOptions), nullLoggerFactory);
            KestrelServerOptions kestrelServerOptions = new KestrelServerOptions();

            //kestrelServerOptions.AllowSynchronousIO = true;
            kestrelServerOptions.ListenLocalhost(5000);
            kestrelServerOptions.ApplicationServices = new ServiceProvider();
            kestrelServerOptions.ListenLocalhost(5001, listenOptions =>
            {
                X509Certificate2 serverCertificate = new X509Certificate2("certificate.pfx", "xxxx");
                listenOptions.UseHttps(serverCertificate);
            });

            using (KestrelServer kestrelServer =
                       new KestrelServer(new OptionsWrapper <KestrelServerOptions>(kestrelServerOptions),
                                         socketTransportFactory,
                                         nullLoggerFactory
                                         )
                   )
            {
                await kestrelServer.StartAsync(new HttpApplication(), CancellationToken.None);

                Console.ReadLine();
            }
        }
Esempio n. 4
0
        private ScopeProvider GetScopeProvider(NullLoggerFactory instance)
        {
            var fileSystems = new FileSystems(
                instance,
                Mock.Of <IIOHelper>(),
                Options.Create(new GlobalSettings()),
                Mock.Of <IHostingEnvironment>());

            var mediaFileManager = new MediaFileManager(
                Mock.Of <IFileSystem>(),
                Mock.Of <IMediaPathScheme>(),
                instance.CreateLogger <MediaFileManager>(),
                Mock.Of <IShortStringHelper>(),
                Mock.Of <IServiceProvider>(),
                Options.Create(new ContentSettings()));

            return(new ScopeProvider(
                       Mock.Of <IUmbracoDatabaseFactory>(),
                       fileSystems,
                       Options.Create(new CoreDebugSettings()),
                       mediaFileManager,
                       Mock.Of <ILogger <ScopeProvider> >(),
                       instance,
                       Mock.Of <IRequestCache>(),
                       Mock.Of <IEventAggregator>()
                       ));
        }
Esempio n. 5
0
        public void CanRemoveObjectFromParentWhenNotDirectChild()
        {
            using var file = File.OpenRead(@"Data\ZORK1.DAT");
            var logger  = NullLoggerFactory.GetLogger();
            var machine = new Machine(logger, new SolveZorkInputStream());

            machine.Load(file);

            var o247 = machine.ObjectTable.GetObject(247);
            var o1   = machine.ObjectTable.GetObject(1);
            var o248 = machine.ObjectTable.GetObject(248);

            o1.Sibling = 33;

            // 247 -> 248
            //         |
            //         1
            //         |
            //         33

            machine.ObjectTable.RemoveFromParent(1);

            Assert.Equal(248, o247.Child);
            Assert.Equal(0, o1.Parent);
            Assert.Equal(33, o248.Sibling);
            Assert.Equal(247, o248.Parent);
        }
Esempio n. 6
0
        public void AbbreviationsMakeSense()
        {
            using var file = File.OpenRead(@"Data\ZORK1.DAT");
            var logger  = NullLoggerFactory.GetLogger();
            var machine = new Machine(logger, new SolveZorkInputStream());

            machine.Load(file);

            logger.Error($"ABBREVIATIONS");
            var decoder = new ZStringDecoder(machine);

            for (var index = 1; index <= 3; index++)
            {
                for (var number = 0; number < 32; number++)
                {
                    var offset = (32 * (index - 1)) + (number * 2);
                    logger.Error($"For [{index}][{number}] the offset is {offset}");

                    var ppAbbreviation = machine.Memory.WordAt(Header.ABBREVIATIONS);
                    logger.Error($"For [{index}][{number}] the ppointer is {ppAbbreviation:X}");

                    var pAbbreviation = machine.Memory.WordAddressAt(ppAbbreviation + offset);
                    logger.Error($"For [{index}][{number}] the pointer is {pAbbreviation:X}");

                    var location = machine.Memory.SpanAt(pAbbreviation);
                    var result   = decoder.Decode(location).Text;

                    logger.Error($"Abbreviation [{index}][{number}] : {result}");
                }
            }
        }
Esempio n. 7
0
        private ScopeProvider GetScopeProvider(out Mock <IEventAggregator> eventAggregatorMock)
        {
            NullLoggerFactory loggerFactory = NullLoggerFactory.Instance;

            var fileSystems = new FileSystems(
                loggerFactory,
                Mock.Of <IIOHelper>(),
                Options.Create(new GlobalSettings()),
                Mock.Of <IHostingEnvironment>());

            var mediaFileManager = new MediaFileManager(
                Mock.Of <IFileSystem>(),
                Mock.Of <IMediaPathScheme>(),
                loggerFactory.CreateLogger <MediaFileManager>(),
                Mock.Of <IShortStringHelper>(),
                Mock.Of <IServiceProvider>(),
                Options.Create(new ContentSettings()));

            eventAggregatorMock = new Mock <IEventAggregator>();

            return(new ScopeProvider(
                       Mock.Of <IDistributedLockingMechanismFactory>(),
                       Mock.Of <IUmbracoDatabaseFactory>(),
                       fileSystems,
                       new TestOptionsMonitor <CoreDebugSettings>(new CoreDebugSettings()),
                       loggerFactory,
                       Mock.Of <IRequestCache>(),
                       eventAggregatorMock.Object
                       ));
        }
Esempio n. 8
0
        public MutationTest(DatabaseFixture fixture)
        {
            this.fixture = fixture;

            ILoggerFactory factory = new NullLoggerFactory();

            _projectService          = new ProjectService(fixture.context);
            _evaluationService       = new EvaluationService(fixture.context);
            _participantService      = new ParticipantService(fixture.context);
            _questionService         = new QuestionService(fixture.context);
            _answerService           = new AnswerService(fixture.context);
            _actionService           = new ActionService(fixture.context);
            _noteService             = new NoteService(fixture.context);
            _closingRemarkService    = new ClosingRemarkService(fixture.context);
            _questionTemplateService = new QuestionTemplateService(fixture.context);
            _projectCategoryService  = new ProjectCategoryService(fixture.context);
            _authService             = new MockAuthService();
            _mutation = new Mutation(
                _projectService,
                _evaluationService,
                _participantService,
                _questionService,
                _answerService,
                _actionService,
                _noteService,
                _closingRemarkService,
                _questionTemplateService,
                _projectCategoryService,
                _authService,
                new Logger <Mutation>(factory)
                );

            _project = _projectService.Create("Project");
        }
        public async Task GivenImportTaskInput_WhenOperationWasCancelledExceptionThrow_ThenTaskShouldBeCanceled()
        {
            ImportProcessingTaskInputData inputData = GetInputData();
            ImportProcessingProgress      progress  = new ImportProcessingProgress();

            IImportResourceLoader    loader                              = Substitute.For <IImportResourceLoader>();
            IResourceBulkImporter    importer                            = Substitute.For <IResourceBulkImporter>();
            IImportErrorStore        importErrorStore                    = Substitute.For <IImportErrorStore>();
            IImportErrorStoreFactory importErrorStoreFactory             = Substitute.For <IImportErrorStoreFactory>();
            IContextUpdater          contextUpdater                      = Substitute.For <IContextUpdater>();
            RequestContextAccessor <IFhirRequestContext> contextAccessor = Substitute.For <RequestContextAccessor <IFhirRequestContext> >();
            ILoggerFactory loggerFactory = new NullLoggerFactory();

            importer.Import(Arg.Any <Channel <ImportResource> >(), Arg.Any <IImportErrorStore>(), Arg.Any <CancellationToken>())
            .Returns(callInfo =>
            {
                throw new OperationCanceledException();
            });

            ImportProcessingTask task = new ImportProcessingTask(
                inputData,
                progress,
                loader,
                importer,
                importErrorStoreFactory,
                contextUpdater,
                contextAccessor,
                loggerFactory);

            TaskResultData result = await task.ExecuteAsync();

            Assert.Equal(TaskResult.Canceled, result.Result);
        }
Esempio n. 10
0
        public void CanTokensize()
        {
            using var file = File.OpenRead(@"Data\ZORK1.DAT");
            var logger  = NullLoggerFactory.GetLogger();
            var machine = new Machine(logger, new SolveZorkInputStream());

            machine.Load(file);

            var textBytes = new byte[37];

            textBytes[0] = (byte)textBytes.Length;

            var textMemory = new MemoryLocation(1, textBytes.AsMemory());
            var textBuffer = new TextBuffer(textMemory);

            textBuffer.Write("fred,go fishing");

            var dictionary = new ParseDictionary(machine);

            textBuffer.Tokenize(dictionary);

            Assert.Equal(4, textBuffer.Tokens.Count);
            Assert.Equal("fred", textBuffer.Tokens[1]);
            Assert.Equal(",", textBuffer.Tokens[5]);
            Assert.Equal("go", textBuffer.Tokens[6]);
            Assert.Equal("fishing", textBuffer.Tokens[9]);
        }
        public void Cloud()
        {
            var options       = new NetworkingOptions();
            var loggerFactory = new NullLoggerFactory();

            options.Addresses.Clear();

            options.Cloud.DiscoveryToken = null;
            Assert.That(options.Cloud.Enabled, Is.False);

            options.Cloud.DiscoveryToken = "*****";
            Assert.That(options.Cloud.Enabled, Is.True);

            options.Cloud.Url = null;
            Assert.Throws <ArgumentNullException>(() => _ = new AddressProvider(options, loggerFactory));
            options.Cloud.Url = new Uri("http://xxxxx");

            options.Addresses.Add("192.0.0.1:5701");
            Assert.Throws <ConfigurationException>(() => _ = new AddressProvider(options, loggerFactory));

            options.Addresses.Clear();

            CloudDiscovery.SetResponse(@"[
    { ""private-address"":""192.0.0.6:5788"", ""public-address"":""192.147.0.6"" },
    { ""private-address"":""192.0.0.7"", ""public-address"":""192.147.0.7"" },
    { ""private-address"":""192.0.0.8:5777"", ""public-address"":""192.147.0.8:5703"" },
    { ""private-address"":""192.0.0.9"", ""public-address"":""192.147.0.9:5707"" },
]");
Esempio n. 12
0
        private static AccountController MockAccountController(SignInManager<ApplicationUser> mockSignInManager, UserManager<ApplicationUser> mockUserManager)
        {
            var mockEmailSender = new Mock<IEmailSender>();
            var mockSmsSender = new Mock<ISmsSender>();
            var mockApplicationDbContext = new Mock<ApplicationDbContext>();
            var mockEmailTemplate = new Mock<IEmailTemplate>();
            var mockNullLoggerFactory = new NullLoggerFactory();


            var mockLocalizer = new Mock<IStringLocalizer<AccountController>>();
            mockLocalizer.Setup(m => m[It.IsAny<string>()])
                .Returns<string>(x => new LocalizedString(x, x, false));
            mockLocalizer.Setup(m => m[It.IsAny<string>(), It.IsAny<object>()])
                .Returns<string, object[]>((x, y) => new LocalizedString(x, string.Format(x, y), false));

            var controller = new AccountController(mockUserManager, mockSignInManager, mockEmailSender.Object, mockSmsSender.Object, mockNullLoggerFactory, mockApplicationDbContext.Object, mockEmailTemplate.Object, mockLocalizer.Object);

            var mockUrl = new Mock<IUrlHelper>();
            mockUrl.Setup(m => m.IsLocalUrl("localUrl")).Returns(true);
            mockUrl.Setup(m => m.IsLocalUrl("remoteUrl")).Returns(false);

            controller.Url = mockUrl.Object;

            return controller;
        }
Esempio n. 13
0
        public PlayerControllerTest()
        {
            PlayerRepository.InitializePlayerDataFromCsv(Resources.ControllerTestData);
            ILoggerFactory mockFactory = new NullLoggerFactory();

            _controller = new PlayerController(mockFactory.CreateLogger <PlayerController>(), new PlayerService());
        }
Esempio n. 14
0
        public ParseFromFileTests()
        {
            ILoggerFactory loggerFactory = new NullLoggerFactory();

            Lexer  = new CobaltLexer(loggerFactory);
            Parser = new CobaltParser(loggerFactory);
        }
Esempio n. 15
0
        public void CanReturnLargeValue()
        {
            var logger  = NullLoggerFactory.GetLogger();
            var machine = new Machine(logger, new SolveZorkInputStream());

            var operand1 = new Operand(OperandType.Large, 0xFFFF, machine);
            var operand2 = new Operand(OperandType.Large, 0xFFFE, machine);
            var operand3 = new Operand(OperandType.Large, 0xFFD7, machine);
            var operand4 = new Operand(OperandType.Large, 0x0001, machine);
            var operand5 = new Operand(OperandType.Large, 0x007F, machine);
            var operand6 = new Operand(OperandType.Large, 0x7FFF, machine);

            Assert.Equal(-1, operand1.SignedValue);
            Assert.Equal(65535, operand1.Value);

            Assert.Equal(-2, operand2.SignedValue);
            Assert.Equal(65534, operand2.Value);

            Assert.Equal(-41, operand3.SignedValue);
            Assert.Equal(65495, operand3.Value);

            Assert.Equal(1, operand4.SignedValue);
            Assert.Equal(1, operand4.Value);

            Assert.Equal(127, operand5.SignedValue);
            Assert.Equal(127, operand5.Value);

            Assert.Equal(32767, operand6.SignedValue);
            Assert.Equal(32767, operand6.Value);
        }
        public void SetUp()
        {
            this.context = new DefaultHttpContext();
            this.context.Request.Method      = HttpMethod;
            this.context.Request.Path        = Path;
            this.context.Request.QueryString = new QueryString(QueryString);

            this.errorHandlerMock = new Mock <IErrorHandler>();

            this.plainConfigurationCacheMock         = new Mock <IPlainConfigurationCache>();
            this.plainRouteConfigurationProviderMock = new Mock <IPlainRouteConfigurationProvider>();

            this.plainHttpRequestFactoryMock = new Mock <IPlainHttpRequestFactory>();

            this.httpClientWrapperMock = new Mock <IHttpClientWrapper>();

            var loggerFactory = new NullLoggerFactory();

            this.sut = new RequestRedirectMiddleware(
                RequestDelegate,
                plainConfigurationCacheMock.Object,
                plainRouteConfigurationProviderMock.Object,
                plainHttpRequestFactoryMock.Object,
                httpClientWrapperMock.Object,
                loggerFactory);
        }
        public async Task FullPath_WritesMessage_True()
        {
            // The Trailing Service Path Tuner is an opt-in service.

            // This test demonstrates existing functionality is not changed
            // when the service is not registered in app startup (opted-in).

            // Arrange
            var logger = new NullLoggerFactory().CreateLogger <SoapEndpointMiddleware>();

            var         encoder = new MockMessageEncoder();
            SoapOptions options = new SoapOptions()
            {
                Path             = "/v1/Service.svc",     // this is the multi-part path registered in app startup
                Binding          = new CustomBinding(),
                MessageEncoders  = new MessageEncoder[] { encoder },
                ServiceType      = typeof(MockSoapService),
                SoapModelBounder = new MockModelBounder(),
                SoapSerializer   = SoapSerializer.DataContractSerializer
            };

            SoapEndpointMiddleware soapCore = new SoapEndpointMiddleware(logger, (innerContext) => Task.FromResult(TaskStatus.RanToCompletion), options);

            var context = new DefaultHttpContext();

            context.Request.Path = new PathString("/v1/Service.svc");

            // Act
            // MockServiceProvider(false) simulates not registering the TrailingServicePathTuner in app startup
            await soapCore.Invoke(context, new MockServiceProvider(false));

            // Assert
            Assert.AreEqual(true, encoder.DidWriteMessage);
        }
        public async Task GivenImportTaskInput_WhenExceptionThrowForCleanData_ThenRetriableExceptionShouldBeThrow()
        {
            ImportProcessingTaskInputData inputData = GetInputData();
            ImportProcessingProgress      progress  = new ImportProcessingProgress();

            IImportResourceLoader    loader                              = Substitute.For <IImportResourceLoader>();
            IResourceBulkImporter    importer                            = Substitute.For <IResourceBulkImporter>();
            IImportErrorStore        importErrorStore                    = Substitute.For <IImportErrorStore>();
            IImportErrorStoreFactory importErrorStoreFactory             = Substitute.For <IImportErrorStoreFactory>();
            IContextUpdater          contextUpdater                      = Substitute.For <IContextUpdater>();
            RequestContextAccessor <IFhirRequestContext> contextAccessor = Substitute.For <RequestContextAccessor <IFhirRequestContext> >();
            ILoggerFactory loggerFactory = new NullLoggerFactory();

            importer.CleanResourceAsync(Arg.Any <ImportProcessingTaskInputData>(), Arg.Any <ImportProcessingProgress>(), Arg.Any <CancellationToken>())
            .Returns(callInfo =>
            {
                throw new InvalidOperationException();
            });

            progress.NeedCleanData = true;
            ImportProcessingTask task = new ImportProcessingTask(
                inputData,
                progress,
                loader,
                importer,
                importErrorStoreFactory,
                contextUpdater,
                contextAccessor,
                loggerFactory);

            await Assert.ThrowsAsync <RetriableTaskException>(() => task.ExecuteAsync());
        }
        public void GetService_GenericAndSpecificRegistered_ReturnsSpecificService()
        {
            // Arrange

            var loggerFactory = new NullLoggerFactory();

            var logger = new Logger <CouchbaseServiceProvider>(loggerFactory);

            var provider = new CouchbaseServiceProvider(new[]
            {
                new KeyValuePair <Type, IServiceFactory>(typeof(ILoggerFactory), new SingletonServiceFactory(loggerFactory)),
                new KeyValuePair <Type, IServiceFactory>(typeof(ILogger <>), new SingletonGenericServiceFactory(typeof(Logger <>))),
                new KeyValuePair <Type, IServiceFactory>(typeof(ILogger <CouchbaseServiceProvider>), new SingletonServiceFactory(logger))
            });

            // Act

            var result = provider.GetService(typeof(ILogger <CouchbaseServiceProvider>));

            // Assert

            Assert.NotNull(result);
            var resultLogger = Assert.IsAssignableFrom <Logger <CouchbaseServiceProvider> >(result);

            Assert.Equal(logger, resultLogger);
        }
Esempio n. 20
0
        private static RSocketClient CreateClient()
        {
            var factory   = new NullLoggerFactory();
            var transport = new ClientWebSocketTransport("ws://localhost:5000/api", factory.CreateLogger <WebSocketTransport>());

            return(new RSocketClient(transport));
        }
Esempio n. 21
0
        /// <summary>
        /// Starts listening for new Websocket stream connections
        /// </summary>
        /// <param name="endpoint">The endpoint to listen to</param>
        /// <param name="connectionAdded">A connection delegate that is called when a new client is connected</param>
        /// <param name="bufferSize">Buffer sized used for receiving</param>
        /// <param name="defaultPage">Default response to clients like browsers</param>
        /// <returns></returns>
        public Task StartAsync(IPEndPoint endpoint, Func <WsStream, Task> connectionAdded, int bufferSize = Config.InternalBufferSize, string defaultPage = Config.Version)
        {
            if (IsListening)
            {
                throw new InvalidOperationException("WsServer is already running!");
            }
            _stopSource = new CancellationTokenSource();
            IsListening = true;
            // setup kestrel parameters
            var logger                 = new NullLoggerFactory();
            var kestrelOptions         = new KestrelServerOptions();
            var lifetime               = new ApplicationLifetime(logger.CreateLogger <ApplicationLifetime>());
            var socketTransportFactory = new SocketTransportFactory(Options.Create(new SocketTransportOptions()), lifetime, logger);

            // start kestrel
            _server = new KestrelServer(Options.Create(kestrelOptions), socketTransportFactory, logger);
            _server.Options.Listen(endpoint);
            return(_server
                   .StartAsync(new KestrelRequestHandler(connectionAdded, bufferSize, _stopSource.Token, defaultPage),
                               CancellationToken.None).ContinueWith(
                       x =>
            {
                var addr = _server.Features.Get <IServerAddressesFeature>();
                ListeningAddresses = addr.Addresses.ToArray();
            }));
        }
Esempio n. 22
0
        private static AccountController MockAccountController(SignInManager <ApplicationUser> mockSignInManager, UserManager <ApplicationUser> mockUserManager)
        {
            var mockEmailSender          = new Mock <IEmailSender>();
            var mockSmsSender            = new Mock <ISmsSender>();
            var mockApplicationDbContext = new Mock <ApplicationDbContext>();
            var mockEmailTemplate        = new Mock <IEmailTemplate>();
            var mockNullLoggerFactory    = new NullLoggerFactory();


            var mockLocalizer = new Mock <IStringLocalizer <AccountController> >();

            mockLocalizer.Setup(m => m[It.IsAny <string>()])
            .Returns <string>(x => new LocalizedString(x, x, false));
            mockLocalizer.Setup(m => m[It.IsAny <string>(), It.IsAny <object>()])
            .Returns <string, object[]>((x, y) => new LocalizedString(x, string.Format(x, y), false));

            var controller = new AccountController(mockUserManager, mockSignInManager, mockEmailSender.Object, mockSmsSender.Object, mockNullLoggerFactory, mockApplicationDbContext.Object, mockEmailTemplate.Object, mockLocalizer.Object);

            var mockUrl = new Mock <IUrlHelper>();

            mockUrl.Setup(m => m.IsLocalUrl("localUrl")).Returns(true);
            mockUrl.Setup(m => m.IsLocalUrl("remoteUrl")).Returns(false);

            controller.Url = mockUrl.Object;

            return(controller);
        }
Esempio n. 23
0
        public MutationTest()
        {
            ILoggerFactory factory = new NullLoggerFactory();

            _projectService          = new ProjectService(_context);
            _evaluationService       = new EvaluationService(_context);
            _participantService      = new ParticipantService(_context);
            _questionService         = new QuestionService(_context);
            _answerService           = new AnswerService(_context);
            _questionTemplateService = new QuestionTemplateService(_context);
            _actionService           = new ActionService(_context);
            _noteService             = new NoteService(_context);
            _mutation = new Mutation(
                _projectService,
                _evaluationService,
                _participantService,
                _questionService,
                _answerService,
                _questionTemplateService,
                _actionService,
                _noteService,
                new MockAuthService(),
                new Logger <Mutation>(factory)
                );
        }
Esempio n. 24
0
 private static async Task Main()
 {
     var logger   = new NullLoggerFactory().CreateLogger <RkRepository>();
     var client   = new RkTracksClient(new HttpClient());
     var repo     = new RkRepository(logger, client);
     var playlist = new Playlist <RkTrack>(repo);
     await playlist.Start();
 }
Esempio n. 25
0
        public WhenNavigating()
        {
            var logger           = new NullLoggerFactory().CreateLogger("Logger");
            var directionControl = new DirectionControl();
            var movementControl  = new MovementControl();

            _navigationControl = new NavigationControl(movementControl, directionControl, logger);
        }
Esempio n. 26
0
        static LoggingFactory()
        {
            ILoggerFactory loggerFactory = new NullLoggerFactory()
                                           .AddConsole()
                                           .AddDebug();

            _logger = loggerFactory.CreateLogger("DBSeed");
        }
        public void SetUp()
        {
            this.httpClientFactoryMock = new Mock <IHttpClientFactory>();

            var loggerFactory = new NullLoggerFactory();

            this.sut = new HttpClientWrapper(this.httpClientFactoryMock.Object, loggerFactory);
        }
Esempio n. 28
0
        public async Task GivenAnOrchestratorTaskAndWrongEtag_WhenOrchestratorTaskStart_ThenTaskShouldFailedWithDetails()
        {
            IImportOrchestratorTaskDataStoreOperation fhirDataBulkImportOperation = Substitute.For <IImportOrchestratorTaskDataStoreOperation>();
            IContextUpdater contextUpdater = Substitute.For <IContextUpdater>();
            RequestContextAccessor <IFhirRequestContext> contextAccessor = Substitute.For <RequestContextAccessor <IFhirRequestContext> >();
            ILoggerFactory loggerFactory = new NullLoggerFactory();
            IIntegrationDataStoreClient     integrationDataStoreClient      = Substitute.For <IIntegrationDataStoreClient>();
            ISequenceIdGenerator <long>     sequenceIdGenerator             = Substitute.For <ISequenceIdGenerator <long> >();
            ImportOrchestratorTaskInputData importOrchestratorTaskInputData = new ImportOrchestratorTaskInputData();
            ImportOrchestratorTaskContext   importOrchestratorTaskContext   = new ImportOrchestratorTaskContext();
            ITaskManager taskManager = Substitute.For <ITaskManager>();

            importOrchestratorTaskInputData.TaskId         = Guid.NewGuid().ToString("N");
            importOrchestratorTaskInputData.TaskCreateTime = Clock.UtcNow;
            importOrchestratorTaskInputData.BaseUri        = new Uri("http://dummy");
            var inputs = new List <InputResource>();

            inputs.Add(new InputResource()
            {
                Type = "Resource", Url = new Uri("http://dummy"), Etag = "dummy"
            });
            importOrchestratorTaskInputData.Input       = inputs;
            importOrchestratorTaskInputData.InputFormat = "ndjson";
            importOrchestratorTaskInputData.InputSource = new Uri("http://dummy");
            importOrchestratorTaskInputData.MaxConcurrentProcessingTaskCount = 1;
            importOrchestratorTaskInputData.ProcessingTaskQueueId            = "default";
            importOrchestratorTaskInputData.RequestUri = new Uri("http://dummy");

            integrationDataStoreClient.GetPropertiesAsync(Arg.Any <Uri>(), Arg.Any <CancellationToken>())
            .Returns(callInfo =>
            {
                Dictionary <string, object> properties = new Dictionary <string, object>();
                properties[IntegrationDataStoreClientConstants.BlobPropertyETag]   = "test";
                properties[IntegrationDataStoreClientConstants.BlobPropertyLength] = 1000L;
                return(properties);
            });

            sequenceIdGenerator.GetCurrentSequenceId().Returns(_ => 0L);

            ImportOrchestratorTask orchestratorTask = new ImportOrchestratorTask(
                importOrchestratorTaskInputData,
                importOrchestratorTaskContext,
                taskManager,
                sequenceIdGenerator,
                contextUpdater,
                contextAccessor,
                fhirDataBulkImportOperation,
                integrationDataStoreClient,
                loggerFactory);

            TaskResultData result = await orchestratorTask.ExecuteAsync();

            ImportTaskErrorResult resultDetails = JsonConvert.DeserializeObject <ImportTaskErrorResult>(result.ResultData);

            Assert.Equal(TaskResult.Fail, result.Result);
            Assert.Equal(HttpStatusCode.BadRequest, resultDetails.HttpStatusCode);
            Assert.NotEmpty(resultDetails.ErrorMessage);
        }
Esempio n. 29
0
 public Server(ILoggerFactory loggerFactory = null)
 {
     if (loggerFactory == null)
     {
         loggerFactory = new NullLoggerFactory();
     }
     _loggerFactory = loggerFactory;
     _logger        = loggerFactory.CreateLogger("KupaRPC");
 }
Esempio n. 30
0
        public PersonControllerTest(ITestOutputHelper testOutputHelper)
        {
            _testOutputHelper = testOutputHelper;
            ILoggerFactory loggerFactory = new NullLoggerFactory();

            _controller = new PersonController(loggerFactory.CreateLogger <PersonController>());
            _person     = new PersonDto(99999, "MyTest", "MyTest", "*****@*****.**", "test", "test",
                                        "test", "03 87 87 87 87", 2, "Test", "Test");
        }
        public void NullLoggerTests()
        {
            ILoggerFactory factory = new NullLoggerFactory();

            Assert.IsNotNull(factory);
            ILogger logger = factory.CreateLogger();

            Assert.IsNotNull(logger);
        }