示例#1
0
        public void MyTestInitialize()
        {
            _mockFileInfo   = new Mock <IFileInfoWrap>();
            _mockFileStream = new Mock <IFileStreamWrap>();
            _mockFile       = new Mock <IFileWrap>();
            _mockPath       = new Mock <IPathWrap>();

            _mockFileInfo.Setup(a => a.OpenRead()).Returns(_mockFileStream.Object);
            fh = new FileProcessHandler(_mockFile.Object, _mockPath.Object, _mockFileInfo.Object);

            _rawData =
                @"FirstName,LastName,Address,PhoneNumber
                        Joseph,Sharma,102 Long Lane,29384857
                        CALVIN,Omkar,65 Ambling Way,31214788";
        }
示例#2
0
        /// <summary>
        /// Excecutes the specified deploy entity.
        /// </summary>
        /// <param name="deployEntity">The deploy entity.</param>
        public void Excecute(dynamic deployEntity)
        {
            //typecasting dynamic model to ServiceDetailsModel
            var serviceDetailsModel = (ServerDetailsModel)deployEntity;

            //get the instance of FileProcess handler class
            var fileProcessHandler = new FileProcessHandler();

            //process XCOPY function
            fileProcessHandler.ProcessXcopy(serviceDetailsModel);

            //delete the old file
            fileProcessHandler.DeleteOldFile(serviceDetailsModel);

            //replace the config file
            fileProcessHandler.ReplaceConfigFile(serviceDetailsModel);
        }
        /// <summary>
        /// Posts the specified promote code.
        /// </summary>
        /// <param name="promoteCode">The promote code.</param>
        /// <returns></returns>
        public async Task <HttpResponseMessage> Post(PromoteCodeModel promoteCode)
        {
            if (String.IsNullOrEmpty(promoteCode.Region))
            {
                return(base.Request.CreateResponse(HttpStatusCode.BadRequest, "Please specify the region!"));
            }

            string sourceFileName = SelectSourceAndDestination(promoteCode);

            var serverDetails = new ConfigFileReader().ReadConfigFile(new ServerDetailsModel
            {
                Region = promoteCode.Region
            });

            serverDetails.SourceFileName = sourceFileName;

            //copy destination location to a private variable
            this.DestinationLocation = serverDetails.DestinationFileLocation;

            if (!Directory.Exists(serverDetails.DestinationFileLocation))
            {
                Directory.CreateDirectory(serverDetails.DestinationFileLocation);
            }

            var fileProcess = new FileProcessHandler();

            //Call a method to perform Xcopy
            fileProcess.ProcessXcopy(serverDetails);
            fileProcess.DeleteOldFile(serverDetails);
            fileProcess.ReplaceConfigFile(serverDetails);

            //perform the deployment to all servers deployment
            foreach (var server in serverDetails.ServerList)
            {
                await MoveCodeToServer(server);
            }

            return(Request.CreateResponse(HttpStatusCode.Created, "Deployment Completed"));
        }