public async void AddDeviceCreateTest() { var button = _fixture.Create <string>(); var deviceModel = _fixture.Create <UnregisteredDeviceModel>(); var devices = _fixture.Create <DeviceListQueryResult>(); var iccids = _fixture.Create <List <string> >(); _apiRegistrationRepository.Setup(repo => repo.IsApiRegisteredInAzure()).Returns(true); _deviceLogicMock.Setup(mock => mock.GetDevices(It.IsAny <DeviceListQuery>())).ReturnsAsync(devices); _deviceLogicMock.Setup(mock => mock.GetDeviceAsync(It.IsAny <string>())).ReturnsAsync(new DeviceModel()); var result = await _deviceController.AddDeviceCreate(button, deviceModel); var viewResult = result as PartialViewResult; var model = viewResult.Model as UnregisteredDeviceModel; var viewBag = viewResult.ViewBag; Assert.True(viewBag.CanHaveIccid); Assert.Equal(model, deviceModel); }