Esempio n. 1
0
        public void TestJsonDeserializationEmptyParameterList() {
            Command original = new Command() {
                CommandType = CommandType.VariablesSet,
                Authentication = {
                    Username = "******",
                    PasswordPlainText = "password"
                }
            };

            ICommand deserialized = CommandServerSerializer.DeserializeCommand(new CommandServerPacket() {
                Content = JsonConvert.SerializeObject(original),
                Headers = new WebHeaderCollection() {
                    { HttpRequestHeader.ContentType, Mime.ApplicationJson }
                }
            });

            Assert.AreEqual(original.CommandType.ToString(), deserialized.Name);
            Assert.AreEqual(original.Authentication.Username, deserialized.Authentication.Username);
            Assert.AreEqual(original.Authentication.PasswordPlainText, deserialized.Authentication.PasswordPlainText);
            Assert.IsNull(deserialized.Parameters);
        }
Esempio n. 2
0
        public IConfigCommand ToConfigCommand() {
            ICommand command = new Command(this);

            // If the scope model does not have any useful information within.
            if (this.Scope != null && this.Scope.ConnectionGuid == Guid.Empty && this.Scope.PluginGuid == Guid.Empty) {
                // Null it out. This avoids storing empty GUID's for no reason.
                command.Scope = null;
            }

            // Commands loaded from the config will always run as local commands.
            command.Authentication = null;

            return new ConfigCommand() {
                Command = command
            };
        }