Ejemplo n.º 1
0
        //this method get the details of particular user
        public Creadential Check(IdPassword cread)
        {
            Creadential cre    = new Creadential();
            User        master = _context.Get(cread.Email);

            if (master == null)
            {
                cre.Status = "notexist";
                return(cre);
            }
            else if (master.Email == cread.Email && master.Password == cread.Password)
            {
                _context.SetLoggedIn(master.Id, true);
                cre.Status   = "success";
                cre.UserId   = master.Id;
                cre.UserName = master.FirstName;
                cre.Email    = master.Email;
                return(cre);
            }
            else if (master.Email == cread.Email && master.Password != cread.Password)
            {
                cre.Status = "exist";
                return(cre);
            }
            else
            {
                cre.Status = "error";
                return(cre);
            }
        }
        public void SignUp_Service_Check_Method_To_Get_Details()
        {
            //Arrange
            var idPass = new IdPassword();

            idPass.Email    = "preetam";
            idPass.Password = "******";
            User master = new User();

            master.Email     = "preetam";
            master.Password  = "******";
            master.FirstName = "preetam";
            master.Id        = 1;
            var creadential = new Creadential();

            creadential.UserId   = 1;
            creadential.Status   = "success";
            creadential.UserName = "******";
            creadential.Email    = "preetam";

            //mocking RequestRepository
            var mockRepoReq = new Mock <ISignUpRepository>();

            //mocking GetAll() of RequestRepository
            mockRepoReq.Setup(x => x.Get(creadential.Email)).Returns(master);
            mockRepoReq.Setup(x => x.SetLoggedIn(1, true)).Returns(true);

            SignUpService obj = new SignUpService(mockRepoReq.Object);
            //Act
            var res = obj.Check(idPass);

            //Assert
            Assert.NotNull(res);
            Assert.Equal(creadential.Email, res.Email);
            Assert.Equal(creadential.Status, res.Status);
            Assert.Equal(creadential.UserName, res.UserName);
            Assert.Equal(creadential.UserId, res.UserId);
        }