Exemplo n.º 1
0
        public void ScanVoteData_FileUpdated()
        {
            var votes = new Dictionary <string, UserVote>();

            votes.Add("Level1", new UserVote()
            {
                key = "1111", voteType = "Upvote"
            });
            votes.Add("Level2", new UserVote()
            {
                key = "2222", voteType = "Downvote"
            });

            var serialized = JsonConvert.SerializeObject(votes);

            File.WriteAllText(SPHModel.VoteFile, serialized);

            Assert.True(SPHModel.ScanVoteData());
            Assert.True(SPHModel.Votes.Count == 2);

            votes.Add("Level3", new UserVote()
            {
                key = "3333", voteType = "Upvote"
            });

            serialized = JsonConvert.SerializeObject(votes);
            File.WriteAllText(SPHModel.VoteFile, serialized);

            Assert.True(SPHModel.ScanVoteData());
            Assert.True(SPHModel.Votes.Count == 3);
        }
Exemplo n.º 2
0
        public void ScanVoteData_InvalidData()
        {
            File.WriteAllText(SPHModel.VoteFile, "NOT_A_VALID_JSON");

            Assert.False(SPHModel.ScanVoteData());
            Assert.True(SPHModel.Votes.Count == 0);
        }
Exemplo n.º 3
0
        public void ScanVoteData_EmptyData()
        {
            File.WriteAllText(SPHModel.VoteFile, string.Empty);

            Assert.True(SPHModel.ScanVoteData());
            Assert.True(SPHModel.Votes.Count == 0);
        }
        public static bool Prepare()
        {
            _thumbsUp ??= LoadSpriteFromResource($"SongPlayHistory.Assets.ThumbsUp.png");
            _thumbsDown ??= LoadSpriteFromResource($"SongPlayHistory.Assets.ThumbsDown.png");

            return(SPHModel.ScanVoteData());
        }
Exemplo n.º 5
0
 public void ScanVoteData_FileNotExist()
 {
     Assert.False(SPHModel.ScanVoteData());
     Assert.True(SPHModel.Votes.Count == 0);
 }