using CTA.WebForms.Helpers; using CTA.WebForms.Helpers.TagConversion; using CTA.WebForms.Services; using CTA.WebForms.TagConverters; using HtmlAgilityPack; using NUnit.Framework; using System.Collections.Generic; using System.Threading.Tasks; namespace CTA.WebForms.Tests.TagConfigs { [TestFixture] public class AspControlTests : TagConfigsTestFixture { [Test] public async Task AspBoundField_Is_Properly_Converted() { var inputText = @" Some text... "; var expectedOutput = @" Some text... "; expectedOutput = expectedOutput.Trim().Replace("\r\n", "\n"); var output = (await GetConverterOutput(inputText)).Trim().Replace("\r\n", "\n"); Assert.AreEqual(expectedOutput, output); Assert.True(_viewImportService.ViewUsingDirectives.Contains("@using BlazorWebFormsComponents")); } [Test] public async Task AspButton_Is_Properly_Converted() { var inputText = @""; var expectedOutput = @""; expectedOutput = expectedOutput.Trim().Replace("\r\n", "\n"); var output = (await GetConverterOutput(inputText)).Trim().Replace("\r\n", "\n"); Assert.AreEqual(expectedOutput, output); } [Test] public async Task AspButtonField_Is_Properly_Converted() { var inputText = @" Some text... "; var expectedOutput = @" Some text... "; expectedOutput = expectedOutput.Trim().Replace("\r\n", "\n"); var output = (await GetConverterOutput(inputText)).Trim().Replace("\r\n", "\n"); Assert.AreEqual(expectedOutput, output); Assert.True(_viewImportService.ViewUsingDirectives.Contains("@using BlazorWebFormsComponents")); } [Test] public async Task AspContent_Is_Properly_Removed() { var inputText = @"

Section

Sub-Section

Content, content, content, content...

"; var expectedOutput = @"

Section

Sub-Section

Content, content, content, content...

"; expectedOutput = expectedOutput.Trim().Replace("\r\n", "\n"); var output = (await GetConverterOutput(inputText)).Trim().Replace("\r\n", "\n"); Assert.AreEqual(expectedOutput, output); } [Test] public async Task AspContentPlaceHolder_Is_Properly_Converted() { var inputText = ""; var expectedOutput = "@Body"; expectedOutput = expectedOutput.Trim().Replace("\r\n", "\n"); var output = (await GetConverterOutput(inputText)).Trim().Replace("\r\n", "\n"); Assert.AreEqual(expectedOutput, output); } [Test] public async Task AspGridView_Is_Properly_Converted() { var inputText = @" ...Column stuff... "; var expectedOutput = @" DataBindingEventHandler(null, args)"" OnDataBound=""(args) => DataBoundEventHandler(null, args)"" OnItemDataBound=""(args) => OnRowDataBoundEventHandler(null, args)"" OnInit=""(args) => OnInitEventHandler(null, args)"" OnLoad=""(args) => OnLoadEventHandler(null, args)"" OnPreRender=""(args) => OnPreRenderEventHandler(null, args)"" OnUnload=""(args) => OnUnloadEventHandler(null, args)"" OnDisposed=""(args) => OnDisposedEventHandler(null, args)"" TabIndex=""0"" Visible=""True""> ...Column stuff... "; expectedOutput = expectedOutput.Trim().Replace("\r\n", "\n"); var output = (await GetConverterOutput(inputText)).Trim().Replace("\r\n", "\n"); Assert.AreEqual(expectedOutput, output); } [Test] public async Task AspHyperLink_With_InnerHtml_Is_Properly_Converted() { var inputText = @" Some text... "; var expectedOutput = @" Some text... "; expectedOutput = expectedOutput.Trim().Replace("\r\n", "\n"); var output = (await GetConverterOutput(inputText)).Trim().Replace("\r\n", "\n"); Assert.AreEqual(expectedOutput, output); } [Test] public async Task AspHyperLink_With_Text_Is_Properly_Converted() { var inputText = @""; var expectedOutput = @" Some text... "; expectedOutput = expectedOutput.Trim().Replace("\r\n", "\n"); var output = (await GetConverterOutput(inputText)).Trim().Replace("\r\n", "\n"); Assert.AreEqual(expectedOutput, output); } [Test] public async Task AspHyperLinkField_Is_Properly_Converted() { var inputText = @" Some text... "; var expectedOutput = @" Some text... "; expectedOutput = expectedOutput.Trim().Replace("\r\n", "\n"); var output = (await GetConverterOutput(inputText)).Trim().Replace("\r\n", "\n"); Assert.AreEqual(expectedOutput, output); Assert.True(_viewImportService.ViewUsingDirectives.Contains("@using BlazorWebFormsComponents")); } [Test] public async Task AspLabel_With_InnerHtml_Is_Properly_Converted() { var inputText = @" Some text... "; var expectedOutput = @""; expectedOutput = expectedOutput.Trim().Replace("\r\n", "\n"); var output = (await GetConverterOutput(inputText)).Trim().Replace("\r\n", "\n"); Assert.AreEqual(expectedOutput, output); } [Test] public async Task AspLabel_With_Text_Is_Properly_Converted() { var inputText = @""; var expectedOutput = @""; expectedOutput = expectedOutput.Trim().Replace("\r\n", "\n"); var output = (await GetConverterOutput(inputText)).Trim().Replace("\r\n", "\n"); Assert.AreEqual(expectedOutput, output); } [Test] public async Task AspListView_Is_Properly_Converted() { var inputText = @" ...LayoutTemplateContent... ...ItemTemplateContent... "; var expectedOutput = @" OnDataBindingEventHandler(null, args)"" OnDataBound=""(args) => OnDataBoundEventHandler(null, args)"" OnDisposed=""(args) => OnDisposedEventHandler(null, args)"" OnInit=""(args) => OnInitEventHandler(null, args)"" OnItemDataBound=""(args) => OnItemDataBoundEventHandler(null, args)"" OnLayoutCreated=""(args) => OnLayoutCreatedEventHandler(null, args)"" OnLoad=""(args) => OnLoadEventHandler(null, args)"" OnPreRender=""(args) => OnPreRenderEventHandler(null, args)"" OnUnload=""(args) => OnUnloadEventHandler(null, args)"" SelectedIndex=""0"" Style=""StyleAttr0=Value0"" TabIndex=""23"" Visible=""True""> ...LayoutTemplateContent... ...ItemTemplateContent... "; expectedOutput = expectedOutput.Trim().Replace("\r\n", "\n"); var output = (await GetConverterOutput(inputText)).Trim().Replace("\r\n", "\n"); Assert.AreEqual(expectedOutput, output); Assert.True(_viewImportService.ViewUsingDirectives.Contains("@using BlazorWebFormsComponents")); } [Test] public async Task AspPlaceHolder_Is_Properly_Converted() { var inputText = @""; var expectedOutput = @"@PlaceHolderId"; expectedOutput = expectedOutput.Trim().Replace("\r\n", "\n"); var output = (await GetConverterOutput(inputText)).Trim().Replace("\r\n", "\n"); Assert.AreEqual(expectedOutput, output); } [Test] public async Task AspRadioButton_Is_Properly_Converted_With_Label() { var inputText = @""; var expectedOutput = @" "; expectedOutput = expectedOutput.Trim().Replace("\r\n", "\n"); var output = (await GetConverterOutput(inputText)).Trim().Replace("\r\n", "\n"); Assert.AreEqual(expectedOutput, output); } [Test] public async Task AspRadioButton_Is_Properly_Converted_Without_Label() { var inputText = @""; var expectedOutput = @""; expectedOutput = expectedOutput.Trim().Replace("\r\n", "\n"); var output = (await GetConverterOutput(inputText)).Trim().Replace("\r\n", "\n"); Assert.AreEqual(expectedOutput, output); } [Test] public async Task AspTemplateField_Is_Properly_Converted() { var inputText = @" Some text... "; var expectedOutput = @" Some text... "; expectedOutput = expectedOutput.Trim().Replace("\r\n", "\n"); var output = (await GetConverterOutput(inputText)).Trim().Replace("\r\n", "\n"); Assert.AreEqual(expectedOutput, output); Assert.True(_viewImportService.ViewUsingDirectives.Contains("@using BlazorWebFormsComponents")); } [Test] public async Task AspTextBox_Is_Properly_Converted_To_TextArea() { var inputText = @" "; var expectedOutput = @""; expectedOutput = expectedOutput.Trim().Replace("\r\n", "\n"); var output = (await GetConverterOutput(inputText)).Trim().Replace("\r\n", "\n"); Assert.AreEqual(expectedOutput, output); } [Test] public async Task AspTextBox_Is_Properly_Converted_To_Password_Input() { var inputText = @" "; var expectedOutput = @" OnTextChangedEventHandler(null, args)"" readonly="""" disabled="""">"; expectedOutput = expectedOutput.Trim().Replace("\r\n", "\n"); var output = (await GetConverterOutput(inputText)).Trim().Replace("\r\n", "\n"); Assert.AreEqual(expectedOutput, output); } [Test] public async Task AspTextBox_Is_Properly_Converted_To_Default_Input() { var inputText = @" "; var expectedOutput = @" OnTextChangedEventHandler(null, args)"" readonly="""" disabled="""">"; expectedOutput = expectedOutput.Trim().Replace("\r\n", "\n"); var output = (await GetConverterOutput(inputText)).Trim().Replace("\r\n", "\n"); Assert.AreEqual(expectedOutput, output); } } }