示例#1
0
        public void Test_SaveNewCategoryToDatabase_Category()
        {
            //arrange
            //act
            var db       = new To_Do_ListContext();
            var category = new Category {
                Name = "aliens"
            };

            db.Category.Add(category);

            //assert
            System.Console.WriteLine(testQuestion.Prompt);
            System.Console.WriteLine(testQuestion.Option1);
            System.Console.WriteLine(testQuestion.Option2);
            System.Console.WriteLine(testQuestion.Option3);
            System.Console.WriteLine(testQuestion.CorrectAnswer);
            System.Console.WriteLine(total);
            // switch (testQuestion.CorrectAnswer) {
            //     case 1:
            //         Assert.AreEqual(total.ToString(), testQuestion.Option1);
            //         break;
            //     case 2:
            //         Assert.AreEqual(total.ToString(), testQuestion.Option2);
            //         break;
            //     case 3:
            //         Assert.AreEqual(total.ToString(), testQuestion.Option3);
            //         break;
            // }
            Assert.AreEqual(total, 3);
        }
 public static List <Category> GetCategory()
 {
     //this sets up the db connection
     using (var db = new To_Do_ListContext())
     {
         //ToList() is a built-in method, and this is putting everything in the Category table into a list
         return(db.Category.ToList());
     }
 }
        public static int Create(string catName)
        {
            var db       = new To_Do_ListContext();
            var category = new Category {
                Name = catName
            };

            db.Category.Add(category);
            db.SaveChanges();
            return(1);
        }