示例#1
0
 private void DataImportType_ItemCheck(object sender, ItemCheckEventArgs e)
 {
     for (int ix = 0; ix < DataImportType.Items.Count; ++ix)
     {
         if (ix != e.Index)
         {
             DataImportType.SetItemChecked(ix, false);
         }
     }
 }
        public static string GetFileExtensionType(this DataImportType importFileType)
        {
            var memInfo = importFileType.GetType().GetTypeInfo().GetDeclaredField(importFileType.ToString());

            var attribute = memInfo?.GetCustomAttributes(true).Single(attributeType => attributeType is FileExtensionsAttribute);

            if (attribute != null)
            {
                return(typeof(FileExtensionsAttribute)
                       .GetProperty("Extensions")
                       ?.GetValue(attribute)
                       ?.ToString());
            }

            return(null);
        }
示例#3
0
        public async Task Then_The_Correct_Error_Message_Is_Displayed(string fileName, string fileContentType, string fileContent, DataImportType importType, string errorMessage, int errorSummaryIndex)
        {
            var client       = _factory.CreateClient();
            var pageResponse = await client.GetAsync("/DataImport");

            var pageContent = await HtmlHelpers.GetDocumentAsync(pageResponse);

            var file = Substitute.For <IFile>();

            file.Name.Returns(fileName);
            file.Type.Returns(fileContentType);
            file.Body.Returns(fileContent != null
                ? new MemoryStream(Encoding.UTF8.GetBytes(fileContent))
                : null);

            var input = (IHtmlInputElement)pageContent.QuerySelector("input[type=file][name=File]");

            input?.Files.Add(file);

            var response = await client.SendAsync(
                (IHtmlFormElement)pageContent.QuerySelector("form"),
                (IHtmlButtonElement)pageContent.GetElementById("tl-upload"),
                new Dictionary <string, string>
            {
                ["SelectedImportType"] = importType.ToString()
            });

            Assert.Equal(HttpStatusCode.OK, pageResponse.StatusCode);

            response.EnsureSuccessStatusCode();

            var responseContent = await HtmlHelpers.GetDocumentAsync(response);

            var errorSummaryList = responseContent.QuerySelector(".govuk-error-summary div ul");

            errorSummaryList.Children[errorSummaryIndex].TextContent.Should().Be(errorMessage);

            AssertError(responseContent, "File", errorMessage);

            Assert.Null(response.Headers.Location?.OriginalString);
        }
        public void GetFileExtensionTypeDataTests(DataImportType importType, string result)
        {
            var extensionType = importType.GetFileExtensionType();

            extensionType.Should().Be(result);
        }
        /// <summary>
        /// Test Method for BulkSend
        /// </summary>
        /// <returns></returns>
        private static string BulkSend(string batchId, string bulkSendId, int contentId, string filePath, string tenantAccountId, BulkSendEmailType bulkSendEmailType, bool isSendInvoke, bool isDynamicDataExtension, bool isOverrideConfiguration, DataImportType dataImportType, string dynamicDataExtensionTemplateName)
        {
            //"b480ee7d-2444-4f37-ba6d-db279b87b60a","b480ee7d-2444-4f37-ba6d-db279b87b60a",@"D:\Usr\ShankarBaradwaj\MslMailerBulkSendList-20150313-255746814.tsv","10290011",BulkSendEmailType.Transactional,true, true,true,DataImportType.AddAndUpdate,"MSL Email Campaigns DE"
            var fileRequest = new FileRequest()
            {
                BatchId                          = batchId,
                BulkSendId                       = bulkSendId,
                ContentId                        = contentId,
                FilePath                         = filePath,
                TenantAccountId                  = tenantAccountId,
                BulkSendEmailType                = bulkSendEmailType,
                IsSendInvoke                     = isSendInvoke,
                IsDynamicDataExtension           = isDynamicDataExtension,
                IsOverrideConfiguration          = isOverrideConfiguration,
                DataImportType                   = dataImportType,
                DynamicDataExtensionTemplateName = dynamicDataExtensionTemplateName
            };

            var azureTBNClient = new AzureTBNClientSDK.InterchangeConnect();
            var filesendResult = azureTBNClient.SendFileRequest(fileRequest);

            return(filesendResult.Result + "; EI ID: '" + filesendResult.EmailInterchangeId + "'");
        }