Пример #1
0
        public void should_find_commands_in_type()
        {
            var command = new CommandFinder().FindInType(typeof(CommandFinderTestCommand));

            Assert.That(command, Is.Not.Null);
            Assert.That(command.Name, Is.EqualTo("command-finder-test-command"));
        }
Пример #2
0
        public void CanFindFromAssembly()
        {
            Assembly           assembly  = this.GetType().Assembly;
            IFinder <ICommand> cmdFinder = new CommandFinder(assembly);
            ICommand           cmd       = cmdFinder.Find <FirstTestCommand>();

            Assert.True(cmd != null && cmd.GetType() == typeof(FirstTestCommand));
        }
        public void should_find_actions_in_commands()
        {
            var command = new CommandFinder().FindInType(typeof(CommandActionFinderTestCommand));
            Assert.That(command, Is.Not.Null);

            var actions = new CommandActionFinder().FindInCommand(command);
            Assert.That(actions.Count(), Is.EqualTo(2));
        }
Пример #4
0
        public void CanFindSingleCommand(string assemblyName)
        {
            string             dllFile   = $@"{Directory.GetCurrentDirectory()}\{assemblyName}";
            IFinder <ICommand> cmdFinder = new CommandFinder(dllFile);
            ICommand           cmd       = cmdFinder.Find <FirstTestCommand>();

            Assert.True(cmd != null, $"Did not find '{typeof(FirstTestCommand).Name}'");
            Assert.True(cmd.GetType() == typeof(FirstTestCommand));
        }
Пример #5
0
        public void HelpCommandExecutesSuccessfully()
        {
            string             dllPath   = $@"{Directory.GetCurrentDirectory()}\ecli.dll";
            IFinder <ICommand> cmdFinder = new CommandFinder(dllPath);
            ICommand           cmd       = new Help(cmdFinder);
            bool succeeded = cmd.Execute(String.Empty, null);

            Assert.True(succeeded);
        }
        public void should_find_actions_in_commands()
        {
            var command = new CommandFinder().FindInType(typeof(CommandActionFinderTestCommand));

            Assert.That(command, Is.Not.Null);

            var actions = new CommandActionFinder().FindInCommand(command);

            Assert.That(actions.Count(), Is.EqualTo(2));
        }
Пример #7
0
        /// <summary>
        /// TODO
        /// </summary>
        /// <param name="bytes"></param>
        public void HandleServerCommand(byte[] bytes)
        {
            var parser = new ByteParser(bytes);

            Console.WriteLine($"Received parser id ->{parser.CMD_ID}");
            Console.WriteLine($"Received from Server ->{CommandFinder.Find(parser.CMD_ID)}");
            switch (parser.CMD_ID)
            {
            case ShipInitializationCommand.ID:

                break;
            }

            MainController.Instance.User.RedirectPacket(PacketDestinations.SERVER_TO_CLIENT, bytes);
        }
Пример #8
0
        public void HandleClientCommand(byte[] bytes)
        {
            var parser = new ByteParser(bytes);

            Console.WriteLine($"Received parser id ->{parser.CMD_ID}");
            Console.WriteLine($"Received from Client ->{CommandFinder.Find(parser.CMD_ID)}");

            if (parser.CMD_ID == 666)
            {
                MainForm.Connected = true;
                MainController.Instance.User.RedirectPacket(PacketDestinations.SERVER_TO_CLIENT, ShipInitializationCommand.write(2103, "devsnowy", 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, true, 1, 1, 1, 1, 1, 1, 1, "", 1, false, false, new List <VisualModifierCommand>()));
                Console.WriteLine("STAY ALIIIIVE");
            }

            MainController.Instance.User.RedirectPacket(PacketDestinations.CLIENT_TO_SERVER, bytes);
        }
Пример #9
0
        public void AllNecessaryCommandsFound(int expectedLength, params string[] dllNames)
        {
            IList <string> assemblyNames = new List <string>();

            foreach (string dllName in dllNames)
            {
                string dllFile = $@"{Directory.GetCurrentDirectory()}\{dllName}";
                assemblyNames.Add(dllFile);
            }
            IFinder <ICommand> finder = new CommandFinder(assemblyNames.ToArray());

            ICommand[] foundCommands = finder.FindAll();
            Assert.True(foundCommands.Length == expectedLength);
            bool typesFound = foundCommands.Any(x =>
                                                x.GetType() == typeof(FirstTestCommand) ||
                                                x.GetType() == typeof(SecondTestCommand)
                                                );

            Assert.True(typesFound, "Did not find all commands that implement ICommand");
        }
Пример #10
0
 public void should_find_commands_in_type()
 {
     var command = new CommandFinder().FindInType(typeof(CommandFinderTestCommand));
     Assert.That(command, Is.Not.Null);
     Assert.That(command.Name, Is.EqualTo("command-finder-test-command"));
 }
Пример #11
0
        private IEnumerable <CommandAction> GetTestActions()
        {
            var command = new CommandFinder().FindInType(typeof(ActionSelectorTestCommand));

            return(new CommandActionFinder().FindInCommand(command));
        }
Пример #12
0
 public void should_turn_command_names_to_hyphened_notation()
 {
     var command = new CommandFinder().FindInType(typeof(CommandRunnerTestClass));
     Assert.That(command.Name, Is.EqualTo("command-runner-test-class"));
 }
Пример #13
0
        public void should_turn_command_names_to_hyphened_notation()
        {
            var command = new CommandFinder().FindInType(typeof(CommandRunnerTestClass));

            Assert.That(command.Name, Is.EqualTo("command-runner-test-class"));
        }