Ejemplo n.º 1
0
        public void LoadingReturnsAccounts()
        {
            var service = new Services.ServiceClient(null);
            var vm      = new ViewModels.AccountsViewModel(service, null);

            Thread.Sleep(defaultAsyncWait);
            //No accounts
            Assert.IsFalse((vm.Accounts == null || vm.Accounts.Count == 0), "Service did not return any accounts");
        }
Ejemplo n.º 2
0
        public void LoadingReturnsActiveAccounts()
        {
            var service = new Services.ServiceClient(null);
            var vm      = new ViewModels.AccountsViewModel(service, null);

            Thread.Sleep(defaultAsyncWait);

            if (vm.Accounts != null)
            {
                bool hasInactive = vm.Accounts.Any(w => w.IsActive == false);
                //Active accounts
                Assert.IsFalse(hasInactive, "Service retuned inactive accounts");
            }
        }
Ejemplo n.º 3
0
        public void LoadingReturnsObsoleteAccounts()
        {
            var service = new Services.ServiceClient(null);
            var vm      = new ViewModels.AccountsViewModel(service, null);

            Thread.Sleep(defaultAsyncWait);

            if (vm.Accounts != null)
            {
                DateTime minAccDate = new DateTime(2016, 1, 1);
                bool     hasOld     = vm.Accounts.Any(w => w.Registered < minAccDate);

                //Accounts registered after 2016
                Assert.IsFalse(hasOld, $"Service retuned accounts registerd before {minAccDate.ToString("mm/DD/yyy")}");
            }
        }
Ejemplo n.º 4
0
        private async void OnAccountLogin(object o)
        {
            if (string.IsNullOrWhiteSpace(Login.LoginName))
            {
                ModernDialog.ShowMessage("* 用户名不能为空", "消息", MessageBoxButton.OK);
                return;
            }
            if (string.IsNullOrWhiteSpace(Login.LoginPwd))
            {
                ModernDialog.ShowMessage("* 用户密码不能为空", "消息", MessageBoxButton.OK);
                return;
            }
            Button loginButton = ((Window)o).FindName("btn_Login") as Button;
            try
            {
                loginButton.IsEnabled = false;
                loginButton.Content = "正在登录中……";
                ResultEx result= await TaskEx.Run(() =>
                 {
                     Services.ServiceClient service = new Services.ServiceClient();
                     string value = service.Login(Login.LoginName, Md5.GetMd5String(Login.LoginPwd));
                     return JsonConvert.DeserializeObject<ResultEx>(value);
                 });
                if (result.Result)
                {
                    Login.ErrorMsg = string.Empty;
                    //保存登录配置文件
                    string login = JsonConvert.SerializeObject(Login);
                    SystemConfig.LoginSetting = login;

                    Views.Windows.MainWindow mainWindow = new Views.Windows.MainWindow();
                    Application.Current.MainWindow = mainWindow;
                    ((Window)o).Close();
                    mainWindow.ShowDialog();
                }
                else ModernDialog.ShowMessage(string.Format("* {0}", result.Message), "消息", MessageBoxButton.OK);
            }
            catch (Exception ex)
            {
                ModernDialog.ShowMessage(ex.Message, "消息", MessageBoxButton.OK);
            }
            finally
            {
                loginButton.Content = "登         录";
                loginButton.IsEnabled = true;
            }
        }