diff --git a/APITest/APITest.csproj b/APITest/APITest.csproj index f2c7b04d..ec1074b4 100644 --- a/APITest/APITest.csproj +++ b/APITest/APITest.csproj @@ -1,72 +1,23 @@ - - + - Debug - AnyCPU - {B26BA503-8721-4547-BCB7-E373C73AEB37} + net7.0 Library - Properties - APITest - APITest - v4.5 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest + false + False + False - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - + - - - - - - - {bf0b37e7-2d93-4a3d-ad6d-0b51b66f5b21} - Ivony.Core - - - {d05d58d3-5c3a-41bd-ba9e-2aa532a3b1be} - Ivony.Html.Parser - - - {e775b408-605f-4b66-87b6-98596069b703} - Ivony.Html - + + + @@ -94,13 +45,12 @@ - - - + + + all + + + + + \ No newline at end of file diff --git a/BindingTest/BindingExpressionParserTest.cs b/BindingTest/BindingExpressionParserTest.cs deleted file mode 100644 index b23c3b6f..00000000 --- a/BindingTest/BindingExpressionParserTest.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Ivony.Html.Binding; -using System.Linq; - -namespace BindingTest -{ - [TestClass] - public class BindingExpressionParserTest - { - [TestMethod] - public void Test1() - { - - TestEvaluator evaluator = new TestEvaluator(); - - var expression = BindingExpression.ParseExpression( "{eval path=Name}" ); - Assert.AreEqual( expression.Name, "eval", "测试解析绑定表达式失败" ); - - object value; - Assert.IsTrue( expression.TryGetValue( evaluator, "path", out value ), "测试解析绑定表达式失败" ); - Assert.AreEqual( value, "Name", "测试解析绑定表达式失败" ); - - - expression = BindingExpression.ParseExpression( "{eval path=Name , key==@#$}" ); - Assert.AreEqual( expression.Name, "eval", "测试解析绑定表达式失败" ); - Assert.IsTrue( expression.TryGetValue( evaluator, "path", out value ), "测试解析绑定表达式失败" ); - Assert.AreEqual( value, "Name ", "测试解析绑定表达式失败" ); - Assert.IsTrue( expression.TryGetValue( evaluator, "key", out value ), "测试解析绑定表达式失败" ); - Assert.AreEqual( value, "=@#$", "测试解析绑定表达式失败" ); - - expression = BindingExpression.ParseExpression( "{eval path={{abc,,}},key=abc}" ); - Assert.AreEqual( expression.Name, "eval", "测试解析绑定表达式失败" ); - Assert.IsTrue( expression.TryGetValue( evaluator, "path", out value ), "测试解析绑定表达式失败" ); - Assert.AreEqual( value, "{abc,}", "测试解析绑定表达式失败" ); - Assert.IsTrue( expression.TryGetValue( evaluator, "key", out value ), "测试解析绑定表达式失败" ); - Assert.AreEqual( value, "abc", "测试解析绑定表达式失败" ); - - expression = BindingExpression.ParseExpression( "{eval path={},,key=abc}" ); - Assert.IsNull( expression, "错误的解析了错误的表达式" ); - - expression = BindingExpression.ParseExpression( "{eval path={eval a=b, c=d},key=abc}" ); - Assert.AreEqual( expression.Name, "eval", "测试解析绑定表达式失败" ); - Assert.IsTrue( expression.TryGetValue( evaluator, "path", out value ), "测试解析绑定表达式失败" ); - Assert.AreEqual( value, "a:b,c:d", "测试解析绑定表达式失败" ); - Assert.IsTrue( expression.TryGetValue( evaluator, "key", out value ), "测试解析绑定表达式失败" ); - Assert.AreEqual( value, "abc", "测试解析绑定表达式失败" ); - - - expression = BindingExpression.ParseExpression( "{eval a, b=}" ); - Assert.AreEqual( expression.Name, "eval", "测试解析绑定表达式失败" ); - Assert.IsTrue( expression.TryGetValue( evaluator, "a", out value ), "测试解析绑定表达式失败" ); - Assert.IsNull( value, "测试解析绑定表达式失败" ); - Assert.IsTrue( expression.TryGetValue( evaluator, "b", out value ), "测试解析绑定表达式失败" ); - Assert.AreEqual( value, "", "测试解析绑定表达式失败" ); - - - } - - private class TestEvaluator : IBindingExpressionEvaluator - { - public object GetValue( BindingExpression bindingExpression ) - { - - if ( bindingExpression == null ) - return null; - - var values = bindingExpression.GetValues( this ); - - return string.Join( ",", values.Select( pair => pair.Key + ":" + pair.Value ) ); - } - - public bool TryConvertValue( object obj, out T value ) - { - value = (T) obj; - return true; - } - } - - - - } -} diff --git a/BindingTest/BindingTest.csproj b/BindingTest/BindingTest.csproj deleted file mode 100644 index e0c31242..00000000 --- a/BindingTest/BindingTest.csproj +++ /dev/null @@ -1,135 +0,0 @@ - - - - Debug - AnyCPU - {92AB60D7-E49A-42EC-9640-12CA298AF843} - Library - Properties - BindingTest - BindingTest - v4.0 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - ..\packages\Newtonsoft.Json.6.0.8\lib\net40\Newtonsoft.Json.dll - - - - 3.5 - - - - - - - - - - - - - - - - - - - - - - - - - - - - {bf0b37e7-2d93-4a3d-ad6d-0b51b66f5b21} - Ivony.Core - - - {ea844798-6870-4b11-bc4d-4dfef2da69e0} - Ivony.Html.Binding - - - {d05d58d3-5c3a-41bd-ba9e-2aa532a3b1be} - Ivony.Html.Parser - - - {e775b408-605f-4b66-87b6-98596069b703} - Ivony.Html - - - - - Always - - - Always - - - Always - - - Always - - - PreserveNewest - - - - - - - - - - False - - - False - - - False - - - False - - - - - - - - \ No newline at end of file diff --git a/BindingTest/DynamicTest.cs b/BindingTest/DynamicTest.cs deleted file mode 100644 index cdf1fea5..00000000 --- a/BindingTest/DynamicTest.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Ivony.Html.Binding; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BindingTest -{ - - [TestClass] - public class DynamicTest - { - - [TestMethod] - public void DynamicTest1() - { - - var a = JObject.FromObject( new { A = 1 } ); - Assert.AreEqual( (int) DynamicBinder.GetPropertyValue( a, "A" ), 1 ); - - - } - - } - -} diff --git a/BindingTest/EvalExpressionTest.cs b/BindingTest/EvalExpressionTest.cs deleted file mode 100644 index 896882b1..00000000 --- a/BindingTest/EvalExpressionTest.cs +++ /dev/null @@ -1,57 +0,0 @@ -using Ivony.Html.Binding; -using Ivony.Html.Parser; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using Ivony.Html; -using Newtonsoft.Json.Linq; - -namespace BindingTest -{ - [TestClass] - public class EvalExpressionTest - { - - [TestMethod] - public void EvalTest1() - { - - var document = new JumonyParser().LoadDocument( Path.Combine( Environment.CurrentDirectory, "Test1.html" ) ); - - - { - var data = new { A = 123, B = "ABC" }; - var context = HtmlBinding.Create( document, data ); - { - var expression = BindingExpression.ParseExpression( "{eval path=A}" ); - Assert.AreEqual( context.GetValue( expression ), 123 ); - } - - { - var expression = BindingExpression.ParseExpression( "{eval path=B}" ); - Assert.AreEqual( context.GetValue( expression ), "ABC" ); - } - } - - { - var data = JObject.Parse( "{A:123,B:'ABC'}" ); - var context = HtmlBinding.Create( document, data ); - { - var expression = BindingExpression.ParseExpression( "{eval path=A}" ); - Assert.AreEqual( context.GetValue( expression ).ToString(), "123" ); - } - - { - var expression = BindingExpression.ParseExpression( "{eval path=B}" ); - Assert.AreEqual( context.GetValue( expression ).ToString(), "ABC" ); - } - } - - - } - - } -} diff --git a/BindingTest/ExpressionBinderTest.cs b/BindingTest/ExpressionBinderTest.cs deleted file mode 100644 index a6d50cb7..00000000 --- a/BindingTest/ExpressionBinderTest.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Ivony.Html; -using Ivony.Html.Binding; -using Ivony.Html.Parser; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; -using System.IO; -using System.Collections.Generic; - -namespace BindingTest -{ - [TestClass] - public class ExpressionBinderTest - { - [TestMethod] - public void AttributeTest1() - { - var document = new JumonyParser().LoadDocument( Path.Combine( Environment.CurrentDirectory, "Test1.html" ) ); - - var dataValues = new Dictionary() { - { "StyleClass", "Test" }, - { "ThisTime", new DateTime( 2000,1,2 ) }, - { "ScriptValue1", null } - }; - - HtmlBinding.Create( document, dataValues ).DataBind(); - - Assert.AreEqual( document.FindFirst( "body" ).Attribute( "class" ).Value(), "Test", "针对属性的表达式绑定不成功" ); - Assert.AreEqual( document.FindFirst( "body" ).Attribute( "test" ).Value(), "this time is 2000-01-02 #", "格式表达式测试失败" ); - - - } - } -} diff --git a/BindingTest/ListTest.cs b/BindingTest/ListTest.cs deleted file mode 100644 index a4ce9465..00000000 --- a/BindingTest/ListTest.cs +++ /dev/null @@ -1,115 +0,0 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Ivony.Html; -using System.IO; -using Ivony.Html.Parser; -using Ivony.Html.Binding; -using System.Linq; -using Newtonsoft.Json.Linq; - -namespace BindingTest -{ - [TestClass] - public class ListTest - { - [TestMethod] - public void SimpleList() - { - - var document = LoadDocument( "ListTest1.html" ); - - document.DataBind( new int[] { 1, 2, 3 } ); - - Assert.AreEqual( document.Find( "div" ).Count(), 3 ); - - Assert.AreEqual( document.Find( "div span" ).ElementAt( 0 ).InnerText(), "1" ); - Assert.AreEqual( document.Find( "div span" ).ElementAt( 1 ).InnerText(), "2" ); - Assert.AreEqual( document.Find( "div span" ).ElementAt( 2 ).InnerText(), "3" ); - - - - document.DataBind( JToken.Parse( "[1,2,3]" ) ); - - Assert.AreEqual( document.Find( "div" ).Count(), 3 ); - - Assert.AreEqual( document.Find( "div span" ).ElementAt( 0 ).InnerText(), "1" ); - Assert.AreEqual( document.Find( "div span" ).ElementAt( 1 ).InnerText(), "2" ); - Assert.AreEqual( document.Find( "div span" ).ElementAt( 2 ).InnerText(), "3" ); - - - - } - - - protected static IHtmlDocument LoadDocument( string filename ) - { - return new JumonyParser().LoadDocument( Path.Combine( Environment.CurrentDirectory, filename ) ); - } - - - - [TestMethod] - public void ListGrowth() - { - - - var document = LoadDocument( "ListTest2.html" ); - - document.DataBind( new int[] { 1, 2, 3, 4, 5, 6 } ); - - - var container = document.FindFirst( "body > div" ); - - Assert.IsTrue( container.Elements().ElementAt( 0 ).Class().Contains( "header" ), "列表增长绑定测试失败" ); - Assert.IsTrue( container.Elements().ElementAt( 1 ).Class().Contains( "item" ), "列表增长绑定测试失败" ); - Assert.IsTrue( container.Elements().ElementAt( 2 ).Class().Contains( "separator" ), "列表增长绑定测试失败" ); - Assert.IsTrue( container.Elements().ElementAt( 3 ).Class().Contains( "item" ), "列表增长绑定测试失败" ); - Assert.IsTrue( container.Elements().ElementAt( 4 ).Class().Contains( "separator" ), "列表增长绑定测试失败" ); - Assert.IsTrue( container.Elements().ElementAt( 5 ).Class().Contains( "item" ), "列表增长绑定测试失败" ); - Assert.IsTrue( container.Elements().ElementAt( 6 ).Class().Contains( "separator" ), "列表增长绑定测试失败" ); - Assert.IsTrue( container.Elements().ElementAt( 7 ).Class().Contains( "item" ), "列表增长绑定测试失败" ); - Assert.IsTrue( container.Elements().ElementAt( 8 ).Class().Contains( "separator" ), "列表增长绑定测试失败" ); - Assert.IsTrue( container.Elements().ElementAt( 9 ).Class().Contains( "item" ), "列表增长绑定测试失败" ); - Assert.IsTrue( container.Elements().ElementAt( 10 ).Class().Contains( "separator" ), "列表增长绑定测试失败" ); - Assert.IsTrue( container.Elements().ElementAt( 11 ).Class().Contains( "item" ), "列表增长绑定测试失败" ); - Assert.IsTrue( container.Elements().ElementAt( 12 ).Class().Contains( "footer" ), "列表增长绑定测试失败" ); - - Assert.AreEqual( container.Elements( ".item" ).ElementAt( 0 ).InnerText(), "1", "列表增长绑定测试失败" ); - Assert.AreEqual( container.Elements( ".item" ).ElementAt( 1 ).InnerText(), "2", "列表增长绑定测试失败" ); - Assert.AreEqual( container.Elements( ".item" ).ElementAt( 2 ).InnerText(), "3", "列表增长绑定测试失败" ); - Assert.AreEqual( container.Elements( ".item" ).ElementAt( 3 ).InnerText(), "4", "列表增长绑定测试失败" ); - Assert.AreEqual( container.Elements( ".item" ).ElementAt( 4 ).InnerText(), "5", "列表增长绑定测试失败" ); - Assert.AreEqual( container.Elements( ".item" ).ElementAt( 5 ).InnerText(), "6", "列表增长绑定测试失败" ); - - Assert.AreEqual( container.Elements( ".footer" ).First().InnerText(), "6", "高级列表绑定测试失败" ); - } - - - [TestMethod] - public void ListTruncate() - { - - - var document = LoadDocument( "ListTest3.html" ); - - document.DataBind( new int[] { 1, 2, 3 } ); - - - var container = document.FindFirst( "body > div" ); - - Assert.AreEqual( container.Elements().Count(), 5, "列表截断绑定测试失败" ); - - Assert.IsTrue( container.Elements().ElementAt( 0 ).Class().Contains( "item" ), "列表截断绑定测试失败" ); - Assert.IsTrue( container.Elements().ElementAt( 1 ).Class().Contains( "separator" ), "列表截断绑定测试失败" ); - Assert.IsTrue( container.Elements().ElementAt( 2 ).Class().Contains( "item" ), "列表截断绑定测试失败" ); - Assert.IsTrue( container.Elements().ElementAt( 3 ).Class().Contains( "separator" ), "列表截断绑定测试失败" ); - Assert.IsTrue( container.Elements().ElementAt( 4 ).Class().Contains( "item" ), "列表截断绑定测试失败" ); - - Assert.AreEqual( container.Elements( ".item" ).ElementAt( 0 ).InnerText(), "1", "列表截断绑定测试失败" ); - Assert.AreEqual( container.Elements( ".item" ).ElementAt( 1 ).InnerText(), "2", "列表截断绑定测试失败" ); - Assert.AreEqual( container.Elements( ".item" ).ElementAt( 2 ).InnerText(), "3", "列表截断绑定测试失败" ); - - } - - } -} diff --git a/BindingTest/ListTest1.html b/BindingTest/ListTest1.html deleted file mode 100644 index ba204b6e..00000000 --- a/BindingTest/ListTest1.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - -
- -
- - - \ No newline at end of file diff --git a/BindingTest/ListTest2.html b/BindingTest/ListTest2.html deleted file mode 100644 index 034d3a04..00000000 --- a/BindingTest/ListTest2.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - -
- -
-
-
-
- -
- - - \ No newline at end of file diff --git a/BindingTest/ListTest3.html b/BindingTest/ListTest3.html deleted file mode 100644 index 67c6ab3d..00000000 --- a/BindingTest/ListTest3.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - -
-
-
-------------------------------------------
-
-
-------------------------------------------
-
-
-------------------------------------------
-
-
-------------------------------------------
-
-
- - \ No newline at end of file diff --git a/BindingTest/LiteralBinderTest.cs b/BindingTest/LiteralBinderTest.cs deleted file mode 100644 index aca030b2..00000000 --- a/BindingTest/LiteralBinderTest.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Ivony.Html.Parser; -using Ivony.Html; -using System.IO; -using Ivony.Html.Binding; - -namespace BindingTest -{ - [TestClass] - public class LiteralBinderTest - { - [TestMethod] - public void Test1() - { - - var document = new JumonyParser().LoadDocument( Path.Combine( Environment.CurrentDirectory, "Test1.html" ) ); - HtmlBinding.Create( document, null ).DataBind(); - - - Assert.AreEqual( document.FindFirst( "title" ).InnerHtml(), "Test Title abc text", "对 title 元素内容的文本替换测试失败" ); - - } - } -} diff --git a/BindingTest/Properties/AssemblyInfo.cs b/BindingTest/Properties/AssemblyInfo.cs deleted file mode 100644 index c2ecac43..00000000 --- a/BindingTest/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// 有关程序集的常规信息通过以下特性集 -// 控制。更改这些特性值可修改 -// 与程序集关联的信息。 -[assembly: AssemblyTitle( "BindingTest" )] -[assembly: AssemblyDescription( "" )] -[assembly: AssemblyConfiguration( "" )] -[assembly: AssemblyCompany( "" )] -[assembly: AssemblyProduct( "BindingTest" )] -[assembly: AssemblyCopyright( "Copyright © 2014" )] -[assembly: AssemblyTrademark( "" )] -[assembly: AssemblyCulture( "" )] - -// 将 ComVisible 设置为 false 会使此程序集中的类型 -// 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, -// 请将该类型上的 ComVisible 特性设置为 true。 -[assembly: ComVisible( false )] - -// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID -[assembly: Guid( "bb7669e1-61c7-4855-b526-93b87e243c03" )] - -// 程序集的版本信息由以下四个值组成: -// -// 主版本 -// 次版本 -// 生成号 -// 修订号 -// -// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, -// 方法是按如下所示使用“*”: -// [assembly: AssemblyVersion("1.0.*")] diff --git a/BindingTest/ScriptBinderTest.cs b/BindingTest/ScriptBinderTest.cs deleted file mode 100644 index ec3ab5d5..00000000 --- a/BindingTest/ScriptBinderTest.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Ivony.Html; -using Ivony.Html.Binding; -using Ivony.Html.Parser; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; - -namespace BindingTest -{ - [TestClass] - public class ScriptBinderTest - { - - [TestMethod] - public void Test1() - { - var document = new JumonyParser().LoadDocument( Path.Combine( Environment.CurrentDirectory, "Test1.html" ) ); - var data = new Dictionary(); - data.Add( "StyleClass", null ); - data.Add( "ThisTime", null ); - data.Add( "ScriptValue1", "TestValue" ); - - HtmlBinding.Create( document, data ).DataBind(); - - StringAssert.Contains( document.FindFirst( "script" ).InnerHtml(), "var value1 =\"TestValue\";" ); - } - - } -} diff --git a/BindingTest/StyleBinderTest.cs b/BindingTest/StyleBinderTest.cs deleted file mode 100644 index 90d03d17..00000000 --- a/BindingTest/StyleBinderTest.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.IO; -using Ivony.Html.Parser; -using Ivony.Html.Binding; -using Ivony.Html; -using System.Linq; - -namespace BindingTest -{ - [TestClass] - public class StyleBinderTest - { - [TestMethod] - public void VisibleTest() - { - var document = new JumonyParser().LoadDocument( Path.Combine( Environment.CurrentDirectory, "StyleTest1.html" ) ); - document.DataBind( null ); - - Assert.AreEqual( document.Find( ".invisible" ).Count(), 0 ); - - - } - } -} diff --git a/BindingTest/StyleTest1.html b/BindingTest/StyleTest1.html deleted file mode 100644 index 3af9cb4b..00000000 --- a/BindingTest/StyleTest1.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/BindingTest/Test1.html b/BindingTest/Test1.html deleted file mode 100644 index c697ecfb..00000000 --- a/BindingTest/Test1.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - Test Title #text# text - - -
- - - \ No newline at end of file diff --git a/BindingTest/packages.config b/BindingTest/packages.config deleted file mode 100644 index c4dd6115..00000000 --- a/BindingTest/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/FormsTest/FormValidationTest.html b/FormsTest/FormValidationTest.html deleted file mode 100644 index b999809c..00000000 --- a/FormsTest/FormValidationTest.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
First Name: - -
Last Name: -  
Age: -  
-
- - diff --git a/FormsTest/FormsTest.cs b/FormsTest/FormsTest.cs deleted file mode 100644 index c741414b..00000000 --- a/FormsTest/FormsTest.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Collections.Specialized; -using Ivony.Html; -using Ivony.Html.Parser; -using Ivony.Html.Forms; -using System.IO; - -namespace FormsTest -{ - [TestClass] - public class FormsTest - { - [TestMethod] - public void FormTest1() - { - var document = LoadDocument( "FormsTest1.html" ); - - - Exception e = null; - - try - { - - document.FindFirst( "form" ).AsForm(); - - } - catch ( Exception exception ) - { - e = exception; - } - - - Assert.IsNotNull( e, "表单中存在重复的文本输入框未能引发异常" ); - Assert.IsInstanceOfType( e, typeof( InvalidOperationException ), "表单中存在重复的文本输入框未能引发正确的异常" ); - - - } - - [TestMethod] - public void TextControlTest() - { - - var document = LoadDocument( "TextControlTest.html" ); - - var form = document.FindFirst( "form" ).AsForm(); - - Assert.IsTrue( form.Controls.Contains( "textbox1" ), "未能找到 textbox1 控件" ); - Assert.IsTrue( form.Controls.Contains( "textbox2" ), "未能找到 textbox2 控件" ); - - Assert.AreEqual( form.Controls["textbox1"].Value, "Test1", "获取 textbox1 控件值失败" ); - Assert.AreEqual( form.Controls["textbox2"].Value, "Test2", "获取 textbox2 控件值失败" ); - - form.Controls["textbox1"].Value = "Test"; - form.Controls["textbox2"].Value = "Test"; - - Assert.AreEqual( form.Controls["textbox1"].Value, "Test", "设置 textbox1 控件值失败" ); - Assert.AreEqual( form.Controls["textbox2"].Value, "Test", "设置 textbox2 控件值失败" ); - - Assert.AreEqual( form.Element.FindFirst( "[name=textbox1]" ).Attribute( "value" ).Value(), "Test", "设置 textbox1 控件值失败" ); - Assert.AreEqual( form.Element.FindFirst( "[name=textbox2]" ).InnerText(), "Test", "设置 textbox2 控件值失败" ); - - - var value = "Text\nText"; - - Assert.IsFalse( form.Controls["textbox1"].CanSetValue( value ), "尝试设置多行文本值成功,这是错误的" ); - - try - { - form.Controls["textbox1"].Value = value; - } - catch ( Exception e ) - { - Assert.IsInstanceOfType( e, typeof( FormatException ), "尝试设置多行文本值引发了错误的异常" ); - - return; - } - - Assert.Fail( "尝试设置多行文本值未能引发异常" ); - } - - - private static IHtmlDocument LoadDocument( string filename ) - { - return new JumonyParser().LoadDocument( Path.Combine( Environment.CurrentDirectory, filename ) ); - } - - - - [TestMethod] - public void ValidationTest() - { - var document = LoadDocument( "FormValidationTest.html" ); - - var form = document.FindFirst( "form" ).AsForm(); - - var presenter = new FormPresenter(); - - var result = new FormValidationResult( form, new[] { new FormValidationError( "FirstName", "First Name is required!" ) } ); - - presenter.ShowValidationResult( result ); - - Assert.AreEqual( form.Element.FindFirst( "#error_FirstName ul li" ).InnerText(), "First Name is required!" ); - - } - - - } -} diff --git a/FormsTest/FormsTest.csproj b/FormsTest/FormsTest.csproj deleted file mode 100644 index 103a9fc1..00000000 --- a/FormsTest/FormsTest.csproj +++ /dev/null @@ -1,112 +0,0 @@ - - - - Debug - AnyCPU - {5A867711-DF50-4FDC-B03D-3E5A7575AF5D} - Library - Properties - FormsTest - FormsTest - v4.5 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - Always - - - Always - - - PreserveNewest - - - - - {bf0b37e7-2d93-4a3d-ad6d-0b51b66f5b21} - Ivony.Core - - - {1dab4b96-d944-46fe-bc73-7b618dee169f} - Ivony.Html.Forms - - - {d05d58d3-5c3a-41bd-ba9e-2aa532a3b1be} - Ivony.Html.Parser - - - {e775b408-605f-4b66-87b6-98596069b703} - Ivony.Html - - - - - - - False - - - False - - - False - - - False - - - - - - - - \ No newline at end of file diff --git a/FormsTest/FormsTest1.html b/FormsTest/FormsTest1.html deleted file mode 100644 index 22ca456f..00000000 --- a/FormsTest/FormsTest1.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - -
- - - - - -
- - - \ No newline at end of file diff --git a/FormsTest/Properties/AssemblyInfo.cs b/FormsTest/Properties/AssemblyInfo.cs deleted file mode 100644 index 60f829dd..00000000 --- a/FormsTest/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// 有关程序集的常规信息通过以下特性集 -// 控制。更改这些特性值可修改 -// 与程序集关联的信息。 -[assembly: AssemblyTitle( "FormsTest" )] -[assembly: AssemblyDescription( "" )] -[assembly: AssemblyConfiguration( "" )] -[assembly: AssemblyCompany( "" )] -[assembly: AssemblyProduct( "FormsTest" )] -[assembly: AssemblyCopyright( "Copyright © 2014" )] -[assembly: AssemblyTrademark( "" )] -[assembly: AssemblyCulture( "" )] - -// 将 ComVisible 设置为 false 会使此程序集中的类型 -// 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, -// 请将该类型上的 ComVisible 特性设置为 true。 -[assembly: ComVisible( false )] - -// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID -[assembly: Guid( "49b75036-d760-4ac4-93f6-cd0ca0c336c2" )] - -// 程序集的版本信息由以下四个值组成: -// -// 主版本 -// 次版本 -// 生成号 -// 修订号 -// -// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, -// 方法是按如下所示使用“*”: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion( "1.0.0.0" )] -[assembly: AssemblyFileVersion( "1.0.0.0" )] diff --git a/FormsTest/TextControlTest.html b/FormsTest/TextControlTest.html deleted file mode 100644 index c7ec9b52..00000000 --- a/FormsTest/TextControlTest.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - -
- - - -
- - - \ No newline at end of file diff --git a/HtmlTranslater/App.xaml b/HtmlTranslater/App.xaml deleted file mode 100644 index 20327dd0..00000000 --- a/HtmlTranslater/App.xaml +++ /dev/null @@ -1,8 +0,0 @@ - - - diff --git a/HtmlTranslater/App.xaml.cs b/HtmlTranslater/App.xaml.cs deleted file mode 100644 index 78f2851d..00000000 --- a/HtmlTranslater/App.xaml.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Data; -using System.Linq; -using System.Windows; - -namespace HtmlTranslator -{ - /// - /// App.xaml 的交互逻辑 - /// - public partial class App : Application - { - } -} diff --git a/HtmlTranslater/CandidateTermsConverter.cs b/HtmlTranslater/CandidateTermsConverter.cs deleted file mode 100644 index f60f4370..00000000 --- a/HtmlTranslater/CandidateTermsConverter.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows.Data; -using System.Windows; - -namespace HtmlTranslator -{ - public class CandidateTermsConverter : IValueConverter - { - - public CandidateTermsConverter() - { - - } - - - public TranslateTask Task - { - get; - set; - } - - - public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture ) - { - var sourceTerm = value as string; - if ( sourceTerm == null ) - return Enumerable.Empty(); - - return Task.Dictionary[sourceTerm]; - } - - public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture ) - { - throw new NotSupportedException(); - } - } -} diff --git a/HtmlTranslater/HtmlTranslater.csproj b/HtmlTranslater/HtmlTranslater.csproj deleted file mode 100644 index fc55966f..00000000 --- a/HtmlTranslater/HtmlTranslater.csproj +++ /dev/null @@ -1,122 +0,0 @@ - - - - Debug - x86 - 8.0.30703 - 2.0 - {4C76EF80-FBA8-4454-A2A6-B75E1D709553} - WinExe - Properties - HtmlTranslator - HtmlTranslator - v4.0 - Client - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - - - x86 - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - x86 - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - 4.0 - - - - - - - - MSBuild:Compile - Designer - - - - - - - MSBuild:Compile - Designer - - - App.xaml - Code - - - MainWindow.xaml - Code - - - - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True - - - ResXFileCodeGenerator - Resources.Designer.cs - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - - {BF0B37E7-2D93-4A3D-AD6D-0B51B66F5B21} - Ivony.Core - - - {D05D58D3-5C3A-41BD-BA9E-2AA532A3B1BE} - Ivony.Html.Parser - - - {E775B408-605F-4B66-87B6-98596069B703} - Ivony.Html - - - - - \ No newline at end of file diff --git a/HtmlTranslater/MainWindow.xaml b/HtmlTranslater/MainWindow.xaml deleted file mode 100644 index 9de25004..00000000 --- a/HtmlTranslater/MainWindow.xaml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -