public void TestForCorrectReturns() { var mock = new Mock <IWeatherStationCrud>(); var fakehub = new Mock <IHubContext <Updates> >(); mock.Setup(mock => mock.Get()) .Returns(GetTestWeatherForecast); var controller = new WeatherForecastsController(mock.Object, fakehub.Object); //uut var listOfTest = controller.Get("Testing for day: number 1"); //Assert Assert.Collection(listOfTest, item => Assert.Contains("Testing for day: number 1", item.Id)); }
public async Task DisplayAllForecasts() { var repo = new MockWeatherRepository(); var controller = new WeatherForecastsController(repo, null); var result = await controller.Index(); Assert.IsInstanceOfType(result, typeof(ViewResult)); var expected = (await repo.GetAllAsync()).ToList(); var model = (result as ViewResult).ViewData.Model; Assert.IsInstanceOfType(model, typeof(List <WeatherForecast>)); var actual = (List <WeatherForecast>)model; Assert.IsTrue(actual.SequenceEqual(expected)); }
public void Setup() { _hubContext = Substitute.For <IHubContext <MeasurementHub> >(); _unit = Substitute.For <IUnitOfWork>(); _uut = new WeatherForecastsController(_unit, _hubContext); }