diff --git a/.nuget/packages.config b/.nuget/packages.config index eb41749c..61eda557 100644 --- a/.nuget/packages.config +++ b/.nuget/packages.config @@ -1,4 +1,5 @@  + \ No newline at end of file diff --git a/MVVM.CEFGlue.sln b/MVVM.CEFGlue.sln index a62e9bb6..66301ece 100644 --- a/MVVM.CEFGlue.sln +++ b/MVVM.CEFGlue.sln @@ -52,6 +52,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MVVM.Awesomium", "MVVM.Awes EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MVVM_Awesonium_UI", "MVVM_Awesonium_UI\MVVM_Awesonium_UI.csproj", "{723A4723-FAE8-4B50-B061-A4C599F4722E}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MVVM.Component.Test", "MVVM.Component.Test\MVVM.Component.Test.csproj", "{371234C6-4903-4F7D-8283-C0F8DBEF8755}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -290,6 +292,17 @@ Global {723A4723-FAE8-4B50-B061-A4C599F4722E}.Release|Mixed Platforms.Build.0 = Release|Any CPU {723A4723-FAE8-4B50-B061-A4C599F4722E}.Release|x86.ActiveCfg = Release|x86 {723A4723-FAE8-4B50-B061-A4C599F4722E}.Release|x86.Build.0 = Release|x86 + {371234C6-4903-4F7D-8283-C0F8DBEF8755}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {371234C6-4903-4F7D-8283-C0F8DBEF8755}.Debug|Any CPU.Build.0 = Debug|Any CPU + {371234C6-4903-4F7D-8283-C0F8DBEF8755}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {371234C6-4903-4F7D-8283-C0F8DBEF8755}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {371234C6-4903-4F7D-8283-C0F8DBEF8755}.Debug|x86.ActiveCfg = Debug|x86 + {371234C6-4903-4F7D-8283-C0F8DBEF8755}.Debug|x86.Build.0 = Debug|x86 + {371234C6-4903-4F7D-8283-C0F8DBEF8755}.Release|Any CPU.ActiveCfg = Release|Any CPU + {371234C6-4903-4F7D-8283-C0F8DBEF8755}.Release|Any CPU.Build.0 = Release|Any CPU + {371234C6-4903-4F7D-8283-C0F8DBEF8755}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {371234C6-4903-4F7D-8283-C0F8DBEF8755}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {371234C6-4903-4F7D-8283-C0F8DBEF8755}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -309,6 +322,7 @@ Global {84916CEB-FEF3-4A42-B1A0-7B43F3D88CCB} = {B3321797-0DAA-40DF-ADD3-13AC511028EF} {E35B9010-5429-4FFE-A788-E9C40E743E9C} = {6F066820-11A1-4533-A8CF-C7E43891D2BD} {723A4723-FAE8-4B50-B061-A4C599F4722E} = {0F0F34BE-CD06-4C13-967D-BB0760617486} + {371234C6-4903-4F7D-8283-C0F8DBEF8755} = {B3321797-0DAA-40DF-ADD3-13AC511028EF} EndGlobalSection GlobalSection(CodealikeProperties) = postSolution SolutionGuid = 21ee2d50-c4fe-49f3-a899-1dc535d57fcf diff --git a/MVVM.Component.Test/MVVM.Component.Test.csproj b/MVVM.Component.Test/MVVM.Component.Test.csproj new file mode 100644 index 00000000..83b92376 --- /dev/null +++ b/MVVM.Component.Test/MVVM.Component.Test.csproj @@ -0,0 +1,94 @@ + + + + + Debug + AnyCPU + {371234C6-4903-4F7D-8283-C0F8DBEF8755} + Library + Properties + MVVM.Component.Test + MVVM.Component.Test + v4.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + prompt + MinimumRecommendedRules.ruleset + + + bin\x86\Release\ + TRACE + true + pdbonly + x86 + prompt + MinimumRecommendedRules.ruleset + + + + ..\packages\FluentAssertions.4.1.1\lib\net45\FluentAssertions.dll + + + ..\packages\FluentAssertions.4.1.1\lib\net45\FluentAssertions.Core.dll + + + ..\packages\NSubstitute.1.9.2.0\lib\net45\NSubstitute.dll + + + + + + + + + + ..\packages\xunit.1.9.2\lib\net20\xunit.dll + + + + + + + + + Designer + + + + + {26203c44-279d-4bfe-b17a-f6ada8d240ed} + MVVM.Component + + + + + \ No newline at end of file diff --git a/MVVM.Component.Test/Properties/AssemblyInfo.cs b/MVVM.Component.Test/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..d61f8c93 --- /dev/null +++ b/MVVM.Component.Test/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("MVVM.Component.Test")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("MVVM.Component.Test")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("487c5802-213c-423c-b84a-1620cbbb21c2")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Tests/MVVM.Component/TaskHelperTest.cs b/MVVM.Component.Test/RelaySimpleCommandTest.cs similarity index 86% rename from Tests/MVVM.Component/TaskHelperTest.cs rename to MVVM.Component.Test/RelaySimpleCommandTest.cs index 1a2bcfa5..280f6359 100644 --- a/Tests/MVVM.Component/TaskHelperTest.cs +++ b/MVVM.Component.Test/RelaySimpleCommandTest.cs @@ -2,12 +2,12 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using NSubstitute; using Xunit; using FluentAssertions; using System.Threading.Tasks; +using NSubstitute; -namespace MVVM.Cef.Glue.Test +namespace MVVM.Component.Test { public class RelaySimpleCommandTest { @@ -49,6 +49,20 @@ public void RelayResultCommandShouldCallFunctionGeneric() res.Should().Be(122); } + [Fact] + public void RelayResultCommandCreate_CreateCommandThatCallFunctionGeneric() + { + var function = Substitute.For>(); + var arg = new object(); + function.Invoke(arg).Returns(122); + var target = RelayResultCommand.Create(function); + + var res = target.Execute(arg).Result; + + function.Received(1).Invoke(arg); + res.Should().Be(122); + } + [Fact] public void RelayResultCommandShouldHandleExceptionFunctionGeneric() { diff --git a/MVVM.Component.Test/packages.config b/MVVM.Component.Test/packages.config new file mode 100644 index 00000000..34222817 --- /dev/null +++ b/MVVM.Component.Test/packages.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/MVVM.Component/Infra/TaskHelper.cs b/MVVM.Component/Infra/TaskHelper.cs deleted file mode 100644 index aab50d79..00000000 --- a/MVVM.Component/Infra/TaskHelper.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace MVVM.Component.Infra -{ - public static class TaskHelper - { - public static async Task Convert(this Task task) - { - T res = await task; - return res; - } - } -} diff --git a/MVVM.Component/MVVM.Component.csproj b/MVVM.Component/MVVM.Component.csproj index 69fdae77..546c8a2a 100644 --- a/MVVM.Component/MVVM.Component.csproj +++ b/MVVM.Component/MVVM.Component.csproj @@ -63,7 +63,6 @@ - diff --git a/MVVM.Component/Relay/RelayResultCommand.cs b/MVVM.Component/Relay/RelayResultCommand.cs index d2d4a9cf..efa57942 100644 --- a/MVVM.Component/Relay/RelayResultCommand.cs +++ b/MVVM.Component/Relay/RelayResultCommand.cs @@ -3,7 +3,6 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -using MVVM.Component.Infra; namespace MVVM.Component { @@ -32,9 +31,9 @@ public RelayResultCommand(Func> iResultBuilder) _ResultBuilder = iResultBuilder; } - public Task Execute(object iargument) + public async Task Execute(object iargument) { - return _ResultBuilder((Tin)iargument).Convert(); + return await _ResultBuilder((Tin)iargument); } } diff --git a/Tests/MVVM.Cef.Glue.Test.csproj b/Tests/MVVM.Cef.Glue.Test.csproj index ccd5d592..954ab196 100644 --- a/Tests/MVVM.Cef.Glue.Test.csproj +++ b/Tests/MVVM.Cef.Glue.Test.csproj @@ -100,8 +100,6 @@ - - @@ -183,11 +181,15 @@ Always - + + Designer + Ko_Extension.min.js - + + Designer + diff --git a/Tests/MVVM.Component/RelaySimpleCommandTest.cs b/Tests/MVVM.Component/RelaySimpleCommandTest.cs deleted file mode 100644 index 60c144e5..00000000 --- a/Tests/MVVM.Component/RelaySimpleCommandTest.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -using NSubstitute; -using Xunit; -using FluentAssertions; - -using MVVM.Component.Infra; - -namespace MVVM.Cef.Glue.Test -{ - public class TaskHelperTest - { - [Fact] - public void SuccessShoulbBeSuccess() - { - TaskCompletionSource tcs = new TaskCompletionSource(); - tcs.SetResult(1); - - var target = tcs.Task.Convert(); - target.Result.Should().Be(1); - } - - - [Fact] - public void CancelShoulbBeCancel() - { - TaskCompletionSource tcs = new TaskCompletionSource(); - tcs.SetCanceled(); - - var target = tcs.Task.Convert(); - target.IsCanceled.Should().BeTrue(); - } - - - [Fact] - public void ExceptionShoulbBeException() - { - var ex = new Exception(); - TaskCompletionSource tcs = new TaskCompletionSource(); - tcs.SetException(ex); - - var target = tcs.Task.Convert(); - target.IsFaulted.Should().BeTrue(); - target.Exception.Flatten().InnerException.Should().Be(ex); - } - - } -} diff --git a/Tests/Test_ConvertToJSO.cs b/Tests/Test_ConvertToJSO.cs index ffcfb8e4..864e6d2f 100644 --- a/Tests/Test_ConvertToJSO.cs +++ b/Tests/Test_ConvertToJSO.cs @@ -67,10 +67,6 @@ protected override void Init() _Tests_NG.Add(_Tests[0]); } - - - - [Fact] public void Test_Simple() { @@ -88,7 +84,6 @@ public void Test_Simple() }); } - [Fact] public void Test_List() { @@ -155,7 +150,6 @@ public void Test_List_Not_Generic() }); } - [Fact] public void Test_Double() { @@ -232,7 +226,6 @@ public void Test_Bool_False() }); } - [Fact] public void Test_String() { @@ -258,6 +251,5 @@ public void Test_Object_Double_reference() _ICSharpMapper.Received().Cache(_Test, Arg.Any()); }); } - } } diff --git a/Tests/Test_DoubleNavigation.cs b/Tests/Test_DoubleNavigation.cs index a8a534b8..17a564a7 100644 --- a/Tests/Test_DoubleNavigation.cs +++ b/Tests/Test_DoubleNavigation.cs @@ -13,13 +13,10 @@ using System.Threading; using System.Threading.Tasks; using System.Windows.Threading; - using MVVM.Cef.Glue.CefGlueHelper; - using Xunit; using FluentAssertions; using NSubstitute; - using MVVM.HTML.Core.Infra; using MVVM.ViewModel.Infra; using MVVM.ViewModel; @@ -28,25 +25,19 @@ namespace MVVM.Cef.Glue.Test { - - - - public class Test_DoubleNavigation { - public Test_DoubleNavigation() { } - private WindowTest BuildWindow(Func iWebControlFac, bool iManageLifeCycle, bool Cef=true) + private WindowTest BuildWindow(Func iWebControlFac, bool iManageLifeCycle, bool Cef = true) { if (Cef) { HTMLEngineFactory.Engine.Register(new CefGlueWPFWebWindowFactory()); } - return new WindowTest( (w) => { @@ -57,11 +48,9 @@ private WindowTest BuildWindow(Func iWebControlFac, bool iManageLife if (iManageLifeCycle) w.Closed += (o, e) => { iWebControl.Dispose(); }; stackPanel.Children.Add(iWebControl); - } - ); + }); } - internal void TestNavigation(Action Test, bool iDebug = false, bool iManageLifeCycle = true) { AssemblyHelper.SetEntryAssembly(); @@ -264,7 +253,6 @@ public void Test_HTMLWindow_Event() nea.Should().NotBeNull(); nea.OldViewModel.Should().BeNull(); nea.NewViewModel.Should().Be(a); - } private void Test_HTMLWindowRecovery_Capacity_Base(IWebSessionWatcher iWatcher) @@ -331,9 +319,6 @@ private void Test_HTMLWindowRecovery_Capacity_Base(IWebSessionWatcher iWatcher) // mre.Set(); //}); //np.Should().NotBe(p); - - - }); } @@ -388,7 +373,6 @@ public void Test_HTMLWindowRecovery_UnderClosure_Capacity_Base() }, false, false); } - private void Test_HTMLWindow_WebCoreShutDown_Base(IWebSessionWatcher iWatcher) { var a = new A1(); @@ -686,11 +670,8 @@ public void Test_WPFBrowserNavigator_Navition_3_screens() WindowTest.RunOnUIThread( () => { - wpfnav.NavigateAsync(a1, "NewPath").ContinueWith - ( - t => - { - //a1.Navigation.Should().Be(wpfnav); + wpfnav.NavigateAsync(a1, "NewPath").ContinueWith ( + t => { a1.Navigation.Should().NotBeNull(); a2.Navigation.Should().BeNull(); mre.Set(); @@ -730,7 +711,6 @@ public void Test_WPFBrowserNavigator_Navition_Simple_2() WindowTest.RunOnUIThread(() => { - //a1.Navigation.Should().Be(wpfnav); a1.Navigation.Should().NotBeNull(); }); @@ -775,7 +755,6 @@ public void Test_WPFBrowserNavigator_Navigation_ToSame() WindowTest.RunOnUIThread(() => { - //a1.Navigation.Should().Be(wpfnav); a1.Navigation.Should().NotBeNull(); }); @@ -821,7 +800,6 @@ public void Test_WPFBrowserNavigator_Navigation_ToNull() WindowTest.RunOnUIThread(() => { - //a1.Navigation.Should().Be(wpfnav); a1.Navigation.Should().NotBeNull(); }); @@ -876,7 +854,6 @@ public void Test_WPFBrowserNavigator_Navition_Resolve_OnBaseType() WindowTest.RunOnUIThread(() => { - //a1.Navigation.Should().Be(wpfnav); a1.Navigation.Should().NotBeNull(); }); @@ -887,8 +864,6 @@ public void Test_WPFBrowserNavigator_Navition_Resolve_OnBaseType() }); } - //string.Format("{0}\\{1}", Assembly.GetCallingAssembly().GetPath(), iPath) - [Fact] public void Test_WPFBrowserNavigator_Navition_Resolve_OnName_alernativesignature() { @@ -913,7 +888,6 @@ public void Test_WPFBrowserNavigator_Navition_Resolve_OnName_alernativesignature WindowTest.RunOnUIThread(() => { - //a1.Navigation.Should().Be(wpfnav); a1.Navigation.Should().NotBeNull(); }); @@ -933,7 +907,6 @@ public void Test_WPFBrowserNavigator_Navition_Resolve_OnName_alernativesignature WindowTest.RunOnUIThread(() => { - //a1.Navigation.Should().Be(wpfnav); a1.Navigation.Should().NotBeNull(); }); @@ -971,12 +944,9 @@ public void Test_WPFBrowserNavigator_Navition_Resolve_OnName() WindowTest.RunOnUIThread(() => { - //a1.Navigation.Should().Be(wpfnav); a1.Navigation.Should().NotBeNull(); }); - - Thread.Sleep(1000); WindowTest.RunOnUIThread( @@ -996,7 +966,6 @@ public void Test_WPFBrowserNavigator_Navition_Resolve_OnName() WindowTest.RunOnUIThread(() => { - //a1.Navigation.Should().Be(wpfnav); a1.Navigation.Should().NotBeNull(); }); @@ -1026,7 +995,6 @@ public void Test_WPFBrowserNavigator_Navition_Resolve_NotFound() Action wf = () => wpfnav.NavigateAsync(a1); wf.ShouldThrow(); }); - }); } @@ -1075,8 +1043,6 @@ public void Test_WPFBrowserNavigator_Navition_Debug_One() safe.ShouldNotThrow(); }); - - wpfnav.Should().NotBeNull(); wpfbuild.Register("javascript\\navigation_1.html"); wpfbuild.Register("javascript\\navigation_2.html", "Special"); @@ -1084,14 +1050,9 @@ public void Test_WPFBrowserNavigator_Navition_Debug_One() wpfnav.UseINavigable = true; wpfnav.UseINavigable.Should().BeTrue(); - //wpfnav.EnableBrowserDebug = true; - //wpfnav.EnableBrowserDebug.Should().BeTrue(); - wpfnav.OnNavigate += wpfnav_OnNavigate; wpfnav.OnNavigate -= wpfnav_OnNavigate; - - var a1 = new A2(); var mre = new ManualResetEvent(false); @@ -1111,7 +1072,6 @@ public void Test_WPFBrowserNavigator_Navition_Debug_One() wpfnav.OpenDebugBrowser(); }); - WindowTest.RunOnUIThread(() => { wpfnav.Focus(); @@ -1150,7 +1110,6 @@ public void Test_WPFBrowserNavigator_Navition_Debug_One_NoDebug() }); } - void wpfnav_OnNavigate(object sender, NavigationEvent e) { } @@ -1169,7 +1128,6 @@ public void Test_WPFBrowserNavigator_Navition_Resolve_OnBaseType_UsingName() var a1 = new A1(); var mre = new ManualResetEvent(false); - WindowTest.RunOnUIThread( () => { @@ -1180,7 +1138,6 @@ public void Test_WPFBrowserNavigator_Navition_Resolve_OnBaseType_UsingName() WindowTest.RunOnUIThread(() => { - //a1.Navigation.Should().Be(wpfnav); a1.Navigation.Should().NotBeNull(); }); @@ -1214,5 +1171,4 @@ public void Test_WPFBrowserNavigator_Navition_Resolve_OnBaseType_ShoulFailed() }); } } - } diff --git a/Tests/Test_HTMLApp.cs b/Tests/Test_HTMLApp.cs index 3507dcc0..a00dd9f7 100644 --- a/Tests/Test_HTMLApp.cs +++ b/Tests/Test_HTMLApp.cs @@ -77,8 +77,6 @@ public async Task Test_HTMLApp_Start_Should_Create_Session() }); disp.Run(() => target.Run()); - } - } }