Exemple #1
0
        public async Task DeleteTaskCollaborator()
        {
            var newUser = new ManagemAntsServer.Dbo.User()
            {
                Pseudo    = "ThisIsANewPseudoTaskToDelete",
                Firstname = "ThisIsANewFirstanameTaskToDelete",
                Lastname  = "ThisIsANewLastnameTaskToDelete",
                Password  = "******"
            };
            var resultUser = await _loginController.SignUp(newUser) as Microsoft.AspNetCore.Mvc.OkObjectResult;

            var user = (resultUser.Value as List <ManagemAntsServer.Dbo.User>).FirstOrDefault();
            var task = _refFixture.Tasks[0];

            var newUserHasTask = new ManagemAntsServer.Dbo.UsersHasTask()
            {
                UserId = user.Id,
                TaskId = task.Id
            };

            var resultUserHasTask = await _taskController.AddTaskCollaborators(newUserHasTask) as Microsoft.AspNetCore.Mvc.OkObjectResult;

            var userHasTask = resultUserHasTask.Value as ManagemAntsServer.Dbo.UsersHasTask;

            var result = await _taskController.DeleteTaskCollaborator(userHasTask.TaskId.ToString(), userHasTask.UserId.ToString()) as Microsoft.AspNetCore.Mvc.OkObjectResult;

            Assert.AreEqual(200, result.StatusCode);
            Assert.IsTrue(result.Value as bool?);
        }
Exemple #2
0
 public static bool IsEqualUsers(ManagemAntsServer.Dbo.User a, ManagemAntsServer.Dbo.User b)
 {
     return(a.Id == b.Id &&
            a.Pseudo == b.Pseudo &&
            a.Firstname == b.Firstname &&
            a.Lastname == b.Lastname &&
            a.Password == b.Password);
 }
Exemple #3
0
        public async Task SignUp()
        {
            var newUser = new ManagemAntsServer.Dbo.User()
            {
                Pseudo    = "ThisIsANewPseudo",
                Firstname = "ThisIsANewFirstaname",
                Lastname  = "ThisIsANewLastname",
                Password  = "******"
            };
            var result = await _loginController.SignUp(newUser) as Microsoft.AspNetCore.Mvc.OkObjectResult;

            Assert.AreEqual(200, result.StatusCode);

            var users = result.Value as List <ManagemAntsServer.Dbo.User>;

            Assert.AreEqual(1, users.Count);
            Assert.IsTrue(UserUtils.IsEqualUsers(newUser, users[0]));
        }
Exemple #4
0
        public async Task SignUpAlreadyExist()
        {
            var prevCount = _refFixture.Users.Count;
            var newUser   = new ManagemAntsServer.Dbo.User()
            {
                Pseudo    = _refFixture.Users[0].Pseudo,
                Firstname = "ThisIsANewFirstaname",
                Lastname  = "ThisIsANewLastname",
                Password  = "******"
            };
            var result = await _loginController.SignUp(newUser) as Microsoft.AspNetCore.Mvc.OkObjectResult;

            Assert.AreEqual(200, result.StatusCode);

            var addedUserResult = _loginController.Login(newUser.Pseudo) as Microsoft.AspNetCore.Mvc.OkObjectResult;
            var users           = addedUserResult.Value as ManagemAntsServer.Dbo.User[];

            Assert.AreEqual(1, users.Length);
            Assert.IsFalse(UserUtils.IsEqualUsers(newUser, users[0]));
        }