Example #1
0
        public void TestTextCommandParsingExecute() {
            var textCommands = new TextCommandController() {
                //Languages = languages,
                Connection = new ConnectionController() {
                    Protocol = new SandboxProtocolController() {
                        SandboxedProtocol = new MockProtocol() {
                            Additional = "",
                            Password = ""
                        }
                    }
                }.Execute() as ConnectionController
            };

            textCommands.Execute();

            textCommands.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.TextCommandsRegister,
                Parameters = new List<ICommandParameter>() {
                    new CommandParameter() {
                        Data = {
                            TextCommands = new List<TextCommandModel>() {
                                new TextCommandModel() {
                                    PluginGuid = Guid.NewGuid(),
                                    PluginCommand = "Command1",
                                    Commands = new List<String>() {
                                        "ExecuteTest"
                                    }
                                }
                            }
                        }
                    }
                }
            });

            Assert.AreEqual(1, textCommands.TextCommands.Count);
            Assert.AreEqual("ExecuteTest", textCommands.TextCommands.First().Commands.First());

            ICommandResult result = textCommands.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.TextCommandsExecute,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "ExecuteTest stuff"
                })
            });

            Assert.IsTrue(result.Success);
            Assert.AreEqual(CommandResultType.Success, result.CommandResultType);
        }
Example #2
0
        public void TestTextCommandParsingExecuteUsePreferredLanguage() {
            var security = (SecurityController)new SecurityController().Execute();

            security.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.SecurityAddGroup,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "TestGroup"
                })
            });
            security.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.SecurityGroupAddAccount,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "TestGroup",
                    "Phogue"
                })
            });
            security.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.SecurityAccountAddPlayer,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "Phogue",
                    CommonProtocolType.DiceBattlefield3,
                    "EA_63A9F96745B22DFB509C558FC8B5C50F"
                })
            });
            security.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.SecurityAccountSetPreferredLanguageCode,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "Phogue",
                    "de-DE"
                })
            });
            security.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.SecurityGroupSetPermission,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "TestGroup",
                    CommandType.TextCommandsExecute,
                    100
                })
            });

            var textCommands = new TextCommandController() {
                Shared = {
                    Security = security
                },
                //Languages = languages,
                Connection = new ConnectionController() {
                    Protocol = new SandboxProtocolController() {
                        SandboxedProtocol = new MockProtocol() {
                            Additional = "",
                            Password = ""
                        }
                    }
                }.Execute() as ConnectionController
            };

            textCommands.Execute();

            textCommands.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.TextCommandsRegister,
                Parameters = new List<ICommandParameter>() {
                    new CommandParameter() {
                        Data = {
                            TextCommands = new List<TextCommandModel>() {
                                new TextCommandModel() {
                                    PluginGuid = Guid.NewGuid(),
                                    PluginCommand = "Command1",
                                    Commands = new List<String>() {
                                        "ExecuteTest"
                                    }
                                }
                            }
                        }
                    }
                }
            });

            Assert.AreEqual(1, textCommands.TextCommands.Count);
            Assert.AreEqual("ExecuteTest", textCommands.TextCommands.First().Commands.First());

            ICommandResult result = textCommands.Tunnel(new Command() {
                Origin = CommandOrigin.Plugin,
                Authentication = {
                    Username = "******"
                },
                CommandType = CommandType.TextCommandsExecute,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "ExecuteTest stuff"
                })
            });

            Assert.IsTrue(result.Success);
            Assert.AreEqual(CommandResultType.Success, result.CommandResultType);
        }
        protected TextCommandController CreateTextCommandController() {
            var security = (SecurityController)new SecurityController().Execute();

            security.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.SecurityAddGroup,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "GroupName"
                })
            });
            security.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.SecurityGroupAddAccount,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "GroupName",
                    "Phogue"
                })
            });
            security.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.SecurityAccountAddPlayer,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "Phogue",
                    CommonProtocolType.DiceBattlefield3,
                    "EA_63A9F96745B22DFB509C558FC8B5C50F"
                })
            });

            var textCommandController = new TextCommandController() {
                Shared = {
                    Security = security
                },
                //Languages = languages,
                Connection = new ConnectionController() {
                    Protocol = new SandboxProtocolController() {
                        SandboxedProtocol = new MockProtocol() {
                            Additional = "",
                            Password = ""
                        }
                    },
                    ConnectionModel = {
                        ProtocolType = new ProtocolType() {
                            Name = CommonProtocolType.DiceBattlefield3,
                            Provider = "Myrcon",
                            Type = CommonProtocolType.DiceBattlefield3
                        }
                    }
                }
            };

            textCommandController.Execute();

            textCommandController.TextCommands.AddRange(new List<TextCommandModel>() {
                TextCommandKick,
                TextCommandChangeMap,
                TextCommandCalculate,
                TextCommandTest
            });

            textCommandController.Connection.ProtocolState.Players.TryAdd(PlayerPhogue.Uid, PlayerPhogue);
            textCommandController.Connection.ProtocolState.Players.TryAdd(PlayerImisnew2.Uid, PlayerImisnew2);
            textCommandController.Connection.ProtocolState.Players.TryAdd(PlayerPhilK.Uid, PlayerPhilK);
            textCommandController.Connection.ProtocolState.Players.TryAdd(PlayerMorpheus.Uid, PlayerMorpheus);
            textCommandController.Connection.ProtocolState.Players.TryAdd(PlayerIke.Uid, PlayerIke);
            textCommandController.Connection.ProtocolState.Players.TryAdd(PlayerPapaCharlie9.Uid, PlayerPapaCharlie9);
            textCommandController.Connection.ProtocolState.Players.TryAdd(PlayerEBassie.Uid, PlayerEBassie);
            textCommandController.Connection.ProtocolState.Players.TryAdd(PlayerZaeed.Uid, PlayerZaeed);
            textCommandController.Connection.ProtocolState.Players.TryAdd(PlayerPhogueIsAButterfly.Uid, PlayerPhogueIsAButterfly);
            textCommandController.Connection.ProtocolState.Players.TryAdd(PlayerSayaNishino.Uid, PlayerSayaNishino);
            textCommandController.Connection.ProtocolState.Players.TryAdd(PlayerMrDiacritic.Uid, PlayerMrDiacritic);

            textCommandController.Connection.ProtocolState.Items = new ConcurrentDictionary<String, ItemModel>(textCommandController.Connection.ProtocolState.Players.Values.SelectMany(player => player.Inventory.Now.Items).ToDictionary(i => i.Name, i => i));

            textCommandController.Connection.ProtocolState.MapPool.TryAdd(String.Format("{0}/{1}", MapPortValdez.GameMode.Name, MapPortValdez.Name), MapPortValdez);
            textCommandController.Connection.ProtocolState.MapPool.TryAdd(String.Format("{0}/{1}", MapValparaiso.GameMode.Name, MapValparaiso.Name), MapValparaiso);
            textCommandController.Connection.ProtocolState.MapPool.TryAdd(String.Format("{0}/{1}", MapPanamaCanal.GameMode.Name, MapPanamaCanal.Name), MapPanamaCanal);

            return textCommandController;
        }