public void T5_Find_FindNameInDatabase() { //arrange Stylist testStylist = new Stylist("Jane"); testStylist.Save(); //act Stylist foundStylist = Stylist.Find(testStylist.GetId()); //Assert Assert.Equal(testStylist, foundStylist); }
public void T3_Test_Save_SavesToDatabase() { //arrange Stylist testStylist = new Stylist("Jane"); //act testStylist.Save(); List<Stylist> result = Stylist.GetAll(); List<Stylist> testList = new List<Stylist>{testStylist}; //Assert Assert.Equal(testList, result); }
public void T4_Save_AssignsIdToObject() { //arrange Stylist testStylist = new Stylist("Jane"); //act testStylist.Save(); Stylist savedStylist = Stylist.GetAll()[0]; int result = savedStylist.GetId(); int testId = testStylist.GetId(); //Assert Assert.Equal(testId, result); }
public HomeModule() { Get ["/"] = _ => { List<Stylist> AllStylist = Stylist.GetAll(); return View["index.cshtml", AllStylist]; }; Get["/clients"] = _ => { List<Client> AllClients = Client.GetAll(); return View["clients.cshtml", AllClients]; }; Get["/stylist"] = _ => { List<Stylist> AllStylist = Stylist.GetAll(); return View["stylists.cshtml", AllStylist]; }; Get["/stylist/new"] = _ => { return View["stylists_form.cshtml"]; }; Post["/stylist/new"] = _ =>{ Stylist newStylist = new Stylist(Request.Form["stylist-name"]); newStylist.Save(); return View["success.cshtml"]; }; Get["/clients/new"] = _ => { List<Stylist> AllStylist = Stylist.GetAll(); return View["clients_form.cshtml", AllStylist]; }; Post["/clients/new"] = _ => { Client newClient = new Client(Request.Form["client-name"], Request.Form["stylist-id"]); newClient.Save(); return View["success.cshtml"]; }; Post["/clients/delete"] = _ => { Client.DeleteAll(); return View["cleared.cshtml"]; }; Get["/stylist/{id}"] = parameters => { Dictionary<string, object> model = new Dictionary<string, object>(); var SelectedStylist = Stylist.Find(parameters.id); var StylistClients = SelectedStylist.GetClients(); model.Add("clients", StylistClients); return View["stylist.cshtml", model]; }; Get["stylist/edit/{id}"] = parameters => { Stylist SelectedStylist = Stylist.Find(parameters.id); return View["stylist_edit.cshtml", SelectedStylist]; }; Patch["stylist/edit/{id}"] = parameters => { Stylist SelectedStylist = Stylist.Find(parameters.id); SelectedStylist.Update(Request.Form["stylist-name"]); return View["success.cshtml"]; }; Get["stylist/delete/{id}"] = parameters => { Stylist SelectedStylist = Stylist.Find(parameters.id); return View["stylist_delete.cshtml", SelectedStylist]; }; Delete["stylist/delete/{id}"] = parameters => { Stylist SelectedStylist = Stylist.Find(parameters.id); SelectedStylist.Delete(); return View["success.cshtml"]; }; }
public void T6_GetClients_RetrievesAllClientsWithStylist() { Stylist testStylist = new Stylist("Jane"); testStylist.Save(); Client firstClient = new Client("Jill", testStylist.GetId()); firstClient.Save(); Client secondClient = new Client("Lisa", testStylist.GetId()); secondClient.Save(); List<Client> testClientList = new List<Client> {firstClient, secondClient}; List<Client> resultClientList = testStylist.GetClients(); Assert.Equal(testClientList, resultClientList); }
public void T8_Delete_DeletesStylistFromDatabase() { //Arrange string name1 = "Mike"; Stylist testStylist1 = new Stylist(name1); testStylist1.Save(); string name2 = "Lucy"; Stylist testStylist2 = new Stylist(name2); testStylist2.Save(); Client testClient1 = new Client("Shirley", testStylist1.GetId()); testClient1.Save(); Client testClient2 = new Client("Bob", testStylist2.GetId()); testClient2.Save(); //Act testStylist1.Delete(); List<Stylist> resultStylist = Stylist.GetAll(); List<Stylist> testStylistList = new List<Stylist> {testStylist2}; List<Client> resultClients = Client.GetAll(); List<Client> testClientList = new List<Client> {testClient2}; //Assert Assert.Equal(testStylistList, resultStylist); Assert.Equal(testClientList, resultClients); }
public void T7_Update_UpdatesStylistInDatabase() { //Arrange string name = "Mike"; Stylist testStylist = new Stylist(name); testStylist.Save(); string newName = "Lucy"; //Act testStylist.Update(newName); string result = testStylist.GetName(); //Assert Assert.Equal(newName, result); }