Exemplo n.º 1
0
        public void Test5_Find_FindClientInDatabase()
        {
            Client testClient = new Client("Robert",1);
              testClient.Save();

              Client foundClient = Client.Find(testClient.GetId());

              Assert.Equal(testClient, foundClient);
        }
Exemplo n.º 2
0
        public void Test_Save_Find_FoundItemEqualsItem()
        {
            //Arrange/Act
              Client item = new Client("Janet", 0, "She's a handful.");
              item.Save();

              //Assert
              Assert.Equal(Client.Find(item.id), item);
        }
Exemplo n.º 3
0
        public void Test_Save_CanRetrieveOneItem()
        {
            //Arrange/Act
              Client item = new Client("Janet", 0, "She's a handful.");
              item.Save();
              List<Client> allClients = Client.GetAll();

              //Assert
              Assert.Equal(1, allClients.Count);
        }
Exemplo n.º 4
0
        public void Test_Update()
        {
            //Arrange/Act
              Client item = new Client("Janet", 0, "She's a handful.");
              item.Save();
              item.Update(new List<string>{"name"}, new List<object>{"Sherry"});

              //Assert
              Assert.Equal(item.name, "Sherry");
        }
Exemplo n.º 5
0
        public void Test_Delete()
        {
            //Arrange/Act
              Client item = new Client("Janet", 0, "She's a handful.");
              item.Save();
              item.Delete();

              //Assert
              Assert.Equal(Client.Find(item.id), null);
        }
Exemplo n.º 6
0
        public void Test3_Save_AssignsIdToObject()
        {
            Client testClient = new Client("Alex",1);

              testClient.Save();
              Client savedClient = Client.GetAll()[0];

              int result = savedClient.GetId();
              int testId = testClient.GetId();

              Assert.Equal(testId, result);
        }
Exemplo n.º 7
0
        public void Find_FindsClientInDatabase_specifiedClient()
        {
            //Arrange
            Client testClient = new Client("Veronique Moore", 2);

            testClient.Save();

            //Act
            Client foundClient = Client.Find(testClient.GetId());

            //Assert
            Assert.Equal(testClient, foundClient);
        }
Exemplo n.º 8
0
        public void Test_UpdateString_ReturnsTrueIfClientInfoIsTheSame()
        {
            //Arrange
            Client firstTestClient = new Client("Vin Diesel", 3);

            firstTestClient.Save();
            Client secondTestClient = new Client("Dwayne Johnson", 3, firstTestClient.GetId());

            //Act
            secondTestClient.UpdateString("Vin Diesel");
            //Assert
            Assert.Equal(firstTestClient, secondTestClient);
        }
Exemplo n.º 9
0
        public void Test4_UpdateClient()
        {
            string name       = "ClientName";
            Client testClient = new Client(name, 1);

            testClient.Save();
            string newName = "ClientNewName";

            testClient.Update(newName);
            string result = testClient.GetName();

            Assert.Equal(newName, result);
        }
        public void Test_IfSavesMultipleClients_True()
        {
            Client        newFirstClient  = new Client("Joe Klein", 0);
            Client        newSecondClient = new Client("Ashley Watson", 0);
            List <Client> clientList      = new List <Client> {
            };

            newFirstClient.Save();
            newSecondClient.Save();
            clientList = Client.GetAll();

            Assert.Equal(2, clientList.Count);
        }
Exemplo n.º 11
0
        public void Test_Save_ToClientDatabase()
        {
            Client testClient = new Client("Iforgotmynameoops", 2);

            testClient.Save();

            List <Client> result   = Client.GetAll();
            List <Client> testList = new List <Client> {
                testClient
            };

            Assert.Equal(testList, result);
        }
Exemplo n.º 12
0
        public void Test_Save_AssignsIdToClientInDatabase()
        {
            //Arrange
            Client testClient = new Client("Vin Diesel", 3);

            testClient.Save();
            //Act
            Client savedClient = Client.GetAll()[0];
            int    testId      = testClient.GetId();
            int    expectedId  = savedClient.GetId();

            //Assert
            Assert.Equal(testId, expectedId);
        }
Exemplo n.º 13
0
        public void Edit_UpdatesValues_true()
        {
            //Arrange
            Client newClient = new Client("client1", 2);

            newClient.Save();
            //Act
            newClient.Edit("Cliff", 1);
            Client foundClient    = Client.Find(newClient.GetId());
            Client expectedResult = new Client(newClient.GetName(), newClient.GetStylistId(), newClient.GetId());

            //Assert
            Assert.Equal(expectedResult, foundClient);
        }
