Ejemplo n.º 1
0
        public void TestCreateEvent()
        {
            var      ctrl  = new EventCtrl();
            UserCtrl uCtrl = new UserCtrl();
            var      u     = uCtrl.CreateUser("Test User", "Test User", "test" + Guid.NewGuid() + "@email.com", "password");


            Event e = new Event
            {
                Title             = "test title" + Guid.NewGuid(),
                Description       = "This is a long description\ncontaining newlines",
                NumOfParticipants = 5,
                PriceFrom         = 100.0,
                PriceTo           = 200.0,
                Location          = "Sofiendalsvej 60",
                Datetime          = DateTime.Now.AddHours(1), //+1 hour from now to not trigger the past date exception
                IsPublic          = true,
                Admin             = u
            };

            // Act
            Event output = ctrl.CreateEvent(e.Title, e.Description, e.NumOfParticipants, e.PriceFrom, e.PriceTo, e.Location, e.Datetime, e.IsPublic, u);


            // Assert
            Assert.AreEqual(e.Title, output.Title);
        }
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.name == "Player")
        {
            UserCtrl healthVal = other.GetComponent <UserCtrl>();
            print("You've collected the item, m8");
            if (isHealth)
            {
                if (healthVal.userHealth < 10)
                {
                    healthVal.userHealth += healUp;
                }
                else if (healthVal.userHealth <= 10)
                {
                    healthVal.userHealth = 10;
                }
            }


            ScoreManager.AddPoints(value);

            Instantiate(pickUpEffect, transform.position, transform.rotation);
            Destroy(gameObject);
        }
    }
Ejemplo n.º 3
0
        public void TestRegister()
        {
            // user details

            string firstname = "Hari";
            string lastname  = "Shrestha";
            string email     = "*****@*****.**";
            int    gender    = 1; // male
            string uname     = "sthahari";
            string pass      = "******";
            int    utype     = 1; // programmer

            bool expected = true;

            // user register process

            DBConnection.setDefault();
            DBConnection.isTesting = true;

            UserCtrl userCtrl = new UserCtrl();

            bool result = userCtrl.registerUser(firstname, lastname, email, gender, uname, pass, utype);

            Assert.AreEqual(result, expected);
        }
Ejemplo n.º 4
0
        public void TestAddItem()
        {
            // Arrange
            ComponentCtrl cCtrl = new ComponentCtrl();
            EventCtrl     eCtrl = new EventCtrl();
            UserCtrl      uCtrl = new UserCtrl();
            var           u     = uCtrl.CreateUser("Test User", "Test User", "test" + Guid.NewGuid() + "@email.com", "password");

            // Act
            var evnt     = eCtrl.CreateEvent("E Title", "E Desc", 42, 42, 42, "E Location", DateTime.Now.AddDays(5), true, u);
            var category = cCtrl.CreateCategory("Cat Name", "Cat desc", null);

            eCtrl.AddCategory(evnt, category);
            var category2 = cCtrl.CreateCategory("Cat2 Name2", "Cat2 desc2", category);

            eCtrl.AddCategory(evnt, category2);
            var item = cCtrl.CreateItem("Item Name", "Item Desc", 42, category2, evnt);

            eCtrl.AddItem(evnt, category2, item);

            // Assert
            var foundCategory = cCtrl.FindCategoryById(category2.Id);
            var foundItem     = ((Item)((Category)evnt.Components[1]).Components[0]);

            Assert.IsNotNull(foundItem);
            Assert.IsTrue(foundCategory.Components.Count == 1);
            Assert.IsTrue(foundCategory.Components[0].Id == foundItem.Id);
        }
Ejemplo n.º 5
0
 public BikeService()
 {
     ACtrl       = new AdvertisementCtrl();
     BCtrl       = new BicycleCtrl();
     uCtrl       = new UserCtrl();
     bookingCtrl = new BookingCtrl();
 }
