Beispiel #1
0
        public void Test1()
        {
            ClientReceiveManager crm = new ClientReceiveManager();

            List <Command> cmdlist = new List <Command>();

            Player p = new Player(null, 0, 0, 0, 0, 0, 0);
            Player x = new Player(null, 0, 0, 0, 0, 0, 0);


            HitCommand cmd  = new HitCommand(p.guid, x.guid, 10);
            HitCommand cmd2 = new HitCommand(x.guid, p.guid, 15);

            cmdlist.Add(cmd);
            cmdlist.Add(cmd2);

            string jsonstring = JsonConvert.SerializeObject(cmdlist);


            List <Command> result = crm.ReceiveString(jsonstring);

            for (int i = 0; i < cmdlist.Count; i++)
            {
                Assert.Equal(cmdlist[i].ToString(), result[i].ToString());
            }
        }
Beispiel #2
0
        internal static Command CreateHitCommand(this OrderChange orderChange)
        {
            HitCommand hitCommand = new HitCommand();

            hitCommand.Content = orderChange.CreateHitXml().ToXmlNode();
            Logger.WarnFormat("CreateHitCommand content = {0}", hitCommand.Content);
            return(hitCommand);
        }
Beispiel #3
0
 private void CommandsCanExecuteChange()
 {
     DealCommand.RaiseCanExecuteChanged();
     HitCommand.RaiseCanExecuteChanged();
     StayCommand.RaiseCanExecuteChanged();
     //SplitCommand.RaiseCanExecuteChanged();
     MakeWagerCommand.RaiseCanExecuteChanged();
 }
Beispiel #4
0
        public void ConstructorOne()
        {
            var button = Button.Down;

            var command = new HitCommand(button);

            Assert.AreEqual(button, command.Button);
            Assert.AreEqual(TimeSpan.Zero, command.Timestamp);
        }
Beispiel #5
0
        public void ConstructorTwo()
        {
            var button    = Button.Down;
            var timestamp = TimeSpan.FromSeconds(3);

            var command = new HitCommand(button, timestamp);

            Assert.AreEqual(button, command.Button);
            Assert.AreEqual(timestamp, command.Timestamp);
        }
Beispiel #6
0
 public Commands(GameViewModel viewModel)
 {
     DealCommand       = new DealCommand(viewModel);
     HitCommand        = new HitCommand(viewModel);
     StandCommand      = new StandCommand(viewModel);
     SplitCommand      = new SplitCommand(viewModel);
     RulesCommand      = new RulesCommand(viewModel);
     HitLeftCommand    = new HitLeftCommand(viewModel);
     StandLeftCommand  = new StandLeftCommand(viewModel);
     HitRightCommand   = new HitRightCommand(viewModel);
     StandRightCommand = new StandRightCommand(viewModel);
 }
Beispiel #7
0
        public void Execute()
        {
            int hits = 0;

            var actuatorRepo = new Mock <IActuator>();

            actuatorRepo.Setup(x => x.Hit(It.IsAny <Button>())).Callback(() => hits++);
            actuatorRepo.Setup(x => x.Press(It.IsAny <Button>())).Callback(() => Assert.Fail());
            actuatorRepo.Setup(x => x.Release(It.IsAny <Button>())).Callback(() => Assert.Fail());

            var button    = Button.Down;
            var timestamp = TimeSpan.FromSeconds(3);
            var command   = new HitCommand(button, timestamp);

            command.Execute(actuatorRepo.Object);

            Assert.AreEqual(1, hits);
        }
        private void HitCommandBtn_Click(object sender, RoutedEventArgs e)
        {
            if (HitIndex > 7) return;
            string xmlPath = this.GetCommandXmlPath("HitCommand");

            XmlDocument doc = new XmlDocument();
            doc.Load(xmlPath);
            XmlNode xmlTran = doc.ChildNodes[1].ChildNodes[HitIndex];

            HitCommand hitCommand;
            hitCommand = new HitCommand(HitIndex);

            XmlDocument xmlDoc = new XmlDocument();
            XmlNode content = xmlDoc.CreateElement("Hit");
            xmlDoc.AppendChild(content);
            hitCommand.Content = content;

            content.AppendChild(xmlDoc.ImportNode(xmlTran, true));

            ManagerClient.AddCommand(hitCommand);
            HitIndex++;
        }
        private static Message Convert(string exchangeCode, HitCommand hitCommand)
        {
            XmlNode ordersNode = hitCommand.Content;
            Order[] orders;

            CommandConvertor.Parse(ordersNode, out orders);
            HitMessage hitMessage = new HitMessage(exchangeCode, orders);
            return hitMessage;
        }