Exemplo n.º 14
0
        public void Test_Update_UpdatesClientInDatabase()
        {
            string name       = "Joe";
            Client testClient = new Client(name, 1);

            testClient.Save();
            string newName = "Paul";

            testClient.Update(newName);

            string result = testClient.GetName();

            Assert.Equal(newName, result);
        }
Exemplo n.º 15
0
        public void Test_ObjectFoundInDatabase_True()
        {
            Console.WriteLine("Client Test: Object Found In db");
            //Arrange
            Client testClient = new Client("Jordan Loop", 1);

            testClient.Save();

            //Act
            Client foundClient = Client.Find(testClient.GetId());

            //Assert
            Assert.Equal(testClient, foundClient);
        }
Exemplo n.º 16
0
        public void Test_GetClients()
        {
            //Arrange
              Stylist item = new Stylist("Sherri", "M-W-F", "Clients love her.");
              item.Save();
              Client a = new Client("Janet", item.id, "She's a handful.");
              a.Save();

              //Act
              List<Client> clients = item.GetClients();

              //Assert
              Assert.Equal(clients[0], a);
        }
        public void Test_IfReturnsListOfClients_True()
        {
            Client        newFirstClient  = new Client("Joe Klein", 0);
            Client        newSecondClient = new Client("Ashley Watson", 0);
            List <Client> clientList      = new List <Client> {
                newFirstClient, newSecondClient
            };

            newFirstClient.Save();
            newSecondClient.Save();
            List <Client> savedClients = Client.GetAll();

            Assert.Equal(clientList, savedClients);
        }
Exemplo n.º 18
0
        public void Test_UpdatesClientInDatabase_True()
        {
            string name       = "Jordan Loop";
            Client testClient = new Client(name, 1);

            testClient.Save();
            string newName = "Nadroj Pool";

            testClient.Update(newName);

            string result = testClient.GetName();

            Assert.Equal(newName, result);
        }
Exemplo n.º 19
0
        [Fact] //Verify we are saving clients to our Database.
        public void Test_Client_Save_SaveToDB()
        {
            //Arrange
            Client testClient = new Client("Jimmy the Client", 1); //Verify datatypes are equal as expected.

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

            //Assert
            Assert.Equal(result, testList);
        }
Exemplo n.º 20
0
        public void Test_SavesRestaurantToDatabase()
        {
            //Arrange
            Client testClient = new Client("Susie", 1, "Monday", "11:30");

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

            //Assert
            Assert.Equal(testList, result);
        }
Exemplo n.º 21
0
        public void Update_UpdatesClientInDatabase()
        {
            //Arrange
            Client testCase = new Client("Hrothgar Gunnirson", 0);

            testCase.Save();
            string newName = "Joe Smith";

            //Act
            testCase.Update(newName);
            string actual = testCase.GetName();

            //Assert
            Assert.Equal(newName, actual);
        }
Exemplo n.º 22
0
        public void Test_Save_ClientToDatabase()
        {
            //Arrange
            Client testClient = new Client("Rick Sanchez", "123-456-7890", "*****@*****.**", 1);

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

            //Assert
            Assert.Equal(testList, result);
        }
        public void Test_Save_SavesToDatabase_True()
        {
            //Arrange
            Client        testClient = new Client("Joe Klein", 0);
            List <Client> clientList = new List <Client> {
            };

            //Act
            testClient.Save();
            clientList = Client.GetAll();
            Client theClient = clientList[0];

            //Assert
            Assert.Equal(testClient, theClient);
        }
Exemplo n.º 24
0
        public void Test_Update_UpdatesClientInDatabase()
        {
            string name       = "Bart";
            int    stylist_id = 2;
            Client testClient = new Client(name, stylist_id);

            testClient.Save();
            string newName = "Bartholomewchlewizkyzak";

            testClient.Update(newName);

            string result = testClient.GetName();

            Assert.Equal(newName, result);
        }
Exemplo n.º 25
0
        public void Test_Save_SavesClientToDatabase()
        {
            //Arrange
            Client testClient = new Client("Vin Diesel", 3);

            testClient.Save();
            //Act
            List <Client> result         = Client.GetAll();
            List <Client> expectedResult = new List <Client> {
                testClient
            };

            //Assert
            Assert.Equal(result, expectedResult);
        }
Exemplo n.º 26
0
        public void Test_SavesToDatabase_True()
        {
            Console.WriteLine("Client Test: Saves To Database");
            //ARRANGE
            Client testClient = new Client("Jordan Loop", 1);

            //ACT
            testClient.Save();
            List <Client> result   = Client.GetAll();
            List <Client> testList = new List <Client> {
                testClient
            };

            //ASSERT
            Assert.Equal(testList, result);
        }