Ejemplo n.º 6
0
        private void modBtnSaveUserChanges_Click(object sender, EventArgs e)
        {
            this.userControl = new UserCtrl();
            Dictionary <Object, dynamic> data = new Dictionary <Object, dynamic>();

            Usuario modifiedUser = new Usuario()
            {
                IdUsuario       = registeredUser.IdUsuario,
                Cedula          = registeredUser.Cedula,
                Tipo            = ((UserTypes)modDropUserType.SelectedItem).value,
                NombreCompleto  = modtxtName.Text.TrimStart().TrimEnd(),
                PrimerApellido  = modtxtLastname1.Text.TrimStart().TrimEnd(),
                SegundoApellido = modtxtLastname2.Text.TrimStart().TrimEnd(),
                NombreUsuario   = modtxtUserName.Text.TrimStart().TrimEnd(),
                Contrasena      = modtxtPassword.Text.TrimStart().TrimEnd(),
                FechaAgrega     = registeredUser.FechaAgrega,
                FechaElimina    = registeredUser.FechaElimina,
                UsuarioAgrega   = registeredUser.UsuarioAgrega,
                Eliminado       = registeredUser.Eliminado,
                IdEstado        = (int)modDropUserStatus.SelectedValue
            };


            data["user"]     = Session.getInstance().session["identification"];
            userControl.data = data;

            Dictionary <Object, dynamic> result = userControl.modifyUser(registeredUser, modifiedUser);

            if (result["code"] == Result.Processed)
            {
                this.loadCombos();
            }

            MessageBox.Show(result["msg"]);
        }
        public void TestUpdateProfile()
        {
            // user details, user with id 1 is manually recorded

            int userId = 1;

            string firstname = "Hari";
            string lastname  = "Shrestha";
            string email     = "*****@*****.**";
            int    gender    = 1; // male
            string uname     = "sthahari";
            int    utype     = 1; // programmer

            bool expected = true;

            // update profile process

            DBConnection.setDefault();
            DBConnection.isTesting = true;

            UserCtrl userCtrl = new UserCtrl();

            bool result = userCtrl.updateOwnProfile(userId, firstname, lastname, email, gender, uname, utype);

            Assert.AreEqual(result, expected);
        }
    // Use this for initialization
    void Start()
    {
        UIHealth = GameObject.Find("Player").GetComponent <UserCtrl>();


        currVal = GetComponent <Text>();
    }
Ejemplo n.º 9
0
 public void CompareTrueTest()
 {
     try
     {
         string hash = "H7rdT7K2Chxiz8xnzyayYoJtT9fPvL0hF8eUNbo3" +
                       "ejg4uxbrFgVQR7qk7uteirsId7Ys2RKYOYRgAd2fOi" +
                       "N5VhJKoPzjQPtzl6iGndVgjQoP74IaMlUbC0a0x0oul5" +
                       "OMwymKDR9Gk953fKM1nwu2gHmHX/JtKXUf6QqwDtvLCpHT" +
                       "7YfOLRQMIm98C2+adlOvH+pXDoWmMAVmkFg2hKW08OQJytOY" +
                       "HgFexvkkLoAjSOw0pqb7ri39pFZrzssxjsd/HBYU4QWAD7EOrQJB" +
                       "xjqcSxGQp73JeRFeFU1ESqcjN2nYmo1epT63d3So2uH97kYZWc1vWP4" +
                       "mpf3nf0/HYt4kfg==";
         UserCtrl userCtrl = new UserCtrl();
         bool     status   = userCtrl.CompareHashes("Aksel", hash);
         Assert.IsTrue(status);
     }
     catch (FaultException <UserNotFoundException> )
     {
         Assert.Fail();
     }
     catch (FaultException <DbConnectionException> )
     {
         Assert.Fail();
     }
 }
Ejemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            signUp      = new SignUpController();
            userControl = new UserCtrl();

            if (IsPostBack)
            {
                ResultLabel.Visible = true;
            }

            if (!IsPostBack)
            {
                EditProfileTitle.Visible = false;

                //if (Session["name"]!= null)
                if (Page.PreviousPage == null && Session["name"] != null)
                {
                    //Manage title and button visibility for Edit Profile
                    EditProfileBtn.Visible   = true;
                    SignUpBtn.Visible        = false;
                    BackButton.Visible       = true;
                    SignUpTitle.Visible      = false;
                    EditProfileTitle.Visible = true;
                    ResultLabel.Visible      = false;

                    email.ReadOnly     = true;
                    confEmail.ReadOnly = true;
                    string emailString = Session["name"].ToString();

                    u = userControl.getProfileInfo(emailString);

                    email.Text     = u.Email;
                    confEmail.Text = u.Email;
                    firstName.Text = u.FirstName;
                    lastName.Text  = u.LastName;
                    address.Text   = u.Address;
                    city.Text      = u.City;
                    DropDownList1.SelectedValue = u.State;
                    zipCode.Text = u.Zip.ToString();
                    //Phone.Text = u.Phone;
                    MobilePhone.Text    = u.Phone;
                    checkToText.Checked = u.Text;
                }
            }

            ServiceReference1.SUSMSClient isuService = new ServiceReference1.SUSMSClient();

            string[] carriers = isuService.getCarriers();

            if (carriers.Length > 0 && CarrierList.Items.Count <= 1)
            {
                foreach (string carrier in carriers)
                {
                    CarrierList.Items.Add(new ListItem(carrier, carrier));
                }
            }
        }
Ejemplo n.º 11
0
        private void addContInfoSendInfo_Click(object sender, EventArgs e)
        {
            this.userControl = new UserCtrl();
            catchInformation();
            userControl.data = data;

            Dictionary <Object, dynamic> result = userControl.insertContactInformation();

            MessageBox.Show(result["msg"]);
        }
Ejemplo n.º 12
0
 protected void Page_Load(object sender, EventArgs e)
 {
     loginCtrl = new UserCtrl();
     if (Request.QueryString["signup"] != null)
     {
         MessagePanel.Visible = true;
     }
     else
     {
         MessagePanel.Visible = false;
     }
 }
Ejemplo n.º 13
0
        private void addbtnSaveUser_Click(object sender, EventArgs e)
        {
            catchData();
            storeDataIntoArray();

            UserCtrl userControl = new UserCtrl();

            userControl.data = this.data;
            Dictionary <Object, dynamic> result = userControl.insertUserFromMaintenance();

            MessageBox.Show(result["msg"]);
        }
    void Update()
    {
        UserCtrl aim = player.GetComponent <UserCtrl>();

        if (aim.faceRight)
        {
            GetComponent <Rigidbody2D>().velocity = new Vector2(speed, GetComponent <Rigidbody2D>().velocity.y);
        }
        else if (!aim.faceRight)
        {
            GetComponent <Rigidbody2D>().velocity = new Vector2(-speed, GetComponent <Rigidbody2D>().velocity.y);
        }
    }
    // Use this for initialization
    void Start()
    {
        player = GameObject.Find("Player");
        UserCtrl direction = player.GetComponent <UserCtrl>();

        enemyDeath = Resources.Load("Prefabs/PS") as GameObject;

        breakDeath = Resources.Load("Prefabs/Break") as GameObject;

        projectileParticle = Resources.Load("Prefabs/PS") as GameObject;

        //Destroy projectile after x seconds
        Destroy(gameObject, timeOut);
    }
Ejemplo n.º 16
0
 public ListForObjects GetAllAssignmentsByTeacherId(int teacherId)
 {
     AssignmentDb asDB = new AssignmentDb();
     UserCtrl userCtrl = new UserCtrl();
     ListForObjects list = new ListForObjects();
     ListForObjects l = asDB.GetAllAssignmentsByTeacherId(teacherId);
     foreach (Object o in l.Asl)
     {
         Assignment a = (Assignment)o;
         a.teacher = (Teacher)userCtrl.GetPerson(a.teacher.Id);
         list.Asl.Add(a);
     }
     return list;
 }
