예제 #1
0
 public IActionResult Create(Madword model)
 {
     model.MadwordDate   = DateTime.Now;
     model.MadwordRating = 1;
     // Store the model in the database
     repo.AddMadword(model);
     return(View(model));
 }
예제 #2
0
        public void AddMadwordTest()
        {
            // Arrange
            var fakeRepo   = new FakeMadwordRepository();
            var controller = new MadwordController(fakeRepo);
            var madword    = new Madword()
            {
                MadwordTitle  = "New Madword Title",
                MadwordTopic  = "New Topic",
                AuthorName    = "Author",
                MadwordRating = 5,
                MadwordText   = "MADWORD TEXT"
            };

            // Act
            controller.Create(madword);

            // Assert
            // Ensure that the review was added to the repository
            var retrievedMadword = fakeRepo.Madwords.ToList()[0];

            Assert.Equal(0, System.DateTime.Now.Date.CompareTo(retrievedMadword.MadwordDate.Date));
        }
예제 #3
0
 public void AddMadword(Madword madword)
 {
     context.Madwords.Add(madword);
     context.SaveChanges();
 }
예제 #4
0
 public void AddMadword(Madword madword)
 {
     madword.MadwordID = madwords.Count;
     madwords.Add(madword);
 }