Exemplo n.º 1
0
        public void ApiGetUserGoals()
        {
            var acc = Mock.Of <IUserGoalService>(a => a.GetUserGoals() == _manyUserGoals);
            var uow = Mock.Of <IUnitOfWork>(u => u.UserGoalService == acc);
            UserGoalsController controller = new UserGoalsController(uow);
            var userGoals = controller.GetUserGoals();

            Assert.IsTrue(userGoals.EqualValues(_manyUserGoals));
        }
Exemplo n.º 2
0
        public void ApiGetUserGoalById()
        {
            long id  = 4;
            var  acc = Mock.Of <IUserGoalService>(a => a.GetUserGoal(id) == _sampleUserGoal1);
            var  uow = Mock.Of <IUnitOfWork>(u => u.UserGoalService == acc);
            UserGoalsController controller = new UserGoalsController(uow);
            var response = controller.GetUserGoal(id);
            var result   = response as OkNegotiatedContentResult <UserGoalDto>;
            var userGoal = result.Content;

            Assert.IsTrue(userGoal.EqualValues(_sampleUserGoal1));
        }
Exemplo n.º 3
0
        public void ApiPutUserGoals()
        {
            long id       = 8;
            var  userGoal = _sampleUserGoal2;
            var  mock     = new Mock <IUserGoalService>();

            mock.Setup(a => a.UpdateUserGoal(userGoal))
            .Returns(userGoal);
            var sv      = mock.Object;
            var uowMock = new Mock <IUnitOfWork>();

            uowMock.Setup(u => u.UserGoalService)
            .Returns(sv);
            var con = new UserGoalsController(uowMock.Object);

            con.PutUserGoal(id, userGoal);
            mock.Verify(a => a.UpdateUserGoal(userGoal));
        }
Exemplo n.º 4
0
        public void ApiPostUserGoal()
        {
            var userGoal = _sampleUserGoal1;
            var mock     = new Mock <IUserGoalService>();

            mock.Setup(acc => acc.CreateUserGoal(userGoal))
            .Returns(userGoal);
            var uowMock = new Mock <IUnitOfWork>();

            uowMock.Setup(u => u.UserGoalService)
            .Returns(mock.Object);
            var con = new UserGoalsController(uowMock.Object);

            con.User = new ClaimsPrincipal(
                new GenericPrincipal(new GenericIdentity(""), null));
            var response       = con.PostUserGoal(userGoal);
            var result         = response as CreatedAtRouteNegotiatedContentResult <UserGoalDto>;
            var resultUserGoal = result.Content;

            Assert.IsTrue(resultUserGoal.EqualValues(userGoal));
            mock.Verify(acc => acc.CreateUserGoal(userGoal));
            uowMock.Verify(u => u.Save());
        }