Exemplo n.º 27
0
        public void Update_UpdatesClientInDB()
        {
            //Arrange
            string name       = "John Mayer";
            Client testClient = new Client(name, 2);

            testClient.Save();
            string newName = "Hayley Williams is a Goddess";

            //Act
            testClient.Update(newName);
            string result = testClient.GetName();

            //Assert
            Assert.Equal(newName, result);
        }
Exemplo n.º 28
0
        public void Test_AssignsIdToObject_True()
        {
            Console.WriteLine("Client Test: Assign Id");
            //Arrange
            Client testClient = new Client("Jordan Loop", 1);

            //Act
            testClient.Save();
            Client savedClient = Client.GetAll()[0];

            int result = savedClient.GetId();
            int testId = testClient.GetId();

            //Assert
            Assert.Equal(testId, result);
        }
Exemplo n.º 29
0
        public void Test_Update_UpdateClient()
        {
            //Arrange
            string name       = "Billy the Goat";
            Client testClient = new Client(name, 1);

            testClient.Save();
            string updateName = "Billy the Giraffe";

            //Act
            testClient.Update(updateName);
            string result = testClient.GetName();

            //Assert
            Assert.Equal(updateName, result);
        }
Exemplo n.º 30
0
        public void Test_Update_UpdatesClientsInDatabase()
        {
            //Arrange
            string appointmentDay = "Monday";
            Client testClient     = new Client("Susie", 1, appointmentDay, "11:30");

            testClient.Save();
            string newAppointmentDay = "Tuesday";

            //Act
            testClient.Update(newAppointmentDay, "11:30");
            string result = testClient.GetAppointmentDay();

            //Assert
            Assert.Equal(newAppointmentDay, result);
        }
Exemplo n.º 31
0
        public void Test_Delete_DeletesClientFromDatabase()
        {
            Client newClient  = new Client("Mrs. C", 1, 1);
            Client nextClient = new Client("Mrs. Y", 1, 1);

            newClient.Save();
            nextClient.Save();
            nextClient.Delete();

            List <Client> allClients = Client.GetAll();
            List <Client> result     = new List <Client> {
                newClient
            };

            Assert.Equal(result, allClients);
        }
Exemplo n.º 32
0
        public void GetStylistName_ReturnsStylistName_true()
        {
            //Arrange
            Stylist newStylist = new Stylist("Frankie");

            newStylist.Save();
            Client newClient = new Client("Frances", newStylist.GetId());

            newClient.Save();
            string expectedResult = newStylist.GetName();
            //Act
            string result = newClient.GetStylistName();

            //Assert
            Assert.Equal(expectedResult, result);
        }
Exemplo n.º 33
0
        public void Test_UpdateName_UpdatesClientNameInDatabase()
        {
            //Arrange
            Client testClient = new Client("Mrs. C", 1, 1);

            testClient.Save();
            string newName = "Mrs. Cauliflower";

            //Act
            testClient.UpdateName(newName);

            string result = testClient.Name;

            //Assert
            Assert.Equal(newName, result);
        }
Exemplo n.º 34
0
        public void Test_FindClientFromStylist()
        {
            Stylist newStylist = new Stylist("Hilary", 1);

            newStylist.Save();

            Client controlClient = new Client("David", 1);

            controlClient.Save();

            Client newClient = Client.Find(controlClient.GetId());

            Console.WriteLine(newClient.GetName());

            Assert.Equal(controlClient.GetName(), newClient.GetName());
        }
Exemplo n.º 35
0
        public void Test_ChangeNameOfClient()
        {
            Client newClient = new Client("Hunter", 10);

            newClient.Save();

            Client testClient = Client.Find(newClient.GetId());

            testClient.Save();

            string newName = "Patrick";

            testClient.Update(newName);

            Assert.Equal(newName, testClient.GetName());
        }
Exemplo n.º 36
0
        public void T4_Save_GetId_DoesSaveIdToClient()
        {
            //Arrange
            Client testClient = new Client("Joe Lee", 1);

            testClient.Save();

            //Act
            Client savedClient = Client.GetAll()[0];

            int testId   = testClient.GetId();
            int resultId = savedClient.GetId();

            //Assert
            Assert.Equal(testId, resultId);
        }
Exemplo n.º 37
0
        public void Test_ByStylist_ReturnsTrueIfListsAreTheSame()
        {
            Stylist newStylist   = new Stylist("A", "*****@*****.**", "photolink");
            Client  firstClient  = new Client("Person A", 1, "email", newStylist.GetId());
            Client  secondClient = new Client("Person B", 2, "email", newStylist.GetId());

            newStylist.Save();
            firstClient.Save();
            secondClient.Save();
            List <Client> result   = Client.ByStylist();
            List <Client> testList = new List <Client> {
                firstClient, secondClient
            };

            Assert.Equal(testList, result);
        }
