Пример #1
0
        public void GetParameterString(
            string command,
            string commandName,
            string expecterParameterString
            )
        {
            var parameterString = SignupImporter.GetParameterString(command, commandName);

            parameterString.Should().Be(expecterParameterString);
        }
Пример #2
0
        public async Task ImportSignups([Remainder] string missionContent = null)
        {
            if (_client.GetGuild(_config.AFGuild)
                .GetUser(Context.User.Id)
                .Roles.All(x => x.Id != _config.MissionMakerRole))
            {
                await ReplyWithException <NotAuthorizedException>("Nie jesteś uprawniony do tworzenia misji.");
            }

            if (SignupsData.Missions.Any(
                    x =>
                    (x.Editing == Mission.EditEnum.New ||
                     x.Editing == Mission.EditEnum.Started) &&
                    x.Owner == Context.User.Id))
            {
                await ReplyWithException <MissionEditionInProgressException>(
                    "Edytujesz bądź tworzysz już misję!");
            }


            if (Context.Message.Attachments.Any(x => x.Filename.Contains(".txt")))
            {
                using var client = new HttpClient();
                var response = await client.GetAsync(Context.Message.Attachments.First().Url);

                missionContent = await response.Content.ReadAsStringAsync();
            }

            if (missionContent is null)
            {
                await ReplyWithException <InvalidCommandParametersException>("Niepoprawne parametry komendy.");
            }

            var signupImporter = new SignupImporter(Context, _commands, _map, this);

            await signupImporter.ProcessMessage(missionContent);

            await ReplyAsync("Zdefiniuj reszte misji.");
        }
Пример #3
0
        public void GetCommandName(string command, string expectedCommandName)
        {
            var commandName = SignupImporter.GetCommandName(command);

            commandName.Should().Be(expectedCommandName);
        }
Пример #4
0
        public void ParseCommands(IEnumerable <string> lines, IEnumerable <string> expectedCommandsList)
        {
            var parsedCommands = (IEnumerable <string>)SignupImporter.ParseCommands(lines);

            parsedCommands.Should().BeEquivalentTo(expectedCommandsList);
        }
Пример #5
0
        public void ReadLines(string message, string[] expectedLines)
        {
            var linesRead = SignupImporter.ReadLines(message);

            linesRead.Should().BeEquivalentTo(expectedLines);
        }
Пример #6
0
        public void GetLineEndings(string message, string expectedLinebreak)
        {
            var lineEnding = SignupImporter.GetLineEnding(message);

            lineEnding.Should().Be(expectedLinebreak);
        }