コード例 #1
0
        public void GetSpecialtys_GetStylistSpecialty_True()
        {
            //Arrange
            Stylist firstStylist = new Stylist("connor", "", 1);

            firstStylist.Save();
            Specialty specialty = new Specialty("short hair");

            specialty.Save();

            //Act
            firstStylist.AddSpecialty(specialty);
            List <Specialty> result = new List <Specialty> {
                specialty
            };
            List <Specialty> GetSpecialties = firstStylist.GetSpecialties();

            //Assert
            CollectionAssert.AreEqual(result, GetSpecialties);
        }
コード例 #2
0
        public ActionResult UpdatePost(int id, int newClientId, int newSpecialtyId)
        {
            Stylist editStylist = Stylist.Find(id);
            string  name        = Request.Form["new-name"];

            editStylist.Edit(name);

            if (newClientId > 0)
            {
                Client newClient = Client.Find(newClientId);
                editStylist.AddClient(newClient);
            }

            if (newSpecialtyId > 0)
            {
                Specialty newSpecialty = Specialty.Find(newSpecialtyId);
                editStylist.AddSpecialty(newSpecialty);
            }

            return(RedirectToAction("ViewAll"));
        }
コード例 #3
0
ファイル: StylistTest.cs プロジェクト: KNBAnderson/hair-salon
        public void Delete_DeletesStylistAssociationsFromDatabase_StylistList()
        {
            //Arrange
            Specialty testSpecialty = new Specialty("Hair");

            testSpecialty.Save();
            string  testName    = "Sally";
            Stylist testStylist = new Stylist(testName, "Always");

            testStylist.Save();

            //Act
            testStylist.AddSpecialty(testSpecialty);
            testStylist.Delete();
            List <Stylist> resultSpecialtyStylists = testSpecialty.GetStylists();
            List <Stylist> testSpecialtyStylists   = new List <Stylist> {
            };

            //Assert
            CollectionAssert.AreEqual(testSpecialtyStylists, resultSpecialtyStylists);
        }
コード例 #4
0
        public IActionResult UpdateStylist(int id, string newFirstName, string newLastName)
        {
            Specialty.DeleteAllSpecialtiesForSylist(id);
            Stylist.Update(newFirstName, newLastName, id);
            Stylist newStylist = Stylist.Find(id);
            //get values from check boxes
            List <Specialty> allSpecialties = Specialty.GetAll();

            for (int i = 0; i < allSpecialties.Count; i++)
            {
                string specialtyName       = allSpecialties[i].GetSpecialtyName();
                string specialtyValueInput = Request.Form[specialtyName];
                if (!(specialtyValueInput == null))
                {
                    //string specialtyValueInput = Request.Form[specialtyName];
                    int specialtyValueInt = Int32.Parse(specialtyValueInput);
                    newStylist.AddSpecialty(specialtyValueInt);
                }
            }
            return(RedirectToAction("Index"));
        }
コード例 #5
0
        public void AddSpecialty_AddsSpecialtyToStylist_SpecialtyList()
        {
            //Arrange
            Stylist testStylist = new Stylist("borg");

            testStylist.Save();
            Specialty testSpecialty = new Specialty("steps");

            testSpecialty.Save();

            //Act
            testStylist.AddSpecialty(testSpecialty);

            List <Specialty> result   = testStylist.GetSpecialties();
            List <Specialty> testList = new List <Specialty> {
                testSpecialty
            };

            //Assert
            CollectionAssert.AreEqual(testList, result);
        }
コード例 #6
0
        public void GetSpecialties_ReturnListOfSpecialties_SpecialtyList()
        {
            Stylist newStylist = new Stylist("Cutter", "O'Hare");

            newStylist.Save();
            Specialty newSpecialty = new Specialty("Blowouts");

            newSpecialty.Save();
            newStylist.AddSpecialty(newSpecialty.GetId());
            List <Specialty> expected = new List <Specialty> {
                newSpecialty
            };
            List <Specialty> result    = newStylist.GetSpecialties();
            List <Stylist>   expected2 = new List <Stylist> {
                newStylist
            };
            List <Stylist> result2 = newSpecialty.GetStylists();

            CollectionAssert.AreEqual(expected, result);
            CollectionAssert.AreEqual(expected2, result2);
        }
コード例 #7
0
        public void AddSpecialty_AddsSpecialtyToStylist_SpecialtyList()
        {
            //Arrange
            Stylist testStylist = new Stylist("first", "last");

            testStylist.Save();

            Specialty testSpecialty = new Specialty("Hair Cut");

            testSpecialty.Save();

            //Act
            testStylist.AddSpecialty(testSpecialty.GetSpecialtyId());

            List <Specialty> result   = testStylist.GetSpecialties();
            List <Specialty> testList = new List <Specialty> {
                testSpecialty
            };

            //Assert
            CollectionAssert.AreEqual(testList, result);
        }
コード例 #8
0
        public void AddaStylistToASpecialty()
        {
            //Arrange
            Stylist testStylist = new Stylist("Peter");

            testStylist.Save();

            Specialty testSpecialty = new Specialty("Color");

            testSpecialty.Save();

            //Act
            testStylist.AddSpecialty(testSpecialty);

            List <Specialty> result   = testStylist.GetSpecialties();
            List <Specialty> testList = new List <Specialty> {
                testSpecialty
            };

            //Assert
            CollectionAssert.AreEqual(testList, result);
        }
