Example #1
0
 private void BtnWithdraw_Click(object sender, RoutedEventArgs e)
 {
     if (decimal.TryParse(TxtAmount.Text, out decimal bedrag))
     {
         try
         {
             ActiveAccount.Withdraw(bedrag);
         }
         catch (ArgumentException ex)
         {
             MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         }
         catch (InvalidOperationException ex)
         {
             MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
         }
         UpdateGUI();
     }
     else
     {
         MessageBox.Show("Invalid amount entered.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         TxtAmount.Focus();
         TxtAmount.Select(0, TxtAmount.Text.Length);
     }
 }
        public void When_calling_GetById_after_every_10_events_a_new_snap_shot_will_be_created_11_events()
        {
            var activeAccount = ActiveAccount.CreateNew(Guid.NewGuid(), "AccountName");

            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(2));
            activeAccount.Deposite(new Amount(3));
            activeAccount.Deposite(new Amount(4));
            activeAccount.Deposite(new Amount(5));
            activeAccount.Deposite(new Amount(6));
            activeAccount.Deposite(new Amount(7));
            activeAccount.Deposite(new Amount(8));
            activeAccount.Deposite(new Amount(9));
            activeAccount.Deposite(new Amount(10));

            _repository.Add(activeAccount);
            _eventStoreUnitOfWork.Commit();

            var sut = _repository.GetById <ActiveAccount>(activeAccount.Id);

            try
            {
                sut.Withdrawl(new Amount(55));
            }
            catch (Exception Ex)
            {
                Assert.Fail(string.Format("This should not fail: {0}", Ex.Message));
            }

            sut.Withdrawl(new Amount(1));
        }
Example #3
0
        private void BtnOkTransaction_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(TxtBoxAmount.Text) ||
                !double.TryParse(TxtBoxAmount.Text, out double amount))
            {
                MessageBox.Show("Ange ett belopp först!");
                return;
            }

            if (RadioBtnWithdraw.IsChecked.Value)
            {
                if (ActiveAccount.TryWithdraw(amount, out _))
                {
                    TxtBlockWithdrawals.Text +=
                        $"{DateTime.Now.ToString("yyyy-MM-dd hh:mm")} - {RadioBtnWithdraw.Content} - {amount}kr\n";
                }
                else
                {
                    MessageBox.Show("Du saknar täckning på kontot.");
                    return;
                }
            }
            else
            {
                ActiveAccount.Deposit(amount);
                TxtBlockWithdrawals.Text +=
                    $"{DateTime.Now.ToString("yyyy-MM-dd hh:mm")} - {RadioBtnDeposit.Content} - {amount}kr\n";
            }

            int sIndex = ComboBoxAccount.SelectedIndex;

            ComboBoxAccount.SelectedIndex = -1;
            ComboBoxAccount.Items.Refresh();
            ComboBoxAccount.SelectedIndex = sIndex;
        }
        public void When_calling_Save_after_more_than_9_events_after_the_last_snap_shot_a_new_snapshot_will_be_created_10_events_after_last_snapshot_9_events_after_last_snapshot_verify_all_event_counts()
        {
            var activeAccount = ActiveAccount.CreateNew(Guid.NewGuid(), "AccountName");

            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));

            _repository.Add(activeAccount);
            _eventStoreUnitOfWork.Commit();
            _domainEventStorage.SaveShapShot(activeAccount);

            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));

            _repository.Add(activeAccount);
            _eventStoreUnitOfWork.Commit();

            Assert.That(_domainEventStorage.GetEventsSinceLastSnapShot(activeAccount.Id).Count(), Is.EqualTo(9));
            Assert.That(_domainEventStorage.GetAllEvents(activeAccount.Id).Count(), Is.EqualTo(19));
        }
Example #5
0
        public ActiveAccount CreateNewAccount(string accountName)
        {
            IsClientCreated();

            var activeAccount = ActiveAccount.CreateNew(Id, accountName);

            Apply(new AccountToClientAssignedEvent(activeAccount.Id));

            return(activeAccount);
        }
Example #6
0
    void Awake()
    {
        var AM = AssetDatabase.LoadAssetAtPath <GameObject> (AccountManagerPath);

        Manager       = AM.GetComponent <RegisterSystem> ();
        ManagerForget = AM.GetComponent <forgetPassword> ();
        ManagerLogin  = AM.GetComponent <LoginSystem> ();
        ManagerReset  = AM.GetComponent <ResetPassword> ();
        ManagerActive = AM.GetComponent <ActiveAccount> ();
    }
        public void When_calling_Save_it_will_add_the_domain_events_to_the_domain_event_storage()
        {
            var activeAccount = ActiveAccount.CreateNew(Guid.NewGuid(), "AccountName");

            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));

            _repository.Add(activeAccount);
            _eventStoreUnitOfWork.Commit();

            Assert.That(_domainEventStorage.GetEventsSinceLastSnapShot(activeAccount.Id).Count(), Is.EqualTo(3));
            Assert.That(_domainEventStorage.GetAllEvents(activeAccount.Id).Count(), Is.EqualTo(3));
        }
        public void When_calling_Save_it_will_reset_the_domain_events()
        {
            var activeAccount = ActiveAccount.CreateNew(Guid.NewGuid(), "AccountName");

            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));

            _repository.Add(activeAccount);
            _eventStoreUnitOfWork.Commit();

            var activeAccountForRepository = (IEventProvider <IDomainEvent>)activeAccount;

            Assert.That(activeAccountForRepository.GetChanges().Count(), Is.EqualTo(0));
        }
