public async Task PostWeatherLog_SeededLogs()
        {
            //Arrange
            _context = new ApplicationDbContext(
                new DbContextOptionsBuilder <ApplicationDbContext>().UseSqlite(CreateInMemoryDatabase()).Options);
            _mockHub           = Substitute.For <IHubContext <WeatherHub> >();
            _weatherController = new WeatherLogsController(_context, _mockHub);
            Seed();

            WeatherLogDto tempweatherlog = new WeatherLogDto()
            {
                LogTime     = new DateTime(2021, 10, 9, 8, 00, 00),
                LogPlaceId  = 1,
                Temperature = 24,
                Humidity    = 90,
                AirPressure = 85
            };

            //Act
            var res = await _weatherController.PostWeatherLog(tempweatherlog);

            var got = await _weatherController.GetWeatherLog(4);

            //Assert
            Assert.Equal(90, got.Value.Humidity);

            Dispose();
        }
        public async Task GetWeatherLogById_SeededLogs_TempEqualTo24()
        {
            //Arrange
            _context = new ApplicationDbContext(
                new DbContextOptionsBuilder <ApplicationDbContext>().UseSqlite(CreateInMemoryDatabase()).Options);
            _mockHub           = Substitute.For <IHubContext <WeatherHub> >();
            _weatherController = new WeatherLogsController(_context, _mockHub);
            Seed();

            //Act
            ActionResult <WeatherLog> log = await _weatherController.GetWeatherLog(1);

            //Assert
            Assert.Equal(24, log.Value.Temperature);

            Dispose();
        }
        public async Task GetWeatherLogs_isEQToSeeded3()
        {
            //Arrange
            _context = new ApplicationDbContext(
                new DbContextOptionsBuilder <ApplicationDbContext>().UseSqlite(CreateInMemoryDatabase()).Options);
            _mockHub           = Substitute.For <IHubContext <WeatherHub> >();
            _weatherController = new WeatherLogsController(_context, _mockHub);
            Seed();

            //Act
            ActionResult <IEnumerable <WeatherLog> > logs = await _weatherController.GetWeatherLogs();

            //Assert
            Assert.Equal(3, logs.Value.Count());

            Dispose();
        }
        public async Task GetAllWeatherLogsForDate_SeededLogs()
        {
            //Arrange
            _context = new ApplicationDbContext(
                new DbContextOptionsBuilder <ApplicationDbContext>().UseSqlite(CreateInMemoryDatabase()).Options);
            _mockHub           = Substitute.For <IHubContext <WeatherHub> >();
            _weatherController = new WeatherLogsController(_context, _mockHub);
            Seed();

            //Act
            ActionResult <IEnumerable <WeatherLog> > logs = await _weatherController.GetAllWeatherLogsForDate(Convert.ToDateTime("2021, 10, 9"));

            //Assert
            Assert.Single(logs.Value);

            Dispose();
        }
        public void GetLastThreeWeatherLogs_SeededLogs3pcs()
        {
            //Arrange
            _context = new ApplicationDbContext(
                new DbContextOptionsBuilder <ApplicationDbContext>().UseSqlite(CreateInMemoryDatabase()).Options);
            _mockHub           = Substitute.For <IHubContext <WeatherHub> >();
            _weatherController = new WeatherLogsController(_context, _mockHub);
            Seed();

            //Act
            Task <ActionResult <IEnumerable <WeatherLog> > > logs = _weatherController.GetLastThreeWeatherLogs();

            var temp = logs.Result.Value.LongCount();

            //Assert
            Assert.Equal(3, temp);

            Dispose();
        }
        public async Task GetWeatherLogsForTimeframe_SeededLogs()
        {
            //Arrange
            _context = new ApplicationDbContext(
                new DbContextOptionsBuilder <ApplicationDbContext>().UseSqlite(CreateInMemoryDatabase()).Options);
            _mockHub           = Substitute.For <IHubContext <WeatherHub> >();
            _weatherController = new WeatherLogsController(_context, _mockHub);
            Seed();

            DateTime from = Convert.ToDateTime("2021, 10, 8");
            DateTime to   = Convert.ToDateTime("2021, 10, 10");

            //Act
            ActionResult <IEnumerable <WeatherLog> > logs = await _weatherController.GetWeatherLogsForTimeframe(from, to);

            //Assert
            Assert.Equal(2, logs.Value.Count());

            Dispose();
        }
        public WeatherLogControllerTestFixture()
        {
            _context = new ApplicationDbContext(
                new DbContextOptionsBuilder <ApplicationDbContext>().UseSqlite(CreateInMemoryDatabase()).Options);

            var settings = new AppSettings()
            {
                SecretKey = "ncSK45=)7@#qwKDSopevvkj3274687236"
            };

            _place = Substitute.For <Place>();

            _appSettings = Options.Create(settings);

            _mockHub = Substitute.For <IHubContext <WeatherHub> >();

            _weatherController = new WeatherLogsController(_context, _mockHub);

            Seed();
        }
 public WeatherLogControllerTest(WeatherLogControllerTestFixture ctrl) : base()
 {
     _fixture = ctrl;
     this._weatherController = ctrl._weatherController;
     this._context           = ctrl._context;
 }