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); }
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]); }; }
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); }
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); }