Exemple #1
0
        public void CanRecordCommands()
        {
            var jax = SheepJaxed.Dynamic(cmd =>
            {
                cmd.CommandOne(1, "one");
                cmd.CommandTwo("Two", 2, null);
            });

            jax.Invocations.Should().HaveCount(2);
            jax.Invocations.ElementAt(0).FunctionName.Should().Be("CommandOne");
            jax.Invocations.ElementAt(0).Args.Should().BeEquivalentTo(1, "one");
            jax.Invocations.ElementAt(1).FunctionName.Should().Be("CommandTwo");
            jax.Invocations.ElementAt(1).Args.Should().BeEquivalentTo("Two", 2, null);
        }
Exemple #2
0
 public ActionResult Baam(string nick)
 {
     return(SheepJaxed.On <ISanta>().Comet(cmd =>
     {
         cmd.SayGood("Hello, " + nick);
         Thread.Sleep(1500);
         cmd.SayBad("Secondly... you're bad, " + nick);
         Thread.Sleep(2000);
         cmd.SayBad("Oh " + nick + " you're still so baaad!!");
         Thread.Sleep(2000);
         cmd.SayGood(nick + ", oh you're now oh so good!!");
         Thread.Sleep(2000);
         cmd.Shout(nick + ", I'm done with you!");
     }));
 }
Exemple #3
0
 public ActionResult Baam(string nick)
 {
     return(SheepJaxed.On <ISanta>().Comet(cmd =>
     {
         var tcs = new TaskCompletionSource <object>();
         GoodMsgSent += msg => cmd.SayGood(FormatMsg(nick, msg));
         BadMsgSent += msg => cmd.SayBad(FormatMsg(nick, msg));
         Shout += msg => cmd.Shout(FormatMsg(nick, msg));
         Done += delegate
         {
             cmd.Shout(nick + ", all done!! You're signed out.");
             tcs.SetResult(null);
         };
         return tcs.Task;
     }));
 }
Exemple #4
0
        public ActionResult UpdateItem(int id, int qty)
        {
            return(SheepJaxed.On <ICartCommands>(cmd =>
            {
                var item = CartItem.All().First(x => x.Id == id);
                item.Qty = qty;

                if (item.Qty == 0)
                {
                    cmd.RemoveItem();
                }
                else if (item.Qty < 0)
                {
                    cmd.MarkInvalid();
                }
                else
                {
                    cmd.ChangeTotalPrice(item.TotalPrice);
                }
            }));
        }