Ejemplo n.º 1
0
    static public String GetUserIdInCookies(HttpRequest Request)
    {
        HttpCookie cookie = Request.Cookies["userid"];

        if (cookie == null)
        {
            return(null);
        }

        if (cookie.Value == null)
        {
            return(null);
        }

        CertificationController c = new CertificationController();

        if (c.IsUserIdValid(cookie.Value))
        {
            return(cookie.Value);
        }
        else
        {
            return(null);
        }
    }
Ejemplo n.º 2
0
        public void ShouldReturnDefaultView()
        {
            var fakeRepository = new Mock <ILearningSystemData>();

            var certification = new CertificationController(fakeRepository.Object);

            certification.WithCallTo(x => x.Info()).ShouldRenderDefaultView();
        }
        public void DeleteCertification()
        {
            // Arrange
            CertificationController controller = new CertificationController();

            var actResult = controller.Delete(1);
            // Act
            var result = actResult as OkNegotiatedContentResult <bool>;

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Content == true);
        }
        public void getCertification()
        {
            // Arrange
            CertificationController controller = new CertificationController();

            var actResult = controller.Get(1);
            // Act
            var result = actResult as OkNegotiatedContentResult <Certification>;

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Content.ID == 1);
        }
        public void PostCertification()
        {
            // Arrange
            CertificationController controller = new CertificationController();

            Certification CertificationObj = new Certification
            {
                Name     = ".Net",
                Comments = "Good Work",
            };
            var actResult = controller.Post(CertificationObj);
            // Act
            var result = actResult as OkNegotiatedContentResult <Certification>;

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Content.ID > 0);
        }
        public void PutCertification()
        {
            // Arrange
            CertificationController controller = new CertificationController();

            Certification CertificationObj = new Certification
            {
                Name     = "Put request sucessfull",
                Comments = "Good Work",
                ID       = 1
            };
            var actResult = controller.Put(1, CertificationObj);
            // Act
            var result = actResult as OkNegotiatedContentResult <Certification>;

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Content.Name.Equals("Put request sucessfull"));
        }
Ejemplo n.º 7
0
    protected void Login_Click(object sender, EventArgs e)
    {
        String username = UserNameTextBox.Text;

        String password = PasswordTextBox.Text;

        byte[] byteArray = System.Text.Encoding.Default.GetBytes(password);
        password = Convert.ToBase64String(byteArray);

        CertificationController Controller = new CertificationController();
        String id = Controller.GetUserId(username, password);

        if (id == null)
        {
            ErrorMessageLabel.Text    = @"用户名或密码错误";
            ErrorMessageLabel.Visible = true;
        }
        else
        {
            if (Context.Request.Browser.Cookies == false)
            {
                ErrorMessageLabel.Text = "登录失败";
                return;
            }

            ErrorMessageLabel.Visible = false;

            HttpCookie cookie = Request.Cookies["userid"];
            if (cookie == null)
            {
                cookie = new HttpCookie("userid");
            }

            cookie.Value   = id;
            cookie.Expires = DateTime.Now.AddDays(7);
            Response.SetCookie(cookie);
            Response.Redirect(@"~/Mission.aspx");
        }
    }
Ejemplo n.º 8
0
 public void SetUp()
 {
     _controller = new CertificationController(Repository.Object);
     StubRequest(_controller);
     StubCursors();
 }