Ejemplo n.º 17
0
        public int SubmitHomework(int childId, int assignmentId, DateTime date, string diskName)
        {
            UserCtrl userCtrl = new UserCtrl();

            Homework hw = new Homework();
            hw.Child = (Child)userCtrl.GetPerson(childId);
            hw.Assignment = new Assignment(assignmentId);
            hw.Date = date;
            hw.DiskName = diskName;

            HomeworkDb hwDb = new HomeworkDb();

            return hwDb.SubmitHomework(hw);
        }
Ejemplo n.º 18
0
        private void delBtnDeleteUser_Click(object sender, EventArgs e)
        {
            this.userControl = new UserCtrl();
            catchData();
            userControl.data = data;

            Dictionary <Object, dynamic> result = userControl.deleteUser(registeredUser);

            if (result["code"] == Result.Processed)
            {
                this.loadCombos();
            }

            MessageBox.Show(result["msg"]);
        }
Ejemplo n.º 19
0
 public ListForObjects GetAllHomeworksByID(int assignmentId)
 {
     HomeworkDb hwDb = new HomeworkDb();
     UserCtrl userCtrl = new UserCtrl();
     AssignmentCtrl assgnmentCtrl = new AssignmentCtrl();
     ListForObjects l = hwDb.GetAllHomeworksById(assignmentId);
     ListForObjects list = new ListForObjects();
     foreach (Homework hw in l.Asl)
     {
         hw.Child = (Child)userCtrl.GetPerson(hw.Child.Id);
         //hw.Assignment = assgnmentCtrl.GetAssignmentById(hw.Assignment.Id);
         list.Asl.Add(hw);
     }
     return list;
 }
Ejemplo n.º 20
0
 protected void Page_Load(object sender, EventArgs e)
 {
     itemCtrl         = new ItemController();
     userCtrl         = new UserCtrl();
     smsCtrl          = new TextCallController();
     MsgPanel.Visible = false;
     if (Request.QueryString["success"] != null)
     {
         SuccessPanel.Visible = true;
     }
     else
     {
         SuccessPanel.Visible = false;
     }
 }
Ejemplo n.º 21
0
        public int CreateAssignment(int teacherId, string subject, string title, string exercise, DateTime date, DateTime deadline)
        {
            UserCtrl usCtrl = new UserCtrl();

            Assignment ass = new Assignment();
            ass.teacher = (Teacher)usCtrl.GetPerson(teacherId);
            ass.subject = subject;
            ass.title = title;
            ass.exercise = exercise;
            ass.date = date;
            ass.deadline = deadline;

            AssignmentDb assDb = new AssignmentDb();

            return assDb.CreateAssignment(ass);
        }
Ejemplo n.º 22
0
        public void loadCombos()
        {
            userControl = new UserCtrl();
            Dictionary <Object, dynamic> resultUsers = this.userControl.getDataToFillUsersCombo();

            if (resultUsers["code"] == Result.Failed)
            {
                MessageBox.Show(resultUsers["msg"]);
                return;
            }

            if (resultUsers["code"] == Result.Processed)
            {
                loadUsersComboBox(resultUsers["content"]);
            }
        }
Ejemplo n.º 23
0
        private void btnSubmitRegister2_Click(object sender, EventArgs e)
        {
            catchInformation();

            data["contactInfoType"]    = ContactInfoType.Email;
            data["value"]              = this.email.TrimStart().TrimEnd();
            data["contactInfoDeleted"] = 0;
            data["contactInfoStatus"]  = Status.Active;

            UserCtrl userCtrl = new UserCtrl();

            userCtrl.data = data;
            Dictionary <Object, dynamic> result = userCtrl.insertUserFromRegister();

            MessageBox.Show(result["msg"]);
        }
