public IDeployer GetDeployer(string deployerKey, Dictionary <string, string> properties)
        {
            var file = HostingEnvironment.MapPath(FileLocation);

            if (!File.Exists(file))
            {
                var backupFactory = new DeployerFactory();
                return(backupFactory.GetDeployer(deployerKey, properties));
            }

            try
            {
                var config   = JsonConvert.DeserializeObject <Config>(File.ReadAllText(file));
                var deployer = config?.deployers?.FirstOrDefault(et => et?.id == deployerKey);

                if (deployer?.deployer == null)
                {
                    throw new Exception("Deployer not set");
                }

                var typeName = deployer?.deployer;
                var type     = Type.GetType(typeName);

                var instance = Activator.CreateInstance(type, properties) as IDeployer;
                return(instance);
            }
            catch
            {
                throw new Exception("Deployer creation exception.");
            }
        }
        public DeviceBridge(string desiredDeviceName, string ipAddress, string localeTag, bool captureCodedUiLogs)
        {
            this.Culture = new CultureInfo(localeTag);

            this.deployer = DeployerFactory.DeployerForPackage(null, desiredDeviceName, false, this.Culture);

            this.GetIpAddress(ipAddress);

            this.captureCodedUiLogs = captureCodedUiLogs;
        }
Exemplo n.º 3
0
        public void RequiesBuildCreatesMSBuildDeployer()
        {
            var environment = new Mock <IEnvironment>();

            environment.Setup(m => m.RequiresBuild).Returns(true);
            var deployerFactory = new DeployerFactory(environment.Object);

            IDeployer deployer = deployerFactory.CreateDeployer();

            Assert.IsType(typeof(MSBuildDeployer), deployer);
        }
Exemplo n.º 4
0
        public void WhenRequiesBuildFalseCreatesBasicDeployer()
        {
            var environment = new Mock <IEnvironment>();

            environment.Setup(m => m.RequiresBuild).Returns(false);
            var deployerFactory = new DeployerFactory(environment.Object);

            IDeployer deployer = deployerFactory.CreateDeployer();

            Assert.IsType(typeof(BasicDeployer), deployer);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            string repositoryPath = Path.Combine(Root, RepositoryPath);
            string deployPath     = Path.Combine(Root, DeploymentTargetPath);
            string buildPath      = Path.Combine(Root, BuildOutputPath);

            var environment = new Environment(repositoryPath, deployPath, buildPath);

            var repositoryManager = new RepositoryManager(environment.RepositoryPath);
            var deployerFactory   = new DeployerFactory(environment);
            var deploymentManager = new DeploymentManager(repositoryManager, deployerFactory);
            var fileSystemFactory = new FileSystemFactory(environment);

            kernel.Bind <IRepositoryManager>().ToConstant(repositoryManager);
            kernel.Bind <IDeployerFactory>().ToConstant(deployerFactory);
            kernel.Bind <IDeploymentManager>().ToConstant(deploymentManager);
            kernel.Bind <IFileSystemFactory>().ToConstant(fileSystemFactory);
            kernel.Bind <ServerRepository>().ToMethod(_ => new ServerRepository(repositoryPath));
        }
Exemplo n.º 6
0
        private void InitializeDeployer()
        {
            var strictMatchDeviceName = Capabilities.BoundDeviceName != null;

            if (strictMatchDeviceName)
            {
                if (Capabilities.BoundDeviceName.StartsWith(
                        this.ActualCapabilities.DeviceName,
                        StringComparison.OrdinalIgnoreCase))
                {
                    this.ActualCapabilities.DeviceName = Capabilities.BoundDeviceName;
                }
                else
                {
                    throw new AutomationException(
                              string.Format(
                                  "Driver was bound to '{0}' at launch with --bound-device-name option, but another device '{1}' was requested by session.",
                                  Capabilities.BoundDeviceName,
                                  this.ActualCapabilities.DeviceName));
                }
            }

            var appFileInfo = new FileInfo(this.ActualCapabilities.App);

            this.Deployer = DeployerFactory.DeployerForPackage(
                appFileInfo,
                this.ActualCapabilities.DeviceName,
                strictMatchDeviceName);

            if (!this.ActualCapabilities.DeviceName.Equals(this.Deployer.DeviceName, StringComparison.OrdinalIgnoreCase))
            {
                Logger.Warn(
                    "Device was found using partail deviceName '{0}',"
                    + " this behavior might be deprecated in favor of specifying strict deviceName or platformVersion (when implemented).",
                    this.ActualCapabilities.DeviceName);
            }
        }