示例#1
0
        public void CreateMethodCreatesWordFileSuccesfully()
        {
            CurrentUser.user.username = "******";
            CreateWordFileService  fileService  = new CreateWordFileService();
            CreateFileBindingModel bindingModel = new CreateFileBindingModel();

            bindingModel.FileName = "gogo";
            bindingModel.DestPath = @"C:\Users\Nikih\Desktop\Resources";

            fileService.CreateWord(bindingModel);

            FileAssert.Exists(@"C:\Users\Nikih\Desktop\Resources\gogo.docx");
        }
示例#2
0
        private void CheckAndCreateFile(CreateFileBindingModel createFileBindingModel)
        {
            if (createFileBindingModel.TextButtonPressed == true)
            {
                string file = createFileBindingModel.DestPath + @"\" + $"{createFileBindingModel.FileName}.txt";
                if (!File.Exists(file))
                {
                    createTextFileService.Create(createFileBindingModel);
                    fileName = $"Created {createFileBindingModel.FileName}.txt successfully";
                    createFileBindingModel.FileType = "Text";
                    fileType = $"File type: {createFileBindingModel.FileType}";
                    createFileBindingModel.TextButtonPressed = false;

                    ShowCreatedFile(createFileBindingModel);
                }
                else
                {
                    fileName = $"File {createFileBindingModel.FileName}.txt already exists";
                    createFileBindingModel.TextButtonPressed = false;

                    ShowFileAlreadyExists();
                }
            }
            else if (createFileBindingModel.WordButtonPressed == true)
            {
                string file = createFileBindingModel.DestPath + @"\" + $"{createFileBindingModel.FileName}.docx";
                if (!File.Exists(file))
                {
                    createWordFileService.CreateWord(createFileBindingModel);
                    fileName = $"Created {createFileBindingModel.FileName}.docx successfully";
                    createFileBindingModel.FileType = "Document";
                    fileType = $"File type: {createFileBindingModel.FileType}";
                    createFileBindingModel.WordButtonPressed = false;

                    ShowCreatedFile(createFileBindingModel);
                }
                else
                {
                    fileName = $"File {createFileBindingModel.FileName}.docx already exists";
                    createFileBindingModel.WordButtonPressed = false;

                    ShowFileAlreadyExists();
                }
            }
            else if (createFileBindingModel.PowerPointButtonPressed == true)
            {
                string file = createFileBindingModel.DestPath + @"\" + $"{createFileBindingModel.FileName}.pptx";
                if (!File.Exists(file))
                {
                    createPowerPointFileService.CreatePowerPoint(createFileBindingModel);
                    fileName = $"Created {createFileBindingModel.FileName}.pptx successfully";
                    createFileBindingModel.FileType = "Presentation";
                    fileType = $"File type: {createFileBindingModel.FileType}";
                    createFileBindingModel.PowerPointButtonPressed = false;

                    ShowCreatedFile(createFileBindingModel);
                }
                else
                {
                    fileName = $"File {createFileBindingModel.FileName}.pptx already exists";
                    createFileBindingModel.PowerPointButtonPressed = false;

                    ShowFileAlreadyExists();
                }
            }
            else if (createFileBindingModel.ExcelButtonPressed == true)
            {
                string file = createFileBindingModel.DestPath + @"\" + $"{createFileBindingModel.FileName}.xlsx";
                if (!File.Exists(file))
                {
                    createExcelFileService.CreateExcel(createFileBindingModel);
                    fileName = $"Created {createFileBindingModel.FileName}.xlsx successfully";
                    createFileBindingModel.FileType = "Excel Worksheet";
                    fileType = $"File type: {createFileBindingModel.FileType}";
                    createFileBindingModel.ExcelButtonPressed = false;

                    ShowCreatedFile(createFileBindingModel);
                }
                else
                {
                    fileName = $"File {createFileBindingModel.FileName}.xlsx already exists";
                    createFileBindingModel.ExcelButtonPressed = false;

                    ShowFileAlreadyExists();
                }
            }
            else if (createFileBindingModel.RarButtonPressed == true)
            {
                string file = createFileBindingModel.DestPath + @"\" + $"{createFileBindingModel.FileName}.rar";
                if (!File.Exists(file))
                {
                    createRartFileService.CreateRar(createFileBindingModel);
                    fileName = $"Created {createFileBindingModel.FileName}.rar successfully";
                    createFileBindingModel.FileType = "Rar Archive";
                    fileType = $"File type: {createFileBindingModel.FileType}";
                    createFileBindingModel.RarButtonPressed = false;

                    ShowCreatedFile(createFileBindingModel);
                }
                else
                {
                    fileName = $"File {createFileBindingModel.FileName}.rar already exists";
                    createFileBindingModel.RarButtonPressed = false;

                    ShowFileAlreadyExists();
                }
            }
            else
            {
                return;
            }
        }