public void ReturnAmpAudioElementWithLayoutAttributeSetToNoDisplay_IfTheOriginalAudioElementHasStyleVisibilityHidden()
        {
            // Arrange
            const string ExpectedResult = "nodisplay";
            var          audioElement   = ElementFactory.CreateAudio();

            audioElement.SetAttribute("style", "visibility:hidden");
            ElementFactory.Document.Body.Append(audioElement);

            // Act
            var actualResult = new AudioSanitizer().Sanitize(ElementFactory.Document, audioElement);

            // Assert
            Assert.AreEqual(ExpectedResult, actualResult.GetAttribute("layout"));
        }
        public void ReturnAmpAudioElementWithLayoutAttributeSetToFixedHeight_IfTheOriginalAudioElementHasOnlyHeightAttributeSpecified()
        {
            // Arrange
            const string ExpectedResult = "fixed-height";
            var          audioElement   = ElementFactory.CreateAudio();

            audioElement.SetAttribute("height", "100");
            ElementFactory.Document.Body.Append(audioElement);

            // Act
            var actualResult = new AudioSanitizer().Sanitize(ElementFactory.Document, audioElement);

            // Assert
            Assert.AreEqual(ExpectedResult, actualResult.GetAttribute("layout"));
        }
        public void ReturnAmpAudioElementWithLayoutAttributeSetToResponsive_IfTheOriginalAudioElementHasBothWidthAndHeightAttributesAndWidthHasValueEqualToAuto()
        {
            // Arrange
            const string ExpectedResult = "responsive";
            var          audioElement   = ElementFactory.CreateAudio();

            audioElement.SetAttribute("width", "auto");
            audioElement.SetAttribute("height", "100");
            ElementFactory.Document.Body.Append(audioElement);

            // Act
            var actualResult = new AudioSanitizer().Sanitize(ElementFactory.Document, audioElement);

            // Assert
            Assert.AreEqual(ExpectedResult, actualResult.GetAttribute("layout"));
        }
        public void ReturnAmpAudioElementWithSourceStartingWithHttpsAndTheOtherPartOfTheUrlPreserved_WhenTheAudioElementHasSourceAttribute()
        {
            // Arrange
            const string ExpectedResult = "https://www.site.com:8082/test-resource?q=1";
            var          audioElement   = ElementFactory.CreateAudio();

            audioElement.Source = "http://www.site.com:8082/test-resource?q=1";
            ElementFactory.Document.Body.Append(audioElement);

            // Act
            var actualResult     = new AudioSanitizer().Sanitize(ElementFactory.Document, audioElement);
            var ampElementSource = new Uri(actualResult.GetAttribute("src"));

            // Assert
            Assert.AreEqual(ExpectedResult, ampElementSource.ToString());
        }
        public void ReturnAmpAudioElementWithSourceStartingWithHttps_WhenTheAudioElementHasSourceAttribute()
        {
            // Arrange
            const string ExpectedResult = "https";
            var          audioElement   = ElementFactory.CreateAudio();

            audioElement.Source = "http://www.mysite.com";
            ElementFactory.Document.Body.Append(audioElement);

            // Act
            var actualResult     = new AudioSanitizer().Sanitize(ElementFactory.Document, audioElement);
            var ampElementSource = new Uri(actualResult.GetAttribute("src"));

            // Assert
            Assert.AreEqual(ExpectedResult, ampElementSource.Scheme);
        }
        public void CopyAllAttributesFromTheOriginalAudioElementToTheAmpElement_Always()
        {
            // Arrange
            var htmlElement = ElementFactory.CreateAudio();

            htmlElement.Source    = "https://www.example.com";
            htmlElement.Id        = "audioId";
            htmlElement.ClassName = "someClassName";
            ElementFactory.Document.Body.Append(htmlElement);

            // Act
            var actualResult = new AudioSanitizer().Sanitize(ElementFactory.Document, htmlElement);

            // Assert
            Assert.AreEqual("https://www.example.com", actualResult.GetAttribute("src"));
            Assert.AreEqual("audioId", actualResult.Id);
            Assert.AreEqual("someClassName", actualResult.ClassName);
        }