Exemple #1
0
 public void AddNewStudent()
 {
     CtrStudent ctrStudentObj = new CtrStudent();
     MdlStudent mdlStudentObj = GenerateStudentObj();
     string expected = "Registration successful.";
     string actual = ctrStudentObj.AddStudent(mdlStudentObj).Trim();
     Assert.AreEqual(expected, actual);
 }
Exemple #2
0
 public void AddExistingStudent()
 {
     CtrStudent ctrStudentObj = new CtrStudent();
     MdlStudent mdlStudentObj = GenerateStudentObj();
     mdlStudentObj.Email = "*****@*****.**";
     string expected = "Registration has failed due to the existing Email.";
     string actual = ctrStudentObj.AddStudent(mdlStudentObj).Trim();
     Assert.AreEqual(expected, actual);
 }
        public bool AddToWishlist(string studentEmail, int flatId, int score)
        {
            ctrStudentObj = new CtrStudent();

            Console.WriteLine();
            Console.WriteLine("AddToWishlist() " + GetExecutionThreadTime());

            return ctrStudentObj.AddToWishlist(studentEmail, flatId, score);
        }
        public string AddStudent(MdlStudent mdlStudentObj)
        {
            ctrStudentObj = new CtrStudent();

            Console.WriteLine();
            Console.WriteLine("AddStudent() " + GetExecutionThreadTime());

            return ctrStudentObj.AddStudent(mdlStudentObj);
        }
Exemple #5
0
        public void GetLastQueueNumber()
        {
            int actualResult = 0;

            CtrStudent ctrStudentObj = new CtrStudent();

            actualResult = ctrStudentObj.GetLastQueueNumber(GetFlatId());
            Assert.IsNotNull(actualResult);
        }
Exemple #6
0
        public void AddToWishListRepeatSameFail()
        {
            bool actualResult = true;
            bool expectedResult = false;

            CtrStudent ctrStudentObj = new CtrStudent();

            actualResult = ctrStudentObj.AddToWishlist(360, GetFlatId(), 0, -1);
            Assert.AreEqual(expectedResult, actualResult);
        }
Exemple #7
0
        public void GetStudentWishlist()
        {
            CtrStudent ctrStudentObj = new CtrStudent();
            DataSet ds = ctrStudentObj.GetWishlist("*****@*****.**");

            string actual = ds.Tables[0].Rows[0]["Address"].ToString().Trim();
            string expected = "Porthusgade";

            Assert.AreEqual(expected, actual);
        }
Exemple #8
0
        public void GetStudentData()
        {
            string expected = "surname";
            string actual;
            CtrStudent ctrStudentObj = new CtrStudent();

            MdlStudent mdlStudentObj = ctrStudentObj.GetStudentData("*****@*****.**");
            actual = mdlStudentObj.Surname.Trim();

            Assert.AreEqual(expected, actual);
        }
Exemple #9
0
        public void RemoveFromWishList()
        {
            CtrStudent ctrStudentObj = new CtrStudent();
            CtrGetData ctrGetDataObj = new CtrGetData();
            DataSet ds = ctrGetDataObj.GetAllFlats();

            string studentEmail = "*****@*****.**";
            int flatId = (int)ds.Tables[0].Rows[0]["Id"];

            bool actual = ctrStudentObj.RemoveFromWishlist(studentEmail, flatId);
            bool expected = true;

            Assert.AreEqual(expected, actual);
        }
Exemple #10
0
        public void AddToWishListExistingApplicaation()
        {
            CtrStudent ctrStudentObj = new CtrStudent();
            MdlStudent mdlStudentObj = StudentTests.GenerateStudentObj();

            CtrGetData ctrGetDataObj = new CtrGetData();
            DataSet ds = ctrGetDataObj.GetAllFlats();

            MdlApplication mdlApplicationObj = new MdlApplication();
            string studentEmail = "*****@*****.**";
            int flatId = (int)ds.Tables[0].Rows[0]["Id"];
            int score = 100;

            bool actual = ctrStudentObj.AddToWishlist(studentEmail, flatId, score);
            bool expected = false;

            Assert.AreEqual(expected, actual);
        }
Exemple #11
0
 public void CheckEmailTest()
 {
     CtrStudent ctrStudent = new CtrStudent();
     //should return true
     Assert.IsTrue(ctrStudent.AddStudent("*****@*****.**", "pass", true, true, 100, 20, false, 25, false, DateTime.Now, "Miro", "Pakanec", "xxx", "f**k", "aalborg", "Denmark", "4546456465"));
 }
