Exemplo n.º 1
0
        public VoteScannerTests()
        {
            var players = new Player[]
            {
                new Player { Name = "John0", Participating = true, Aliases = new string[] { "John" } },
                new Player { Name = "Xevious", Participating = true, Aliases = new string[0] },
                new Player { Name = "snowbind", Participating = true, Aliases = new string[0] },
                new Player { Name = "GMass", Participating = true, Aliases = new string[0] },
                new Player { Name = "Liamness", Participating = true, Aliases = new string[0] },
                new Player { Name = "spork", Participating = true, Aliases = new string[0] },
                new Player { Name = "Alask", Participating = true, Aliases = new string[0] },
                new Player { Name = "PaulM", Participating = true, Aliases = new string[0] },
                new Player { Name = "Danster", Participating = true, Aliases = new string[0] },
                new Player { Name = "gospvg", Participating = true, Aliases = new string[0] },
                new Player { Name = "Strategos", Participating = true, Aliases = new string[0] },
                new Player { Name = "bennette98", Participating = true, Aliases = new string[0] },
                new Player { Name = "Don Wiskerando", Participating = true, Aliases = new string[0] },
                new Player { Name = "The Grand Pursuivant", Participating = true, Aliases = new string[0] },
                new Player { Name = "Mr. Blonde", Participating = true, Aliases = new string[0] },
                new Player { Name = "Mr. Violet", Participating = true, Aliases =  new string[] { "Mr Violet", "Violet", "Mr.Violet", "MrViolet" } },
                new Player { Name = "Mr. Viridian", Participating = true, Aliases = new string[] { "Mr.Viridian", "Mr Viridian", "Viridian", "MrViridian" } },
                new Player { Name = "Moderator", Participating = false, Aliases = new string[0] },
                new Player { Name = "Player With Aliases", Participating = true, Aliases = new string[] { "PlayerWithAliases", "PWA" } },
            };

            var mockRepo = new Mock<IRepository>();
            mockRepo.Setup(m => m.FindAllPlayers())
                .Returns(players);

            _voteScanner = new VoteScanner(mockRepo.Object);
        }
Exemplo n.º 2
0
        public void UpsertPlayer(Player player)
        {
            BsonArray recruitments = new BsonArray();

            foreach (var recruitment in player.Recruitments)
            {
                recruitments.Add(new BsonDocument
                    {
                        { "FactionName", recruitment.FactionName },
                        { "Allegiance", recruitment.Allegiance.ToString() },
                        { "ForumPostNumber", recruitment.ForumPostNumber },
                    });
            }

            BsonArray aliases = new BsonArray();

            foreach (var alias in aliases)
            {
                aliases.Add(alias.ToString());
            }

            var newDoc = new BsonDocument
            {
                { "Name", player.Name },
                { "Recruitments", recruitments },
                { "Participating", player.Participating },
                { "Fatality", player.Fatality },
                { "Character", player.Character },
                { "Notes", player.Notes },
                { "Aliases", aliases }
            };

            var filter = Builders<BsonDocument>.Filter.Eq("Name", player.Name);

            Upsert(_players, newDoc, filter);
        }
Exemplo n.º 3
0
        private static Recruitment DetermineRecruitment(Player player, string forumPostNumber)
        {
            foreach (var recruitment in player.Recruitments)
            {
                if (string.Compare(forumPostNumber, recruitment.ForumPostNumber) >= 0)
                {
                    return recruitment;
                }
            }

            string msg = string.Format(
                "Something went wrong with recruitments and stuff. Player name: {0}. Forum Post Number: {1}.",
                player.Name,
                forumPostNumber);

            throw new InvalidOperationException(msg);
        }