Exemplo n.º 1
0
        static ProfileBotCommand ParseAdminCommand(string normalizedMessage)
        {
            switch (normalizedMessage)
            {
            case "validate all users":
                return(ValidateAllProfilesCommand.Create());

            case "notify all users":
                return(NotifyAllProfilesCommand.Create());
            }

            var commandParts = normalizedMessage.Split(' ');

            if (commandParts.Length == 2 && commandParts[1].StartsWith("<@"))
            {
                var verb    = commandParts[0];
                var subject = new SlackStringUser(commandParts[1].ToUpper());
                switch (verb)
                {
                case "validate":
                    return(new ValidateSingleProfileCommand(subject));

                case "notify":
                    return(new NotifySingleProfileCommand(subject));
                }
            }

            return(UnknownCommand.Create());
        }
Exemplo n.º 2
0
        static ProfileBotCommand ParseAdminCommand(string normalizedMessage)
        {
            switch (normalizedMessage)
            {
            case "validate all users":
                return(ValidateAllProfilesCommand.Create());

            case "notify all users":
                return(NotifyAllProfilesCommand.Create());

            case "version":
                return(ShowVersionNumberCommand.Create());

            default:
                var commandParts = normalizedMessage.Split(' ');
                if (commandParts.Length == 2 && commandParts[1].StartsWith("<@") && commandParts[1][commandParts[1].Length - 1] == '>')
                {
                    return(ParseVerbSubjectCommands(commandParts));
                }

                if (normalizedMessage == "whitelist")
                {
                    return(ShowWhitelistedUsersCommand.Create());
                }

                return(UnknownCommand.Create());
            }
        }
Exemplo n.º 3
0
        static ProfileBotCommand ParseVerbSubjectCommands(string[] commandParts)
        {
            var verb        = commandParts[0];
            var slackUserId = commandParts[1].Substring(2, commandParts[1].Length - 3).ToUpper();
            var subject     = new SlackUser {
                Id = slackUserId
            };

            switch (verb)
            {
            case "validate":
                return(new ValidateSingleProfileCommand(subject));

            case "notify":
                return(new NotifySingleProfileCommand(subject));

            case "whitelist":
                return(new WhitelistSingleProfileCommand(subject));

            default:
                return(UnknownCommand.Create());
            }
        }
Exemplo n.º 4
0
 public void Equals_OneUnknownOneNUll_NotEqual()
 {
     Assert.False(UnknownCommand.Create().Equals(null));
 }
Exemplo n.º 5
0
 public void GetHashCode_TwoDifferent_NotEqual()
 {
     Assert.NotEqual(UnknownCommand.Create().GetHashCode(), ValidateAllProfilesCommand.Create().GetHashCode());
 }
Exemplo n.º 6
0
 public void Equals_TwoDifferent_NotEqual()
 {
     // ReSharper disable once SuspiciousTypeConversion.Global
     Assert.False(UnknownCommand.Create().Equals(ValidateAllProfilesCommand.Create()));
 }
Exemplo n.º 7
0
 public void GetHashCode_TwoUnknown_Equal()
 {
     Assert.Equal(UnknownCommand.Create().GetHashCode(), UnknownCommand.Create().GetHashCode());
 }
Exemplo n.º 8
0
 public void Equals_TwoUnknown_Equal()
 {
     Assert.Equal(UnknownCommand.Create(), UnknownCommand.Create());
 }