Exemple #12
0
        public void LoginExistingStudent()
        {
            CtrLogin ctrLoginObj = new CtrLogin();
            CtrStudent ctrStudentObj = new CtrStudent();

            MdlStudent mdlStudentObj = GenerateStudentObj();
            mdlStudentObj.Email = "*****@*****.**";
            ctrStudentObj.AddStudent(mdlStudentObj).Trim();

            string expected = "You have successfully logged in.";
            string actual = ctrLoginObj.Login(mdlStudentObj.Email, "myPassword");
            Assert.AreEqual(expected, actual.Trim());
        }
Exemple #13
0
 public void GetNonExistingStudentData()
 {
     CtrStudent ctrStudentObj = new CtrStudent();
     MdlStudent mdlStudentObj = ctrStudentObj.GetStudentData("*****@*****.**");
     Assert.IsNull(mdlStudentObj.Surname);
 }
        public bool RemoveFromWishlist(string studentEmail, int flatId)
        {
            ctrStudentObj = new ServerController.CtrStudent();
            Console.WriteLine();
            Console.WriteLine("RemoveFromWishlist() " + GetExecutionThreadTime());

            return ctrStudentObj.RemoveFromWishlist(studentEmail, flatId);
        }
Exemple #15
0
        public void RemoveFromWishList()
        {
            bool actualResult = false;
            bool expectedResult = true;

            CtrStudent ctrStudentObj = new CtrStudent();

            actualResult = ctrStudentObj.RemoveFromWishlist(361, GetFlatId());
            Assert.AreEqual(expectedResult, actualResult);
        }
Exemple #16
0
        public void UpdateStudentProfileNonExistingEmail()
        {
            CtrStudent ctrStudentObj = new CtrStudent();

            bool expected = false;
            bool actual = ctrStudentObj.UpdateProfile("*****@*****.**",
                2, false, 0, true, "name", "surname", "address", "postCode", "city", "country", "phone");

            Assert.AreEqual(expected, actual);
        }
        public MdlStudent GetStudentData(string email)
        {
            ctrStudentObj = new CtrStudent();

            Console.WriteLine();
            Console.WriteLine("GetStudentData() " + GetExecutionThreadTime());

            return ctrStudentObj.GetStudentData(email);
        }
Exemple #18
0
        public void GetLastQueueNumberFlatFail()
        {
            int actualResult=0;

            CtrStudent ctrStudentObj = new CtrStudent();

            actualResult = ctrStudentObj.GetLastQueueNumber(1);
            Assert.AreEqual(actualResult, -2);
        }
        public DataSet GetWishlist(string studentEmail)
        {
            ctrStudentObj = new CtrStudent();

            Console.WriteLine();
            Console.WriteLine("GetWishlist() " + GetExecutionThreadTime());

            return ctrStudentObj.GetWishlist(studentEmail);
        }
Exemple #20
0
        private static void UpdateScores(DataSet ds)
        {
            var option = new TransactionOptions();
            option.IsolationLevel = System.Transactions.IsolationLevel.Serializable;
            option.Timeout = TimeSpan.FromSeconds(30);
            using (var scope = new TransactionScope(TransactionScopeOption.Required, option))
            {
                try
                {
                    Parallel.ForEach(ds.Tables[0].AsEnumerable(), drow =>
                    {
                        CtrStudent ctrStudentObj = new CtrStudent();
                        string studentEmail = drow["StudentEmail"].ToString().Trim();
                        int profileScore = ctrStudentObj.GetStudentData(studentEmail).Score;
                        int dateScore = CtrApplications.CalculateScoreDate(Convert.ToDateTime(drow["DateOfCreation"]));

                        drow["Score"] = CtrApplications.SumScores(profileScore, dateScore);
                    });

                    //update table
                    if (DbApplications.UpdateAllApplicationScores(ds))
                        Console.WriteLine("Update Successful");
                    else
                    {
                        Console.WriteLine("Update Failed");
                        Transaction.Current.Rollback();
                    }
                    Console.WriteLine("Update score transactions complete.");
                    scope.Complete();
                }
                catch(Exception e)
                {
                    Console.WriteLine("Update score transactions rolled back.");
                    Console.WriteLine("Error: " + e);
                    Transaction.Current.Rollback();
                }
                finally
                {
                    if (scope != null)
                        ((IDisposable)scope).Dispose();
                    Thread.CurrentThread.Abort();
                }
            }
        }
        public bool EditStudentProfile(string email, int numberOfChildren, bool pet, int numberOfCohabitors, bool disabled,
            string name, string surname, string address, string postCode, string city, string country, string phone)
        {
            ctrStudentObj = new CtrStudent();

            Console.WriteLine();
            Console.WriteLine("EditStudentProfile() " + GetExecutionThreadTime());

            return ctrStudentObj.UpdateProfile(email, numberOfChildren, pet, numberOfCohabitors, disabled,
                name, surname, address, postCode, city, country, phone);
        }