public void Test_CorridorServices_Add_Staff_To_New_Corridor()
        {
            try
            {
                /* Creating new Corridor */
                CorridorServices cs = new CorridorServices();
                string           NewCorridorName = "T1234";
                cs.Post(NewCorridorName);

                /* Get the created CorridorModel from the database */
                List <CorridorModel> CorridorList = new List <CorridorModel>();
                CorridorModel        Corridor     = new CorridorModel();
                CorridorList = cs.List();
                Corridor     = CorridorList.Find(x => x.corridorName == NewCorridorName);

                /* Creates the new User */
                UserServices us      = new UserServices();
                UserModel    NewUser = new UserModel()
                {
                    UserName  = "******",
                    firstname = "Johan",
                    lastname  = "Johansson"
                };
                us.Post(NewUser);

                /* Adds a User to the Corridor */
                cs.Post(Corridor.corridorId, NewUser.UserName);
            }
            catch (Exception e)
            {
                Assert.Fail("Expected no exception, but got " + e.Message);
            }
        }
        public void Test_CorridorServices_Update_Corridor()
        {
            try {
                /* Creating new Corridor */
                CorridorServices cs           = new CorridorServices();
                string           CorridorName = "E1234";
                cs.Post(CorridorName);

                /* Get the Corridor's ID */
                List <CorridorModel> CorridorList = new List <CorridorModel>();
                CorridorModel        Corridor     = new CorridorModel();
                CorridorList = cs.List();
                Corridor     = CorridorList.Find(x => x.corridorName == CorridorName);

                /* Update the name of the Corridor from 'E1234' to 'J2134' */
                CorridorModel NewCorridor = new CorridorModel()
                {
                    corridorName = "J2134",
                    corridorId   = Corridor.corridorId
                };
                cs.Update(NewCorridor);

                /* Check that the Corridor has updated */
                CorridorList = cs.List();
                Corridor     = CorridorList.Find(x => x.corridorId == NewCorridor.corridorId);
                Assert.AreEqual(NewCorridor.corridorId, Corridor.corridorId);
            }
            catch (Exception e)
            {
                Assert.Fail("Expected no exception, but got " + e.Message);
            }
        }
 public void Test_CorridorServices_Add_New_Corridor()
 {
     try
     {
         /* Creating new Corridor */
         CorridorServices cs = new CorridorServices();
         string           NewCorridorName = "T1234";
         cs.Post(NewCorridorName);
     }
     catch (Exception e)
     {
         Assert.Fail("Expected no exception, but got " + e.Message);
     }
 }
示例#4
0
        public void Test_StaffService_List_Users_From_Same_Corridor()
        {
            try
            {
                /* Create two new User */
                UserServices us       = new UserServices();
                UserModel    NewUser1 = new UserModel()
                {
                    UserName  = "******",
                    firstname = "Kalle",
                    lastname  = "Anka"
                };
                UserModel NewUser2 = new UserModel()
                {
                    UserName  = "******",
                    firstname = "Joakim",
                    lastname  = "von Anka"
                };
                us.Post(NewUser1);
                us.Post(NewUser2);

                /* Creates a new Corridor and retrieves its ID*/
                CorridorServices sc           = new CorridorServices();
                string           CorridorName = "Pengabinge3303";
                sc.Post(CorridorName);
                List <CorridorModel> CorridorList = new List <CorridorModel>();
                CorridorList = sc.List();
                CorridorModel Corridor = CorridorList.Find(x => x.corridorName == CorridorName);

                /* Puts the two new users in the new corridor */
                sc.Post(Corridor.corridorId, NewUser1.UserName);
                sc.Post(Corridor.corridorId, NewUser2.UserName);

                /* Get a list of all users in the new corridor and check if the two new users are included */
                StaffServices     ss        = new StaffServices();
                List <StaffModel> StaffList = new List <StaffModel>();
                StaffList = ss.List(Corridor.corridorId);
                StaffModel Staff1 = StaffList.Find(x => x.username == NewUser1.UserName);
                StaffModel Staff2 = StaffList.Find(x => x.username == NewUser2.UserName);

                Assert.AreEqual(NewUser1.UserName, Staff1.username);
                Assert.AreEqual(NewUser2.UserName, Staff2.username);
            }
            catch (Exception e)
            {
                Assert.Fail("Expected no exception, but got " + e.Message);
            }
        }
        public void Test_CorridorServices_Get_CorridorID_From_New_Corridor()
        {
            try
            {
                /* Creating new Corridor */
                CorridorServices cs = new CorridorServices();
                string           NewCorridorName = "T1234";
                cs.Post(NewCorridorName);

                /* Checks if the Get() function returns the right corridor */
                List <CorridorModel> CorridorList = new List <CorridorModel>();
                CorridorModel        cm           = new CorridorModel();
                CorridorList = cs.List();
                cm           = CorridorList.Find(x => x.corridorName == NewCorridorName);

                Assert.AreEqual(NewCorridorName, cm.corridorName);
            }
            catch (Exception e)
            {
                Assert.Fail("Expected no exception, but got " + e.Message);
            }
        }
        public void Test_CorridorServices_Add_Two_Corridors_With_Same_Name()
        {
            try
            {
                /* Creating new Corridor */
                CorridorServices cs = new CorridorServices();
                string           NewCorridorName = "T1234";
                cs.Post(NewCorridorName);

                /* Add second Corridor with same name */
                cs.Post(NewCorridorName);

                /* Check if there is 2 Corridors. If there is, test failed */
                List <CorridorModel> CorridorList = new List <CorridorModel>();
                CorridorList = cs.List();
                Assert.AreEqual(2, CorridorList.Count);
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message);
            }
        }
        public void Test_CorridorServices_Delete_Corridor()
        {
            try
            {
                /* Creating new Corridor */
                CorridorServices cs = new CorridorServices();
                string           NewCorridorName = "T1234";
                cs.Post(NewCorridorName);

                /* Get the new Corridor's ID */
                List <CorridorModel> CorridorList = new List <CorridorModel>();
                CorridorModel        NewCorridor  = new CorridorModel();
                CorridorList = cs.List();
                NewCorridor  = CorridorList.Find(x => x.corridorName == NewCorridorName);

                /* Try to delete the new Corridor */
                cs.Delete(NewCorridor.corridorId);
            }
            catch (Exception e)
            {
                Assert.Fail("Expected no exception, but got " + e.Message);
            }
        }