Example #9
0
        public void AddLocalDirectoryLink(string repositoryName, string repositoryId)
        {
            VstsProject currentProject = ActiveAccount.CurrentProject(_gitConfiguration.GitDirectory);

            currentProject.Repositories.Add(new RepositoryRegistration
            {
                Name      = repositoryName,
                Id        = repositoryId,
                Directory = _gitConfiguration.GitDirectory
            });

            var json = JsonConvert.SerializeObject(Accounts, Formatting.Indented);

            File.WriteAllText(VstsCliConfigPath, json);
        }
        public void When_calling_Save_after_more_than_9_events_a_new_snap_shot_will_be_created_9_events_will_not()
        {
            var activeAccount = ActiveAccount.CreateNew(Guid.NewGuid(), "AccountName");

            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));

            _repository.Add(activeAccount);
            _eventStoreUnitOfWork.Commit();

            Assert.That(_domainEventStorage.GetSnapShot(activeAccount.Id), Is.Null);
        }
        public void When_calling_Save_after_more_than_9_events_after_the_last_snap_shot_a_new_snapshot_will_be_created_10_events_after_last_snapshot()
        {
            var activeAccount = ActiveAccount.CreateNew(Guid.NewGuid(), "AccountName");

            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));

            _repository.Add(activeAccount);
            _eventStoreUnitOfWork.Commit();
            _domainEventStorage.SaveShapShot(activeAccount);

            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));

            _repository.Add(activeAccount);
            _eventStoreUnitOfWork.Commit();

            var snapShot = _domainEventStorage.GetSnapShot(activeAccount.Id);

            Assert.That(snapShot, Is.Not.Null);
            Assert.That(snapShot.Memento, Is.InstanceOfType(typeof(ActiveAccountMemento)));
        }
