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); }
public void ScanVoteData_InvalidData() { File.WriteAllText(SPHModel.VoteFile, "NOT_A_VALID_JSON"); Assert.False(SPHModel.ScanVoteData()); Assert.True(SPHModel.Votes.Count == 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()); }
public void ScanVoteData_FileNotExist() { Assert.False(SPHModel.ScanVoteData()); Assert.True(SPHModel.Votes.Count == 0); }