public void it_will_call_after_global_listener_with_parameters()
        {
            TransactionWorker.Define("Some transaction").AddStep <DummyStep>().Process(new TransactionContext());

            _listener.Verify(z => z.After(It.Is <ListenerModel>(t => t.TransactionName == "Some transaction")));
            _listener.Verify(z => z.After(It.Is <ListenerModel>(t => t.StepName == typeof(DummyStep).ToString())));
        }
        public void in_case_of_exception_will_call_global_listener_with_params()
        {
            var transaction = TransactionWorker.Define("Some transaction").AddStep <ThrowExceptionStep>();

            var ex = Assert.Throws <CustomException>(() => transaction.Process(new TransactionContext()));

            _listener.Verify(z => z.OnError(It.Is <ListenerModel>(t => t.TransactionName == "Some transaction"), It.IsAny <CustomException>()));
            _listener.Verify(z => z.OnError(It.Is <ListenerModel>(t => t.StepName == typeof(ThrowExceptionStep).ToString()), It.IsAny <CustomException>()));

            Assert.Equal("Some nasty exception", ex.Message);
        }
        public void it_can_chain_multiple_transaction_steps()
        {
            dynamic tranContext = new TransactionContext();

            tranContext.Name           = "Alex";
            tranContext.fhdjfjhdshgjsd = "sfjksdfsdfhks";
            var response = TransactionWorker.Define("Shoud do the do")
                           .AddStep <Step1>()
                           .AddStep <Step2>()
                           .Process(tranContext);

            Assert.Equal(response.Person.FirstName, tranContext.Name);
            Assert.Equal(response.Person.LastName, tranContext.Name);
        }
Example #4
0
        public void Start()
        {
            var parkingWorker     = new ParkingWorker();
            var transactionWorker = new TransactionWorker();

            parkingWorker.Start();
            transactionWorker.Start();

            Router.Instance.Switch("default");

            while (true)
            {
                CurrentMenu.Render();
                var command = Console.ReadLine();
                CurrentMenu.Notify(command);
            }
        }
        public void it_can_run_multiple_transactions()
        {
            dynamic tranContext = new TransactionContext();

            tranContext.Name  = "Alex";
            tranContext.Step3 = "Pasul 3";
            tranContext.Step4 = "Pasul 4";
            tranContext.Step5 = "Pasul 5";

            var response = TransactionWorker.Define("Do a lot of work")
                           .AddStep <FirstTransaction>()
                           .AddStep <SecondTransaction>()
                           .AddStep <Step5>()
                           .Process(tranContext);

            Assert.Equal(response.Result.Step3, "Pasul 3 rezolvat");
            Assert.Equal(response.Result.Step4, "Pasul 4 rezolvat");
            Assert.Equal(response.Result.Step5, "Pasul 5 rezolvat");
            Assert.Equal(response.Person.FirstName, "Alex");
            Assert.Equal(response.Person.LastName, "Alex");
        }
 public TransactionController(DataFactory dataFactory)
 {
     _transactionWorker = (TransactionWorker)dataFactory.GetDataFactory <Transaction>();
     var _paymentScheduleWorker = (PaymentScheduleWorker)dataFactory.GetDataFactory <PaymentSchedule>();
 }
Example #7
0
 /// <summary>
 /// Defines the transaction name
 /// </summary>
 /// <param name="name">Transaction Name</param>
 protected BaseTransaction(string name)
 {
     this._tran = TransactionWorker.Define(name);
 }