Example #12
0
    void OnGUI()
    {
        if (_window != null)
        {
            GUI.contentColor = Color.red;              // Apply Red color to Button
            GUILayout.Label("PHP Source Folder & Secure Key", EditorStyles.boldLabel);

            URL = EditorGUILayout.TextField("Folder URL", URL);
            Key = EditorGUILayout.TextField("Secure Key", Key);

            GUILayout.Label("First Step : Before Login", EditorStyles.boldLabel);
            GUILayout.Label(MSG);

            AccountManager = (GameObject)EditorGUILayout.ObjectField("Account Manager:", AccountManager, typeof(GameObject), true);
            if (GUILayout.Button("Configure ! STEP 1") && AccountManager != null)
            {
                LoginManager    = AccountManager.GetComponent <LoginSystem> ();
                RegisterManager = AccountManager.GetComponent <RegisterSystem> ();
                ForgetManager   = AccountManager.GetComponent <forgetPassword> ();
                ResetManager    = AccountManager.GetComponent <ResetPassword> ();
                ActiveManager   = AccountManager.GetComponent <ActiveAccount> ();
                //			AccountM = Manager.GetComponent<AccountSystem>();

                PlayerPrefs.SetString("registerURL", URL + "/register.php");

                PlayerPrefs.SetString("LoginUrl", URL + "/login.php");
                ManagerLogin.LoginUrl       = URL + "/login.php";
                LoginManager.LoginUrl       = URL + "/login.php";
                ManagerLogin.SecureKey      = Key;
                ManagerLogin.checkBannedUrl = URL + "/checkbanned.php";
                ManagerLogin.checkBannedUrl = URL + "/checkbanned.php";
                Manager.securePassword      = Key;
                Manager.checkBannedUrl      = URL + "/checkbanned.php";
                Manager.RegisterUrl         = URL + "/register.php";

                RegisterManager.checkBannedUrl = URL + "/checkbanned.php";
                ManagerForget.UrlSendCode      = URL + "/sendcode.php";
                ForgetManager.UrlSendCode      = URL + "/sendcode.php";
                ManagerForget.securePassword   = Key;
                ManagerReset.ResetUrl          = URL + "/resetpassword.php";
                ResetManager.ResetUrl          = URL + "/resetpassword.php";
                ManagerReset.securePassword    = Key;
                ManagerActive.activeURL        = URL + "/activeaccount.php";
                ManagerActive.resendURL        = URL + "/resendactive.php";
                ManagerActive.securePassword   = Key;
                ActiveManager.activeURL        = URL + "/activeaccount.php";
                ActiveManager.resendURL        = URL + "/resendactive.php";


                PlayerPrefs.SetString("UrlSendCode", URL + "/sendcode.php");

                PlayerPrefs.SetString("ResetUrl", URL + "/resetpassword.php");

                PlayerPrefs.SetString("UpdateURL", URL + "/update.php");

                PlayerPrefs.SetString("RefreshURL", URL + "/refresh.php");
                PlayerPrefs.SetString("ActiveAccountURL", URL + "/activeaccount.php");
                PlayerPrefs.SetString("CheckBanned", URL + "/checkbanned.php");
                PlayerPrefs.SetString("ResendActive", URL + "/resendactive.php");



                _window.Close();
                success_window = (gaseditor)EditorWindow.GetWindow(typeof(gaseditor), true, "Done !");
                //Manager.registerURL = "ololo";
                //Manager.oo = ":";

                EditorUtility.SetDirty(AccountManager);

                AssetDatabase.Refresh();
            }

            GUILayout.Label("Second Step: After Login", EditorStyles.boldLabel);
            GUILayout.Label(MSG2);

            MAS = (GameObject)EditorGUILayout.ObjectField("Manager GameObject:", MAS, typeof(GameObject), true);


            if (GUILayout.Button("Configure ! STEP 2") && MAS != null)
            {
                AccountM = MAS.GetComponent <AccountSystem>();


                AccountM.UpdateURL      = URL + "/update.php";
                AccountM.RefreshURL     = URL + "/refresh.php";
                AccountM.securePassword = Key;
                //ManagerLogin.LoginUrl = URL + "/login.php";
                //	ManagerLogin.checkBannedUrl = URL + "/checkbanned.php";
                //Manager.registerURL = URL + "/register.php";
                //Manager.checkBannedUrl = URL + "/checkbanned.php";
                //	ManagerForget.UrlSendCode = URL + "/sendcode.php";
                //	ManagerReset.ResetUrl = URL + "/resetpassword.php";
                //	ManagerActive.activeURL = URL + "/activeaccount.php";
                //	ManagerActive.resendURL = URL + "/resendactive.php";
                PlayerPrefs.SetString("UpdateURL", URL + "/update.php");

                PlayerPrefs.SetString("RefreshURL", URL + "/refresh.php");



                _window.Close();
                success_window2 = (gaseditor)EditorWindow.GetWindow(typeof(gaseditor), true, "Done !");
                //Manager.registerURL = "ololo";
                //Manager.oo = ":";

                EditorUtility.SetDirty(MAS);

                AssetDatabase.Refresh();
            }



            if (AccountManager == null)
            {
                //GUI.contentColor = Color.red;
                MSG = "Please Attach Account Manager !";
            }
            else
            {
                MSG = "Good !";
            }

            if (MAS == null)
            {
                GUI.contentColor = Color.red;
                MSG2             = "Please Attach Manager !";
            }
            else
            {
                MSG2 = "Good !";
            }
        }
        if (success_window != null)
        {
            GUILayout.Label("We Got These :", EditorStyles.boldLabel);

            GUILayout.Label("Register URL : " + PlayerPrefs.GetString("registerURL"));
            GUILayout.Label("Login URL : " + PlayerPrefs.GetString("LoginUrl"));
            GUILayout.Label("Send URL : " + PlayerPrefs.GetString("UrlSendCode"));
            GUILayout.Label("Reset URL : " + PlayerPrefs.GetString("ResetUrl"));
            GUILayout.Label("Active Account URL : " + PlayerPrefs.GetString("ActiveAccountURL"));
            GUILayout.Label("Check Banned URL : " + PlayerPrefs.GetString("CheckBanned"));
            GUILayout.Label("Resend Active URL : " + PlayerPrefs.GetString("ResendActive"));



            if (GUILayout.Button("Seems Good  !"))
            {
                success_window.Close();
            }
            if (GUILayout.Button("Nope ! , Re-Setup"))
            {
                success_window.Close();
                _window = (gaseditor)EditorWindow.GetWindow(typeof(gaseditor), true, "GAS Database Setup");
            }
        }



        if (success_window2 != null)
        {
            GUILayout.Label("We Got These :", EditorStyles.boldLabel);


            GUILayout.Label("Update URL : " + PlayerPrefs.GetString("UpdateURL"));
            GUILayout.Label("Refresh URL : " + PlayerPrefs.GetString("RefreshURL"));



            if (GUILayout.Button("Seems Good  !"))
            {
                success_window2.Close();
            }
            if (GUILayout.Button("Nope ! , Re-Setup"))
            {
                success_window2.Close();
                _window = (gaseditor)EditorWindow.GetWindow(typeof(gaseditor), true, "GAS Database Setup");
            }
        }
    }