コード例 #1
0
        public void TemplateService_GetAll_CallsRepositoryAll()
        {
            #region Arrange

            #endregion

            #region Act

            _templateService.All();

            #endregion

            #region Assert

            _mockTemplateRepository.Verify(x => x.All(), Times.Once);

            #endregion
        }
コード例 #2
0
        public void Execute(string serviceDecompositionFilePath, string filename, int templateType)
        {
            // Set the license for Aspose
            var license = new License();

            license.SetLicense("Aspose.Total.lic");

            if (serviceDecompositionFilePath == null)
            {
                throw new ArgumentNullException(nameof(serviceDecompositionFilePath));
            }

            if (filename == null)
            {
                throw new ArgumentNullException(nameof(filename));
            }

            if (!Enum.IsDefined(typeof(TemplateType), templateType))
            {
                throw new ArgumentException(nameof(templateType));
            }

            if (!FileExists(serviceDecompositionFilePath))
            {
                throw new FileNotFoundException(serviceDecompositionFilePath);
            }

            if (templateType == TemplateTypeNames.SORT.GetEnumIntFromText <TemplateType>() && _templateService.All().Any(x => x.TemplateType == TemplateTypeNames.SORT.GetEnumIntFromText <TemplateType>()))
            {
                throw new DataImportException("A SORT Service Decomposition Template already exists, please delete before importing a new SORT spreadsheet.");
            }

            // Read the contents of Service Decomposition spreadsheet (This will have been uploaded via the Web UI)
            var importResults = _serviceDecompositionTemplateImporter.ImportSpreadsheet(serviceDecompositionFilePath);


            if (importResults.ValidationResults.Count > 0)
            {
                throw new DataImportException(
                          $"Error reading Service Decomposition Template spreadsheet ({filename}) - ", importResults.ValidationResults);
            }

            if (importResults.Results.Count == 0)
            {
                throw new DataImportException(
                          $"Error reading Service Decomposition Template spreadsheet ({filename}) - Spreadsheet does not contain any valid data.");
            }

            var template = CreateTemplate(serviceDecompositionFilePath, filename, templateType);

            _transformSpreadsheetToTemplate.Transform(template, importResults.AsTemplateRows());

            _templateService.Create(template);
        }