Exemplo n.º 38
0
        public Homemodule()
        {
            Get["/"] = _ => {
            List<Stylist> AllStylists = Stylist.GetAll();
            return View["index.cshtml", AllStylists];
              };

              Get["/clients"] = _ => {
            List<Client> AllClients = Client.GetAll();
            return View["clients.cshtml", AllClients];
              };

              Get["/stylists"] = _ => {
            List<Stylist> AllStylists = Stylist.GetAll();
            return View["stylists.cshtml", AllStylists];
              };

              Get["/stylists/new"] = _ => {
            return View["stylists_form.cshtml"];
              };

              Post["/stylists/new"] = _ => {
            Stylist newStylist = new Stylist(Request.Form["stylist-name"]);
            newStylist.Save();
            return View["success.cshtml"];
              };

              Get["/clients/new"] = _ => {
            List<Stylist> AllStylists = Stylist.GetAll();
            return View["clients_form.cshtml", AllStylists];
              };
              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["/stylists/{id}"] = parameters => {
            Dictionary<string, object> model = new Dictionary<string, object>();
            var SelectedStylist = Stylist.Find(parameters.id);
            var StylistClients = SelectedStylist.GetClients();
            model.Add("stylist", SelectedStylist);
            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"];
              };
        }
Exemplo n.º 39
0
 public HomeModule()
 {
     Get["/"] = _ => {
     List<Stylist> stylists = Stylist.GetAll();
     return View["index.cshtml", stylists];
       };
       Post["/stylists/new"] = _ => {
     Stylist newStylist = new Stylist(Request.Form["name"], Request.Form["avail"], Request.Form["notes"]);
     newStylist.Save();
     List<Stylist> stylists = Stylist.GetAll();
     return View["index.cshtml", stylists];
       };
       Get["/stylists/{id}"] = parameter => {
     Stylist foundStylist = Stylist.Find(parameter.id);
     return View["stylist.cshtml", foundStylist];
       };
       Patch["/stylists/edit/{id}"] = parameter => {
     Stylist editedStylist = Stylist.Find(parameter.id);
     List<string> updateColumns = new List<string> {"name", "availability", "notes"};
     string newStylistId = (string)Request.Form["avail"];
     string newName = (string)Request.Form["name"];
     string newNotes = (string)Request.Form["notes"];
     List<object> updateValues = new List<object> {newName, newStylistId, newNotes};
     editedStylist.Update(updateColumns, updateValues);
     return View["stylist.cshtml", editedStylist];
       };
       Delete["/stylists/delete/{id}"] = parameter => {
     Stylist deletedStylist = Stylist.Find(parameter.id);
     deletedStylist.Delete();
     List<Stylist> stylists = Stylist.GetAll();
     return View["index.cshtml", stylists];
       };
       Post["/clients/new"] = _ => {
     string newName = (string)Request.Form["name"];
     int stylistId = (int)Request.Form["stylist_id"];
     string newNotes = (string)Request.Form["notes"];
     Client newClient = new Client(newName, stylistId, newNotes);
     newClient.Save();
     Stylist foundStylist = Stylist.Find(stylistId);
     return View["stylist.cshtml", foundStylist];
       };
       Get["/clients/{id}"] = parameter => {
     Client foundClient = Client.Find(parameter.id);
     List<object> model = new List<object> {};
     model.Add(foundClient);
     model.Add(Stylist.GetAll());
     return View["client.cshtml", model];
       };
       Patch["/clients/edit/{id}"] = parameter => {
     Client editedClient = Client.Find(parameter.id);
     List<string> updateColumns = new List<string> {"name", "stylist_id", "notes"};
     int newStylistId = (int)Request.Form["stylist_id"];
     string newName = (string)Request.Form["name"];
     string newNotes = (string)Request.Form["notes"];
     List<object> updateValues = new List<object> {newName, newStylistId, newNotes};
     editedClient.Update(updateColumns, updateValues);
     List<object> model = new List<object> {};
     model.Add(editedClient);
     model.Add(Stylist.GetAll());
     return View["client.cshtml", model];
       };
       Delete["/clients/delete/{id}"] = parameter => {
     Client deletedClient = Client.Find(parameter.id);
     deletedClient.Delete();
     Stylist foundStylist = Stylist.Find(deletedClient.stylist_id);
     return View["stylist.cshtml", foundStylist];
       };
 }