Esempio n. 1
0
        public async void Task_UpdateAccount_NotFound()
        {
            //Arrange
            var controller = new ComptesAPIController(repository);
            var accountId  = 100000;

            //Act
            var existingAccount = await controller.GetById(accountId);

            //Assert
            var okResult = existingAccount.Should().BeOfType <NotFoundResult>();

            //var account = new EditAccountViewModel();
            //account.Name = "Update Test Name";
            //account.UserName = result.Username;
            //account.NewPassword = "******";
            //account.NewPasswordAgain = "test1";
            //account.RegistrationDate = result.RegistrationDateTime;
            //account.LastLogin = result.LastLoginDateTime;

            //var updatedData = await controller.UpdateAccount(account);

            ////Assert
            //Assert.IsType<NotFoundObjectResult>(updatedData);
        }
Esempio n. 2
0
        public async void Task_DeleteAccount_OkResult()
        {
            //Arrange
            var controller = new ComptesAPIController(repository);
            //Act
            string username = RandomString(7);
            var    account  = new RegisterAccountViewModel()
            {
                Name           = "Test name",
                Username       = username,
                Email          = "*****@*****.**",
                Password       = "******",
                RepeatPassword = "******"
            };

            var existingAccount = await controller.AddAccount(account);

            var okResult = existingAccount.Should().BeOfType <OkObjectResult>().Subject;
            var result   = okResult.Value.Should().BeAssignableTo <Account>().Subject;

            var data = await controller.Delete(result.Id);

            //Assert
            Assert.IsType <OkObjectResult>(data);
        }
Esempio n. 3
0
        public async void Task_Update_Password_NotMatch_BadRequestResult()
        {
            //Arrange
            var controller = new ComptesAPIController(repository);
            var accountId  = 2011;

            //Act
            var existingAccount = await controller.GetById(accountId);

            var okResult = existingAccount.Should().BeOfType <OkObjectResult>().Subject;
            var result   = okResult.Value.Should().BeAssignableTo <Account>().Subject;

            var account = new EditAccountViewModel();

            account.Id               = accountId;
            account.Name             = "Update Test Name";
            account.UserName         = result.Username;
            account.NewPassword      = "******";
            account.NewPasswordAgain = "test1";
            account.RegistrationDate = result.RegistrationDateTime;
            account.LastLogin        = result.LastLoginDateTime;

            var updatedData = await controller.UpdateAccount(account);

            //Assert
            Assert.IsType <BadRequestObjectResult>(updatedData);
        }
Esempio n. 4
0
        public async void Task_GetAccounts_OkResult()
        {
            //Arrange
            var controller = new ComptesAPIController(repository);

            //Act
            var data = await controller.GetAccounts();

            //Assert
            Assert.IsType <OkObjectResult>(data);
        }
Esempio n. 5
0
        public async void Task_DeleteAccount_BadRequestResult()
        {
            //Arrange
            var controller = new ComptesAPIController(repository);


            //Act
            var data = await controller.Delete(17500);

            //Assert
            Assert.IsType <BadRequestObjectResult>(data);
        }
Esempio n. 6
0
        public async void Task_GetAccountById__BadRequestResult()
        {
            //Arrange
            var controller = new ComptesAPIController(repository);
            int?accountId  = null;

            //Act
            var data = await controller.GetById(accountId);

            //Assert
            Assert.IsType <BadRequestResult>(data);
        }
Esempio n. 7
0
        public async void Task_GetAccountById_NotFound()
        {
            //Arrange
            var controller = new ComptesAPIController(repository);
            var accountId  = 500;

            //Act
            var data = await controller.GetById(accountId);

            //Assert
            Assert.IsType <NotFoundResult>(data);
        }
Esempio n. 8
0
        public async void Task_Login_BadRequestResult()
        {
            //Arrange
            var    controller = new ComptesAPIController(repository);
            string username   = RandomString(7);
            var    account    = new LoginAccountViewModel()
            {
                Username = "******",
                Password = "******",
            };

            //Act
            var data = await controller.Login(account);

            //Assert
            Assert.IsType <BadRequestObjectResult>(data);
        }
Esempio n. 9
0
        public async void Task_AddAccount_Password_NotMatch_BadRequestResult()
        {
            //Arrange
            var controller = new ComptesAPIController(repository);
            var account    = new RegisterAccountViewModel()
            {
                Name           = "Test name",
                Username       = "******",
                Email          = "*****@*****.**",
                Password       = "******",
                RepeatPassword = "******"
            };

            //Act
            var data = await controller.AddAccount(account);

            //Assert
            Assert.IsType <BadRequestResult>(data);
        }
Esempio n. 10
0
        public async void Task_GetAccounts_ResultatExacte_OkResult()
        {
            //Arrange
            var controller = new ComptesAPIController(repository);

            //Act
            var data = await controller.GetAccounts();

            //Assert
            Assert.IsType <OkObjectResult>(data);

            var okResult = data.Should().BeOfType <OkObjectResult>().Subject;
            var account  = okResult.Value.Should().BeAssignableTo <List <Account> >().Subject;

            Assert.Equal("*****@*****.**", account[0].Email);
            Assert.Equal("wbakkali", account[0].Username);

            Assert.Equal("*****@*****.**", account[1].Email);
            Assert.Equal("alahoui", account[1].Username);
        }
Esempio n. 11
0
        public async void Task_AddAccount_UsernameExist_BadRequestResult()
        {
            //Arrange
            var    controller = new ComptesAPIController(repository);
            string username   = RandomString(7);
            var    account    = new RegisterAccountViewModel()
            {
                Name           = "Test name",
                Username       = "******",
                Email          = "*****@*****.**",
                Password       = "******",
                RepeatPassword = "******"
            };

            //Act
            var data = await controller.AddAccount(account);

            //Assert
            Assert.IsType <BadRequestObjectResult>(data);
        }