public void GetSeleniumConfigById_Found_iOS() { var device = new Device(_device1.Id, _device1.Name, true, DeviceType.IOS, DeviceStatus.Online); const string version = "12.1"; var deviceProperties = new List <DeviceProperties> { new DeviceProperties("ProductVersion", version), new DeviceProperties("Version", "11.1") }; device.Properties = deviceProperties; // Arrange var mockRepository = new Mock <IRepository <Device> >(); mockRepository.Setup(repo => repo.Find(device.Id)) .Returns(device); var mockLogger = new Mock <IManagerLogger>(); var mockConfiguration = new Mock <IManagerConfiguration>(); var controller = new DevicesController(mockRepository.Object, mockLogger.Object, mockConfiguration.Object, null, null, _externalProcesses); // Act var result = controller.GetSeleniumConfigById(device.Id); // Assert var viewResult = Assert.IsType <JsonResult>(result); Assert.Contains(_device1.Id, viewResult.Value.ToString()); Assert.Contains($"deviceVersion = {version}", viewResult.Value.ToString()); Assert.Contains("teamId", viewResult.Value.ToString()); }
public void GetSeleniumConfigById_DeviceNotFound() { var device = new Device(_device1.Id, _device1.Name, true, DeviceType.IOS, DeviceStatus.Online); // Arrange var mockRepository = new Mock <IRepository <Device> >(); mockRepository.Setup(repo => repo.Find(device.Id)) .Returns((Device)null); var mockLogger = new Mock <IManagerLogger>(); var mockConfiguration = new Mock <IManagerConfiguration>(); var controller = new DevicesController(mockRepository.Object, mockLogger.Object, mockConfiguration.Object, null, null, _externalProcesses); // Act var result = controller.GetSeleniumConfigById(device.Id); // Assert Assert.IsType <NotFoundObjectResult>(result); }
public void GetSeleniumConfigById_Unspecified() { var device = new Device(_device1.Id, _device1.Name, true, DeviceType.Unspecified, DeviceStatus.Online); // Arrange var mockRepository = new Mock <IRepository <Device> >(); mockRepository.Setup(repo => repo.Find(device.Id)) .Returns(device); var mockLogger = new Mock <IManagerLogger>(); var mockConfiguration = new Mock <IManagerConfiguration>(); var controller = new DevicesController(mockRepository.Object, mockLogger.Object, mockConfiguration.Object, null, null, _externalProcesses); // Act var result = controller.GetSeleniumConfigById(device.Id); // Assert var viewResult = Assert.IsType <JsonResult>(result); Assert.Equal("Unsupported device type", viewResult.Value); }
public void GetSeleniumConfigById_Found_Android() { var device = new Device(_device1.Id, _device1.Name, true, DeviceType.Android, DeviceStatus.Online); // Arrange var mockRepository = new Mock <IRepository <Device> >(); mockRepository.Setup(repo => repo.Find(device.Id)) .Returns(device); var mockLogger = new Mock <IManagerLogger>(); var mockConfiguration = new Mock <IManagerConfiguration>(); var controller = new DevicesController(mockRepository.Object, mockLogger.Object, mockConfiguration.Object, null, null, _externalProcesses); // Act var result = controller.GetSeleniumConfigById(device.Id); // Assert var viewResult = Assert.IsType <JsonResult>(result); Assert.Contains(_device1.Id, viewResult.Value.ToString()); Assert.Contains("platformName = android", viewResult.Value.ToString()); }