#region Copyright 2010-2014 by Roger Knapp, Licensed under the Apache License, Version 2.0 /* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #endregion using System; using System.Collections.Generic; using NUnit.Framework; using CSharpTest.Net.Html; using System.IO; using System.Xml; using CSharpTest.Net.IO; #pragma warning disable 1591 namespace CSharpTest.Net.Library.Test { [TestFixture] [Category("TestXhtmlValid")] public partial class TestXhtmlValid { [Test] public void TestValidStrict() { string doc = @" required "; XhtmlValidation v = new XhtmlValidation(XhtmlDTDSpecification.XhtmlStrict_10); using (TempFile temp = new TempFile()) { temp.WriteAllText(doc); v.Validate(temp.TempPath); } } [Test] public void TestValidTransitional() { string doc = @" required "; XhtmlValidation v = new XhtmlValidation(XhtmlDTDSpecification.XhtmlTransitional_10); using (TempFile temp = new TempFile()) { temp.WriteAllText(doc); v.Validate(@"C:\transitional.xhtml", new StreamReader(temp.Read())); } } [Test] public void TestValidFrameset() { string doc = @" required "; XhtmlValidation v = new XhtmlValidation(XhtmlDTDSpecification.XhtmlFrameset_10); v.Validate(new StringReader(doc)); } [Test] public void TestValidAnyDTD() { string doc = @" required "; XhtmlValidation v = new XhtmlValidation(XhtmlDTDSpecification.Any); v.Validate(new StringReader(doc)); } [Test] public void TestValidNoDTD() { string doc = @" required "; XhtmlValidation v = new XhtmlValidation(XhtmlDTDSpecification.None); v.Validate(new StringReader(doc)); } [Test, ExpectedException(typeof(XmlException))] public void TestInvalidDTD() { string doc = @" required "; XhtmlValidation v = new XhtmlValidation(XhtmlDTDSpecification.None); v.Validate(new StringReader(doc)); } [Test, ExpectedException(typeof(XmlException))] public void TestIncorrectDTD() { string doc = @" required "; XhtmlValidation v = new XhtmlValidation(XhtmlDTDSpecification.XhtmlStrict_10); v.Validate(new StringReader(doc)); } [Test, ExpectedException(typeof(XmlException))] public void TestInvalidXml() { string doc = @" required "; XhtmlValidation v = new XhtmlValidation(); v.Validate(new StringReader(doc)); } [Test, ExpectedException(typeof(XmlException))] public void TestInvalidStrictDoc() { string doc = @" required "; XhtmlValidation v = new XhtmlValidation(); v.Validate(new StringReader(doc)); } [Test, ExpectedException(typeof(XmlException))] public void TestInvalidAttribute() { string doc = @" required "; XhtmlValidation v = new XhtmlValidation(); v.Validate(new StringReader(doc)); } [Test, ExpectedException(typeof(XmlException))] public void TestInvalidRoot() { string doc = @" required "; XhtmlValidation v = new XhtmlValidation(); v.Validate(new StringReader(doc)); } } }