public void TemperatureGet2Locations() { TemperatureController controller = new TemperatureController(); controller.Put("location1", "98.6"); controller.Put("location2", "32.0"); string result1 = controller.Get("location1"); string result2 = controller.Get("location2"); Assert.AreEqual("98.6", result1); Assert.AreEqual("32.0", result2); }
public void TestGetAllTemp() { IEnumerable <Temperature> tempList = _controller.Get(); Assert.AreEqual(70, tempList.Count()); Temperature temp = _controller.Get(1); Assert.AreEqual("1", temp.Id); temp = _controller.Get(8); Assert.IsNull(temp); }
public void GetLatestActionListisCorrect() { var connection = new SqliteConnection("Data Source=:memory:"); connection.Open(); var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseSqlite(connection) .Options; using (var context = new ApplicationDbContext(options)) { context.Database.EnsureCreated(); context.Temperatures.AddRange( new Temperature { TemperatureC = 25, Humidity = 10, Pressure = 30 }); context.SaveChanges(); var controller = new TemperatureController(null, context); var temp = controller.Get(1); Assert.Equal(25, temp.Result.Value.TemperatureC); } }
public void TemperatureGetUnknownLocation() { TemperatureController controller = new TemperatureController(); string results = controller.Get("!!!"); Assert.IsTrue(string.IsNullOrEmpty(results)); }
public async Task Get_WhenCalled_ReturnsOkResult() { mock.Setup(p => p.TemperatureConverter(1, "f", "c")).ReturnsAsync(12.222222222222223); temperatureController = new TemperatureController(mock.Object); var result = await temperatureController.Get(1, "f", "c"); Assert.IsType <OkObjectResult>(result); }
public async Task Get_BadRequest_ReturnsTemperatureConverterNull() { temperatureController = new TemperatureController(mock.Object); var result = await temperatureController.Get(1, "", ""); var ex = Assert.IsType <BadRequestObjectResult>(result); Assert.Equal("Temperature converter type cannot same", ex.Value); }
public async void TestGetTemperature_ReturnTempObjects() { // Arrange var temps = fixture.Create <TempDTO[]>(); tempReader.Setup(tr => tr.GetTempAllSensors()).Returns(Task.FromResult(temps.AsEnumerable())); // Act var result = await temperatureController.Get(); // Assert Assert.NotNull(result); OkObjectResult okObjResult = Assert.IsType <OkObjectResult>(result); Assert.Equal(200, okObjResult.StatusCode); Assert.NotNull(okObjResult.Value); Assert.IsType <TempDTO[]>(okObjResult.Value); }
public void TemperatureGet() { TemperatureController controller = new TemperatureController(); controller.Put("location", "98.6"); string result = controller.Get("location"); Assert.AreEqual("98.6", result); }
public void GetLatestWithNoParametersShouldReturnLatestTemperature() { Assert.AreEqual(_controller.Get().Taken, DateTime.Parse("1/6/2014 10:20:41 AM")); }