Exemple #1
0
        public async Task <Guid> CreateNewAccount()
        {
            var token   = new CancellationToken();
            var command = new CreateNewAccountCommand();

            return(await mediator.Send(command, token));
        }
Exemple #2
0
 public MainWindowViewModel(AuthorizationCommand authorizationCommand, CreateNewAccountCommand createNewAccountCommand,
                            ObservableCollection <User> users)
 {
     AuthorizationCommand    = authorizationCommand;
     CreateNewAccountCommand = createNewAccountCommand;
     Users = users;
 }
Exemple #3
0
        static void Main(string[] args)
        {
            // Using StructureMap for IoC.  You can use Ninject, AutoFac, Windsor, or whatever
            // supports the methods you need to override in SeekUHostConfiguration<T>
            var config = new SeekUHostConfiguration <SeekUDemoDependencyResolver>();

            // Normally you'd configure providers here.  This "in memory" sample
            // uses the default providers, so no configuration is necessary.

            var bus = config.GetCommandBus();

            // I'm not a proponent of Guids for primary keys.  This method returns
            // a sequential Guid to make database sorting behave like integers.
            // http://www.informit.com/articles/article.asp?p=25862
            var id = SequentialGuid.NewId();

            // Create the account
            var newAccountCommand = new CreateNewAccountCommand(id, 950);
            // Simple validation example.
            var validation = bus.Validate(newAccountCommand);

            Console.WriteLine("CreateNewAccountCommand is valid?  {0}", validation.Success);

            bus.Send(new CreateNewAccountCommand(id, 950));

            // Use the account to create a history of events including a snapshot
            bus.Send(new DebitAccountCommand(id, 50));
            bus.Send(new CreditAccountCommand(id, 120));
            bus.Send(new DebitAccountCommand(id, 350));

            Console.Read();
        }
        public void AccountBeginsAsUnfrozenTest()
        {
            var accountId = Guid.NewGuid();

            var command = new CreateNewAccountCommand(accountId);

            _newAccountCreator.Create(command);

            var bankAccountData = _accountRetriever.Retrieve(new BankAccountStateQuery(accountId));

            IsTrue(() => bankAccountData.IsFrozen == false);
        }
Exemple #5
0
        public void Test1()
        {
            var accountId = Guid.NewGuid();

            var command = new CreateNewAccountCommand(accountId);

            _newAccountCreator.Create(command);

            var actual = _accountRetriever.Retrieve(new BankAccountStateQuery(accountId));

            IsTrue(() => actual.Id == accountId);
            IsTrue(() => actual.Balance == 0);
        }
        public void FreezeAccountTest()
        {
            var accountId = Guid.NewGuid();

            var command = new CreateNewAccountCommand(accountId);

            _newAccountCreator.Create(command);

            _customerServiceRepresentative.FreezeAccount(new FreezeAccountCommand(accountId));

            var bankAccountData = _accountRetriever.Retrieve(new BankAccountStateQuery(accountId));

            IsTrue(() => bankAccountData.IsFrozen);
        }
Exemple #7
0
        public void Test2()
        {
            var accountId = Guid.NewGuid();

            var command = new CreateNewAccountCommand(accountId);

            _newAccountCreator.Create(command);

            _cashMachine.Deposit(new MakeDepositCommand(accountId, 5000));

            var actual = _accountRetriever.Retrieve(new BankAccountStateQuery(accountId));

            IsTrue(() => actual.Id == accountId);
            IsTrue(() => actual.Balance == 5000);
        }
        public void FreezeAccountWithdrawalTest()
        {
            var accountId = Guid.NewGuid();

            var command = new CreateNewAccountCommand(accountId);

            _newAccountCreator.Create(command);

            _cashMachine.Deposit(new MakeDepositCommand(accountId, 5000));

            _customerServiceRepresentative.FreezeAccount(new FreezeAccountCommand(accountId));

            Assert.Throws <AccountIsFrozenException>(
                () => { _cashMachine.Withdraw(new MakeWithdrawalCommand(accountId, 2000)); });
        }