Ejemplo n.º 1
0
        public Task StartAsync(CancellationToken cancellationToken)
        {
            _logger.LogInformation("Using the injected logger from the App.");
            _writer.WriteDate();

            AsyncMessageWriter asyncMessageWriter = new AsyncMessageWriter(_loggerFactory.CreateLogger <AsyncMessageWriter>());

            return(asyncMessageWriter.WriteMessage("Here is a test message."));
        }
Ejemplo n.º 2
0
        public void UsingManuallyCreatedAndRegisteredDependencyInConstructorTest()
        {
            Startup.Configure();

            MockLogger         logger = (MockLogger)ServiceLocator.Current.GetService <ILogger>();
            AsyncMessageWriter writer = new AsyncMessageWriter(ServiceLocator.Current.GetService <ILogger <AsyncMessageWriter> >());

            writer.WriteMessage("Test string");
            Assert.True(logger.Called);
            Assert.Equal("WriteMessage called. Message: Test string", logger.With);
        }
Ejemplo n.º 3
0
        public static void Main(string[] args)
        {
            RegisterServices();

            AsyncMessageWriter asyncMessageWriter = new AsyncMessageWriter(ServiceLocator.Current.GetService <ILogger <AsyncMessageWriter> >());

            asyncMessageWriter.WriteMessage("Here is a test message.").Wait(100);

            IDateWriter writer = ServiceLocator.Current.GetService <IDateWriter>();

            writer.WriteDate();
        }