public void RetrieveDevicesFromBackend() { RestService restService = new RestService(new HttpClient(fakeDevicesHandler), mockTokenAcquisition, mockConfiguration); MapViewController mapViewController = new MapViewController(restService); ViewResult result = (ViewResult)mapViewController.Index().Result; MapViewModel resultWrapper = (MapViewModel)result.Model; Assert.Equal(2, resultWrapper.LifeCycleManagers.Count(l => l.ConnectionState.Equals("Connected"))); Assert.Single(resultWrapper.LifeCycleManagers.Where(l => l.ConnectionState.Equals("Disconnected"))); }
public void ExceptionWithoutConnection() { FakeResponseHandler noConnectionHandler = new FakeResponseHandler(); noConnectionHandler.AddFakeException( new Uri($"{ApplicationURLS.Backend}/api/devices"), new AggregateException()); RestService restService = new RestService(new HttpClient(noConnectionHandler), mockTokenAcquisition, mockConfiguration); MapViewController mapViewController = new MapViewController(restService) { ControllerContext = new ControllerContext { HttpContext = new DefaultHttpContext() } }; Assert.ThrowsAsync <AggregateException>(() => mapViewController.Index()); }