Example #1
0
        public void GetSearchResults_GetsSearchResults_Results()
        {
            string salt1   = Player.MakeSalt();
            Hash   hash1   = new Hash("password", salt1);
            Player player1 = new Player("thebigtaco", hash1.Result, salt1);

            player1.Save();
            string salt2   = Player.MakeSalt();
            Hash   hash2   = new Hash("password1", salt2);
            Player player2 = new Player("lydianlights", hash2.Result, salt2);

            player2.Save();
            GameStats stats1 = new GameStats(player1.Id, 100, 1, 1000, new DateTime(2013, 10, 3));

            stats1.Save();
            GameStats stats2 = new GameStats(player2.Id, 100000, 100, 9999, new DateTime(2013, 10, 3));

            stats2.Save();

            PlayerListEntry search1 = new PlayerListEntry(player1.Id, player1.Username, stats1.Score);
            PlayerListEntry search2 = new PlayerListEntry(player2.Id, player2.Username, stats2.Score);

            Dictionary <string, PlayerListEntry> result = PlayerListEntry.GetSearchResults("");
            Dictionary <string, PlayerListEntry> test   = new Dictionary <string, PlayerListEntry> {
                { player2.Username, search2 },
                { player1.Username, search1 }
            };

            CollectionAssert.AreEqual(test, result);
        }
Example #2
0
 public SearchModel(string searchTerm, string sessionId) : base(sessionId)
 {
     Results = PlayerListEntry.GetSearchResults(searchTerm);
 }