更新框架
This commit is contained in:
1 parent
ef50fa0620
commit
84b28f9672
72 files changed
+2222
-282
No files matched your search
@@ -0,0 +1,63 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
using Store.Management;
|
||||
using Store.Management.Views;
|
||||
using Store.Management.ViewModels;
|
||||
using Store.Management.Framework.Controls;
|
||||
class Program
|
||||
{
|
||||
[STAThread]
|
||||
static int Main()
|
||||
{
|
||||
var app = new App();
|
||||
app.InitializeComponent();
|
||||
int exitCode = 0;
|
||||
app.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var page = (FrameworkTestPage)((MainWindow)app.MainWindow).Content;
|
||||
var vm = (FrameworkTestPageViewModel)page.DataContext;
|
||||
vm.TestIocCommand.Execute();
|
||||
Check(vm.IocResult.StartsWith("通过"), vm.IocResult);
|
||||
vm.ProductName = " ";
|
||||
await vm.PublishNotificationCommand.Execute();
|
||||
Check(vm.NotificationResult == "请输入商品名称。", "通知输入校验");
|
||||
vm.ProductName = "通知测试商品";
|
||||
await vm.PublishNotificationCommand.Execute();
|
||||
Check(vm.NotificationResult.StartsWith("通知处理完成")
|
||||
&& vm.NotificationResult.Contains("缓存模块")
|
||||
&& vm.NotificationResult.Contains("审计模块")
|
||||
&& vm.NotificationResult.Contains(vm.ProductName), vm.NotificationResult);
|
||||
vm.ShowModelessCommand.Execute();
|
||||
var dialog = app.Windows.OfType<DialogWindow>().Single();
|
||||
var dialogVm = (FrameworkTestDialogViewModel)dialog.DataContext;
|
||||
Check(dialogVm.Message == vm.DialogInput, "Dialog input");
|
||||
dialogVm.Message = " ";
|
||||
dialogVm.ConfirmCommand.Execute(null);
|
||||
Check(dialog.IsVisible && dialogVm.ErrorMsg.Length > 0, "Empty validation");
|
||||
dialogVm.Message = "返回测试";
|
||||
dialogVm.ConfirmCommand.Execute(null);
|
||||
Check(vm.DialogResult == "确认:返回测试", vm.DialogResult);
|
||||
vm.ShowModelessCommand.Execute();
|
||||
app.Windows.OfType<DialogWindow>().Single().Close();
|
||||
Check(vm.DialogResult.Contains("None"), vm.DialogResult);
|
||||
_ = app.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(() =>
|
||||
((FrameworkTestDialogViewModel)app.Windows.OfType<DialogWindow>().Single().DataContext).CancelCommand.Execute(null)));
|
||||
vm.ShowModalCommand.Execute();
|
||||
Check(vm.DialogResult.Contains("Cancel"), vm.DialogResult);
|
||||
vm.DialogInput = " ";
|
||||
vm.ShowModalCommand.Execute();
|
||||
Check(!app.Windows.OfType<DialogWindow>().Any(), "Empty input blocks dialog");
|
||||
Console.WriteLine("PASS: startup, view model wiring, IoC, modeless/modal dialogs, parameters, validation, confirm/cancel/window-close.");
|
||||
}
|
||||
catch (Exception ex) { Console.Error.WriteLine(ex); exitCode = 1; }
|
||||
finally { app.Shutdown(); }
|
||||
}));
|
||||
app.Run();
|
||||
return exitCode;
|
||||
}
|
||||
static void Check(bool success, string message) { if (!success) throw new Exception(message); }
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user