コード例 #9
0
        public void AddSpecialty_AddsEntryToJunctionTable_ListSpecialties()
        {
            //arrange
            Specialty newSpecialty = new Specialty("Cutting Hair");

            newSpecialty.Save();
            Stylist newStylist = new Stylist("Carol", "Smith");

            newStylist.Save();

            //act
            newStylist.AddSpecialty(newSpecialty);
            List <Specialty> testList = new List <Specialty> {
                newSpecialty
            };
            List <Specialty> result = newStylist.GetSpecialties();

            Console.WriteLine(result.Count);

            //assert
            CollectionAssert.AreEqual(testList, result);
        }
コード例 #10
0
ファイル: StylistTests.cs プロジェクト: BatesColin/HairSalon4
        public void Delete_DeletesStylistAssociationsFromDatabase_StylistList()
        {
            //Arrange
            Specialty testSpecialty = new Specialty("Mens Hair");

            testSpecialty.Save();

            string  testName    = "test";
            Stylist testStylist = new Stylist(testName);

            testStylist.Save();

            //Act
            testStylist.AddSpecialty(testSpecialty);
            testStylist.Delete();

            List <Stylist> resultSpecialtyCategories = Stylist.GetAll();
            List <Stylist> testSpecialtyCategories   = new List <Stylist> {
            };

            //Assert
            CollectionAssert.AreEqual(testSpecialtyCategories, resultSpecialtyCategories);
        }
コード例 #11
0
        public void GetSpecialties_ReturnsAllStylistSpecialties_SpecialtyList()
        {
            //Arrange
            Stylist testStylist = new Stylist("test stylist");

            testStylist.Save();
            Specialty testSpecialty1 = new Specialty("test description1");

            testSpecialty1.Save();
            Specialty testSpecialty2 = new Specialty("test description2");

            testSpecialty2.Save();

            //Act
            testStylist.AddSpecialty(testSpecialty1);
            List <Specialty> savedSpecialties = testStylist.GetSpecialties();
            List <Specialty> testList         = new List <Specialty> {
                testSpecialty1
            };

            //Assert
            CollectionAssert.AreEqual(testList, savedSpecialties);
        }
コード例 #12
0
        public void GetSpecialty_ReturnsAllStylistSpecialty_SpecialtyList()
        {
            //Arrange
            Stylist testStylist = new Stylist("gulzat", "cuts");

            testStylist.Save();
            Specialty testSpecialty1 = new Specialty("color");

            testSpecialty1.Save();
            Specialty testSpecialty2 = new Specialty("cut");

            testSpecialty2.Save();

            //Act
            testStylist.AddSpecialty(testSpecialty1);
            List <Specialty> savedSpecialty = testStylist.GetSpecialties();
            List <Specialty> testList       = new List <Specialty> {
                testSpecialty1
            };

            //Assert
            CollectionAssert.AreEqual(testList, savedSpecialty);
        }
コード例 #13
0
        public void GetSpecialties_ReturnsAllStylistSpecialties_SpecialtyList()
        {
            //Arrange
            Stylist testStylist = new Stylist("borg");

            testStylist.Save();
            Specialty testSpecialty1 = new Specialty("trim");

            testSpecialty1.Save();
            Specialty testSpecialty2 = new Specialty("bowl cut");

            testSpecialty2.Save();

            //Act
            testStylist.AddSpecialty(testSpecialty1);
            List <Specialty> result   = testStylist.GetSpecialties();
            List <Specialty> testList = new List <Specialty> {
                testSpecialty1
            };

            //Assert
            CollectionAssert.AreEqual(testList, result);
        }
コード例 #14
0
        public void GetSpecialties_GetSpecialtiesForStylist_listSpecialties()
        {
            //arrange
            Stylist newStylist = new Stylist("Carol", "Smith");

            newStylist.Save();
            Specialty newSpecialty1 = new Specialty("Cutting Hair");

            newSpecialty1.Save();
            Specialty newSpecialty2 = new Specialty("Cutting Hair");

            newSpecialty2.Save();
            newStylist.AddSpecialty(newSpecialty1);
            List <Specialty> testList = new List <Specialty> {
                newSpecialty1
            };

            //act
            List <Specialty> result = newStylist.GetSpecialties();

            //assert
            CollectionAssert.AreEqual(result, testList);
        }
コード例 #15
0
        public void GetStylists_ReturnListOfStylists_List()
        {
            //arrange
            Stylist newStylist1 = new Stylist("Carol", "Smith");
            Stylist newStylist2 = new Stylist("Mike", "Stinson");

            newStylist1.Save();
            newStylist2.Save();
            Specialty newSpecialty1 = new Specialty("Cutting Hair");
            Specialty newSpecialty2 = new Specialty("Curly Hair");

            newSpecialty1.Save();
            newSpecialty2.Save();
            newStylist1.AddSpecialty(newSpecialty1);
            List <Stylist> testList = new List <Stylist> {
                newStylist1
            };

            //act
            List <Stylist> result = newSpecialty1.GetStylists();

            //assert
            CollectionAssert.AreEqual(result, testList);
        }
コード例 #16
0
 public ActionResult AddSpecialty(int stylistId, int id)
 {
     Stylist foundStylist = Stylist.Find(stylistId);
     foundStylist.AddSpecialty(id);
     return RedirectToAction("Show", new {id = stylistId});
 }
コード例 #17
0
 public ActionResult UpdateStylist(int specialtyId, string stylist)
 {
     Stylist.AddSpecialty(int.Parse(stylist), specialtyId);
     return(RedirectToAction("UpdateSpecialtyForm", new { specialtyId = specialtyId }));
 }
コード例 #18
0
 public ActionResult UpdateSpecialty(int stylistId, string specialty)
 {
     Stylist.AddSpecialty(stylistId, int.Parse(specialty));
     return(RedirectToAction("UpdateStylistForm", new { stylistId = stylistId }));
 }