Example #1
0
        public UKCityCommand(ICurrentWeatherService weatherService, ILoggerFactory loggerFactory)
        {
            this._weatherService = weatherService ?? throw new ArgumentNullException(nameof(weatherService));

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            this._logger = loggerFactory.CreateLogger(CommandHelper.ApplicationAuditCategory);
        }
        public void Constructing_WhenArgumentIsNull_ThrowArgumentNullException(bool isCurrenWeatherServiceNull, bool isLoggerNull, string exceptionMessage)
        {
            ICurrentWeatherService currentWeatherService = isCurrenWeatherServiceNull ? null : TestHelper.GetCurrentWeatherServiceMock().Object;

            Microsoft.Extensions.Logging.ILoggerFactory logger = isLoggerNull ? null : TestHelper.GetLoggerFactoryMock().Object;

            ArgumentNullException ex = Assert.Throws <ArgumentNullException>(() => new CitySearchCommand(currentWeatherService, logger));

            Assert.NotNull(ex);
            Assert.Equal(exceptionMessage, ex.Message);
        }
        public void ExecuteAsync_WhenCalled_ReturnSuccessful()
        {
            ICurrentWeatherService currentWeatherService = TestHelper.GetCurrentWeatherServiceMock().Object;

            Microsoft.Extensions.Logging.ILoggerFactory loggerFactory = TestHelper.GetLoggerFactoryMock().Object;

            CitySearchViewModel result = new CitySearchCommand(currentWeatherService, loggerFactory)
                                         .ExecuteAsync("auditId", "Guiseley")
                                         .Result;

            Assert.NotNull(result);
        }
Example #4
0
 public TimedHostedService(ILogger <TimedHostedService> logger, ICurrentWeatherService currentWeatherService)
 {
     _logger = logger;
     _currentWeatherService = currentWeatherService;
 }