Ejemplo n.º 24
0
        public void SystemTestAddCategoryToCategory()
        {
            EventCtrl     eCtrl   = new EventCtrl();
            ComponentCtrl cCtrl   = new ComponentCtrl();
            UserCtrl      uCtrl   = new UserCtrl();
            IService      service = new Service();

            User  u = uCtrl.CreateUser("System Test User", "Test User", "test" + Guid.NewGuid() + "@email.com", "password");
            Event e = service.CreateEvent("System Test Event", "Test", 2, 20, 100, "Right here", DateTime.Now.AddHours(5), true, u);

            service.AddCategoryToEvent(e.Id, "System Test Cat 1", "Cat 1", null);
            e = service.FindEventById(e.Id);

            service.AddCategoryToEvent(e.Id, "System Test Cat 2", "Cat 2",
                                       e.Components.Where(c => c.Title == "System Test Cat 1" && c is Category).FirstOrDefault());

            Assert.IsTrue(true);
        }
Ejemplo n.º 25
0
        protected void BtnAccept_Click(object sender, EventArgs e)
        {
            //temp
            UserCtrl   userCtrl = new UserCtrl();
            List <int> idList   = new List <int>();

            foreach (GridViewRow row in UserRequestGrid.Rows)
            {
                CheckBox cb = (CheckBox)row.FindControl("CheckBox1");
                if (cb != null && cb.Checked)
                {
                    idList.Add(Convert.ToInt32(row.Cells[5].Text));
                }
            }

            userCtrl.approveRequest(idList);
            UserRequestGrid.DataBind();
        }
        public void TestPasswordChange()
        {
            // user details, user the following details is manually recorded
            int userId = 1;

            bool expected = true;

            // change password process

            DBConnection.setDefault();
            DBConnection.isTesting = true;

            UserCtrl userCtrl = new UserCtrl();

            bool result = userCtrl.changePassword(userId, "newpassword");

            Assert.AreEqual(result, expected);
        }
