コード例 #1
0
        public void Test_Find_FindsNutcrackerInDatabase()
        {
            //Arrange
            Nutcracker testNutcracker = new Nutcracker("Phil");

            testNutcracker.Save();

            //Act
            Nutcracker foundNutcracker = Nutcracker.Find(testNutcracker.GetId());

            //Assert
            Assert.Equal(testNutcracker, foundNutcracker);
        }
コード例 #2
0
 public HomeModule()
 {
     Get["/"] = _ => {
         return(View["index.cshtml"]);
     };
     Post["/"] = _ => {
         string     userInput     = Request.Form["name"];
         Nutcracker newNutcracker = new Nutcracker(userInput);
         newNutcracker.Save();
         string            newName        = newNutcracker.GetName();
         List <Nutcracker> allNutcrackers = Nutcracker.GetAll();
         return(View["index.cshtml", allNutcrackers]);
     };
 }
コード例 #3
0
        public void Test_Save_AssignsIdToObject()
        {
            //Arrange
            Nutcracker testNutcracker = new Nutcracker("Phil");

            //Act
            testNutcracker.Save();
            Nutcracker savedNutcracker = Nutcracker.GetAll()[0];

            int result = savedNutcracker.GetId();
            int testId = testNutcracker.GetId();

            //Assert
            Assert.Equal(testId, result);
        }
コード例 #4
0
        public void Test_Save_SavesToDatabase()
        {
            //Arrange
            Nutcracker testNutcracker = new Nutcracker("Phil");

            //Act
            testNutcracker.Save();
            List <Nutcracker> result   = Nutcracker.GetAll();
            List <Nutcracker> testList = new List <Nutcracker> {
                testNutcracker
            };

            //Assert
            Assert.Equal(testList, result);
        }