public ActionResult Create(string addSpecialty) { Specialties createSpecialty = new Specialties(addSpecialty); createSpecialty.Save(); return(RedirectToAction("Index")); }
public void SaveAndGetAll_SavesToDatabaseAndReturnAll_Specialties() { //Arrange Specialties testSpecialty = new Specialties("testName"); //Act testSpecialty.Save(); List <Specialties> result = Specialties.GetAll(); List <Specialties> testList = new List <Specialties> { testSpecialty }; //Assert CollectionAssert.AreEqual(testList, result); }
public void Save_AssignsIdToObject_Id() { //Arrange Specialties testSpecialty = new Specialties("testName"); //Act testSpecialty.Save(); Specialties savedSpecialty = Specialties.GetAll()[0]; int result = savedSpecialty.GetId(); int testId = testSpecialty.GetId(); //Assert Assert.AreEqual(testId, result); }
public void Find_FindSpecialtyInDatabase_Specialties() { //Arrange Specialties testSpecialty = new Specialties("testName"); testSpecialty.Save(); List <Specialties> testList = new List <Specialties> { testSpecialty }; //Act Specialties resultById = Specialties.FindById(testSpecialty.GetId()); List <Specialties> resultByName = Specialties.FindByName(testSpecialty.GetSpecialties()); //Assert Assert.AreEqual(testSpecialty, resultById); CollectionAssert.AreEqual(testList, resultByName); }
public void Delete_DeleteStylistFromDatabaseAndStylist_SpecialtyTable_Stylist() { // Arrange Stylist testStylist = new Stylist("testName", "testDescription", 1); testStylist.Save(); Specialties testSpecialty = new Specialties("testSpecialty"); testSpecialty.Save(); StylistSpecialties testStylistSpecialty = new StylistSpecialties(testStylist.GetId(), testSpecialty.GetId()); testStylistSpecialty.Save(); // Act testStylist.Delete(); // Assert Assert.AreEqual(0, Stylist.FindById(testStylist.GetId()).GetId()); Assert.AreEqual(0, testSpecialty.GetStylists().Count); }
public void GetSpecialties_RetrievesAllSpecialtiesWithStylistId_SpecialtiesList() { // Arrange Stylist testStylist = new Stylist("testStylist"); testStylist.Save(); Specialties testSpecialty = new Specialties("testSpecialty"); testSpecialty.Save(); StylistSpecialties testStylistSpecialty = new StylistSpecialties(testStylist.GetId(), testSpecialty.GetId()); testStylistSpecialty.Save(); List <Specialties> testSpecialties = new List <Specialties> { testSpecialty }; // Act List <Specialties> resultSpecialties = testStylist.GetSpecialties(); // Assert CollectionAssert.AreEqual(testSpecialties, resultSpecialties); }