public async Task GetWeatherBetweenDate() { using (var context = new ApplicationDbContext(_options)) { context.Database.EnsureCreated(); _uut = new WeatherObservationController(context, _hub); var result = _uut.BetweenDateGet("04-05-2020", "11-06-2020"); Assert.Equal("USA", result.Value.FirstOrDefault().LocationName); } }
public void GetThreeWeatherObservations() { using (var context = new ApplicationDbContext(_options)) { context.Database.EnsureCreated(); _uut = new WeatherObservationController(context, _hub); var result = _uut.GetThree(); Assert.Equal(3, result.Count()); } }
public async Task UploadWeatherObservation() { using (var context = new ApplicationDbContext(_options)) { context.Database.EnsureCreated(); int initial = context.WeatherObservations.ToList().Count; _uut = new WeatherObservationController(context, _hub); DTOWeatherObservation entry = new DTOWeatherObservation() { TimeOfDay = DateTime.Now, LocationName = "USA", Temperature = 50, AirPressure = 5, AirHumidity = 10, LocationRefId = 1 }; await _uut.UploadWeatherObservation(entry); Assert.Equal(initial + 1, context.WeatherObservations.ToList().Count); } }
public async Task GetWeatherObservationFromDateGet1() { using (var context = new ApplicationDbContext(_options)) { context.Database.EnsureCreated(); _uut = new WeatherObservationController(context, _hub); DTOWeatherObservation entry = new DTOWeatherObservation() { TimeOfDay = new DateTime(2020, 05, 06, 00, 00, 00), LocationName = "USA", Temperature = 50, AirPressure = 5, AirHumidity = 10, LocationRefId = 1 }; await _uut.UploadWeatherObservation(entry); var result = _uut.DateGet("06-05-2020"); Assert.Equal("USA", result.Value.FirstOrDefault().LocationName); } }
public UnitTests() { var options = new DbContextOptionsBuilder <AppDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; _context = new AppDbContext(options); _context.Database.EnsureCreated(); //IHubContext _fakeHubContext = Substitute.For <IHubContext <SubscribeHub> >(); _uut = new WeatherObservationController(_context, _fakeHubContext); _listOfWeatherObservations = new List <WeatherObservation>(); _locationAr = new Location[10]; _locationAr[0] = new Location { Latitude = 100, Longitude = 100, Name = "Horsens" }; _locationAr[1] = new Location { Latitude = 200, Longitude = 200, Name = "Aarhus" }; _locationAr[2] = new Location { Latitude = 300, Longitude = 300, Name = "Herning" }; _locationAr[3] = new Location { Latitude = 400, Longitude = 400, Name = "Hedensted" }; _locationAr[4] = new Location { Latitude = 500, Longitude = 500, Name = "Randers" }; _locationAr[5] = new Location { Latitude = 600, Longitude = 600, Name = "Koebenhavn" }; _locationAr[6] = new Location { Latitude = 700, Longitude = 700, Name = "Haderslev" }; _locationAr[7] = new Location { Latitude = 800, Longitude = 800, Name = "Viborg" }; _locationAr[8] = new Location { Latitude = 900, Longitude = 900, Name = "Skive" }; _locationAr[9] = new Location { Latitude = 1000, Longitude = 1000, Name = "Aalborg" }; for (int i = 0; i < 10; i++) { var wo = new WeatherObservation { AirPressure = i, Date = DateTime.Now, Humidity = i + 5, Location = _locationAr[i], TemperatureC = i + 10, WeatherObservationId = i + 100 }; _listOfWeatherObservations.Add(wo); } }
public void setup() { _options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase(databaseName: "Test").Options; _context = new ApplicationDbContext(_options); _uut = new WeatherObservationController(_context, _hub); }
public void Setup() { _weatherObservationRepository = Substitute.For <IWeatherObservationRepository>(); _hubContext = Substitute.For <IHubContext <LiveUpdateHub> >(); _uut = new WeatherObservationController(_weatherObservationRepository, _hubContext); }