public void OnPostVote(string id) { ImageManagement imageManagement = new ImageManagement(); imageManagement.ApplyVote(_imageDirectory?.Images, id); TotalNumberOfVotes = imageManagement.GetTotalNumberOfVotes(_imageDirectory?.Images).GetValueOrDefault(); }
public void TestApplyVoteWithExistantId() { var imagesList = new List <Image> { new Image { Id = "1" }, new Image { Id = "2" }, new Image { Id = "3" } }; imageManagement.ApplyVote(imagesList, "1"); Assert.AreEqual(1, imagesList[0].Votes); Assert.AreEqual(0, imagesList[1].Votes); Assert.AreEqual(0, imagesList[2].Votes); }