Ejemplo n.º 27
0
        public bool NewUserSubscriber(string mail)
        {
            EmailSubscriber sub = new EmailSubscriber();
            UserCtrl        uc  = new UserCtrl();
            UserModel       um  = null;

            try
            {
                um = uc.GetUserByEmail(mail);
                if (um != null)
                {
                    sub.userId = um.Id;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            sub.emailAddress     = mail;
            sub.validationCode   = GenerateValidationCode();
            sub.addressValidated = false;
            sub.dateSubscribed   = DateTime.Now;

            try
            {
                EmailSubscriber es = GetSubscriber(mail);

                if (es != null)
                {
                    return(false);
                }
                context.EmailSubscribers.InsertOnSubmit(sub);
                context.SubmitChanges();
                string linkExtention = sub.validationCode;

                SendValidateUserEmail(linkExtention, mail);
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 28
0
        public void TestChangeDeleteUser()
        {
            // user details

            int userId = 1; // user with id 1 is manually recorded

            bool expected = true;

            // delete user process

            DBConnection.setDefault();
            DBConnection.isTesting = true;

            UserCtrl userCtrl = new UserCtrl();

            bool result = userCtrl.deleteUser(userId);

            Assert.AreEqual(result, expected);
        }
Ejemplo n.º 29
0
        public void TestSignUpForEvent()
        {
            var user  = new UserCtrl().CreateUser("Fornavn", "Efternavn", "*****@*****.**" + Guid.NewGuid(), "123456");
            var eCtrl = new EventCtrl();
            var e     = eCtrl.CreateEvent("dsd", "dewdc", 23, 213.3, 21312.3, "here", DateTime.Now.AddHours(5), false, user);


            // Act
            eCtrl.SignUpForEvent(user.Email, e.Id);

            // Assert
            using (var ctx = new DALContext())
            {
                var reg = new UserCtrl().FindByEmail(user.Email).Registrations[0];

                var found = ctx.Registrations.Find(reg.Id);
                Assert.AreEqual(reg.Id, found.Id);
            }
        }
Ejemplo n.º 30
0
 public void FindSaltByUserNameTest()
 {
     try
     {
         UserCtrl userCtrl = new UserCtrl();
         string   salt     = userCtrl.FindSaltByUserName("Aksel");
         string   saltInDB = "yR9c4qazcTfrnEJb8USdqruRe+3+iq/s95r+GmFJW0ed" +
                             "AvJLGgHbW0o59L+JGMWWB9aU4SSa5Z24n37laq+DeA==";
         Assert.IsTrue(salt.Equals(saltInDB));
     }
     catch (FaultException <UserOrPasswordException> )
     {
         Assert.Fail();
     }
     catch (FaultException <DbConnectionException> )
     {
         Assert.Fail();
     }
 }
Ejemplo n.º 31
0
        public void CompareFalseTest()
        {
            bool status = false;

            try
            {
                string   hash     = "WRONG";
                UserCtrl userCtrl = new UserCtrl();
                status = userCtrl.CompareHashes("Aksel", hash);
                Assert.IsFalse(status);
            }
            catch (FaultException <UserOrPasswordException> )
            {
                Assert.IsTrue(true);
            }
            catch (FaultException <DbConnectionException> )
            {
                Assert.Fail();
            }
        }
Ejemplo n.º 32
0
        public void TestChangeUserStatus()
        {
            // user details, user with id 1 is manually recorded

            int userId = 1;
            int status = 1;

            bool expected = true;

            // change user status process

            DBConnection.setDefault();
            DBConnection.isTesting = true;

            UserCtrl userCtrl = new UserCtrl();

            bool result = userCtrl.changeUserStatus(userId, status);

            Assert.AreEqual(result, expected);
        }
Ejemplo n.º 33
0
        public void CreateUserTest()
        {
            UserCtrl uCtrl = new UserCtrl();
            User     user  = new User
            {
                Firstname = "Niklas",
                Lastname  = "Jørgensen",
                Email     = "*****@*****.**" + Guid.NewGuid(), // To avoid creating the same user when rerunning the test
                Password  = "******"
            };

            uCtrl.CreateUser(user.Firstname, user.Lastname, user.Email, user.Password);

            using (var ctx = new DALContext())
            {
                User foundUser = ctx.Users.Where(u => u.Email == user.Email).FirstOrDefault();
                Assert.IsNotNull(foundUser);
                Assert.AreEqual(user.Firstname, foundUser.Firstname);
            }
        }
Ejemplo n.º 34
0
        public void TestAddCategoryToCategory()
        {
            // Arrange
            EventCtrl     eCtrl = new EventCtrl();
            ComponentCtrl cCtrl = new ComponentCtrl();
            UserCtrl      uCtrl = new UserCtrl();
            var           u     = uCtrl.CreateUser("Test User", "Test User", "test" + Guid.NewGuid() + "@email.com", "password");
            var           e     = eCtrl.CreateEvent("Testing Event", "Test", 2, 20, 100, "Right here", DateTime.Now.AddHours(5), true, u);
            var           c1    = cCtrl.CreateCategory("Testing Category Lvl 1", "Test", null);

            // Act
            eCtrl.AddCategory(e, c1);

            var c2 = cCtrl.CreateCategory("Testing Category Lvl 2", "Test", c1);
            var e2 = eCtrl.FindById(e.Id);

            eCtrl.AddCategory(e2, c2);

            Assert.IsTrue(c2.Parent.Id == c1.Id);
            Assert.IsTrue(c2.EventId == e.Id);
        }
Ejemplo n.º 35
0
        public Object Login(string User, string Password)
        {
            UserCtrl userCtrl = new UserCtrl();

             return userCtrl.Login(User, Password);
        }