Ejemplo n.º 1
0
        private ICommand CreateCommandChain(DeploymentItem item)
        {
            var itemContext = CreateContext(item);

            ICommand command;

            if (item.RemoveApplicationFirst)
            {
                var command6 = new UpgradeApplicationCommand(itemContext);
                var command5 = new CreateApplicationCommand(itemContext);
                var command4 = new ApplicationDeploymentCommand(itemContext, command5, command6);
                var command3 = new CreateApplicationTypeCommand(itemContext, command4);
                var command2 = new CopyImageToStoreCommand(itemContext, command3);
                command = new RemoveApplicationTypeCommand(itemContext, command2);
            }
            else
            {
                var command5 = new UpgradeApplicationCommand(itemContext);
                var command4 = new CreateApplicationCommand(itemContext);
                var command3 = new ApplicationDeploymentCommand(itemContext, command4, command5);
                var command2 = new CreateApplicationTypeCommand(itemContext, command3);
                command = new CopyImageToStoreCommand(itemContext, command2);
            }

            return(command);
        }
        public RemoveApplicationTypeCommandTests()
        {
            _appClient     = new Mock <IApplicationClient>();
            _appTypeClient = new Mock <IApplicationTypeClient>();
            _innerCommand  = new Mock <ICommand>();
            var fabricClient = new Mock <IServiceFabricClient>();

            fabricClient.Setup(c => c.Applications).Returns(_appClient.Object);
            fabricClient.Setup(c => c.ApplicationTypes).Returns(_appTypeClient.Object);
            _item = new DeploymentItem {
                ApplicationTypeName = "AppType", ApplicationId = "app"
            };
            var context = new CommandContext
            {
                FabricClient          = fabricClient.Object,
                Logger                = Logger.Object,
                CurrentDeploymentItem = _item
            };

            _command = new RemoveApplicationTypeCommand(context, _innerCommand.Object);
        }