public void SignUpAndLogin()
        {
            AdressDTO address = new AdressDTO();

            address.latitude  = 50;
            address.longitude = 30;
            address.address   = "Beautiful city";

            SignUpAccountDTO account = new SignUpAccountDTO();

            account.FirstName = "Ion";
            account.LastName  = "Popescu";
            account.UserName  = "******";
            account.Email     = "*****@*****.**";
            account.Adress    = address;
            account.Password  = "******";


            SignUpAccountService signUpAccountService = new SignUpAccountService();

            signUpAccountService.addAccount(account);

            AccountService accountService = new AccountService();

            AccountSimpleDTO login = accountService.Login("Popescu", "123456");

            accountService.deleteAccount(login.Id);

            Assert.IsNotNull(login);
            Assert.AreEqual(login.FullName, account.LastName + " " + account.FirstName);
        }
        public void AddRemoveFriend()
        {
            SignUpAccountService signUpAccountService = new SignUpAccountService();
            AccountService       accountService       = new AccountService();
            FriendshipService    frService            = new FriendshipService();

            AdressDTO address = new AdressDTO();

            address.latitude  = 50;
            address.longitude = 30;
            address.address   = "Beautiful city";

            SignUpAccountDTO account = new SignUpAccountDTO();

            account.FirstName = "Ion";
            account.LastName  = "Popescu";
            account.UserName  = "******";
            account.Email     = "*****@*****.**";
            account.Adress    = address;
            account.Password  = "******";

            SignUpAccountDTO account1 = new SignUpAccountDTO();

            account1.FirstName = "Dfsadsa";
            account1.LastName  = "Ddsadsad";
            account1.UserName  = "******";
            account1.Email     = "*****@*****.**";
            account1.Adress    = address;
            account1.Password  = "******";



            AccountSimpleDTO acc  = signUpAccountService.addAccount(account);
            AccountSimpleDTO acc1 = signUpAccountService.addAccount(account1);

            frService.AddFriend(acc.Id, acc1.Id);

            var friends = frService.GetAllFriendships(acc.Id);

            FriendshipDTO friendship = friends.Where(fr => (fr.UserOne.Id == acc1.Id | fr.UserTwo.Id == acc1.Id)).FirstOrDefault();

            frService.RemoveFriendship(friendship.Id);

            var friends1 = frService.GetAllFriendships(acc.Id);

            FriendshipDTO friendship1 = friends1.Where(fr => (fr.UserOne.Id == acc1.Id | fr.UserTwo.Id == acc1.Id)).FirstOrDefault();

            accountService.deleteAccount(acc.Id);
            accountService.deleteAccount(acc1.Id);

            Assert.IsNotNull(friendship);
            Assert.IsNull(friendship1);
        }
Exemple #3
0
        public IHttpActionResult Post(SignUpAccountDTO account)
        {
            var accountService         = new SignUpAccountService();
            AccountSimpleDTO accountVM = accountService.addAccount(account);

            if (accountVM == null)
            {
                return(NotFound());
            }

            return(Ok(accountVM));
        }
Exemple #4
0
        public IHttpActionResult Get(int id)
        {
            var accountSignUpService = new SignUpAccountService();

            SignUpAccountDTO accountVM = accountSignUpService.getAccountById(id);

            if (accountVM == null)
            {
                return(NotFound());
            }

            return(Ok(accountVM));
        }
Exemple #5
0
        public IHttpActionResult Put(SignUpAccountDTO suaccountVM)
        {
            if (ModelState.IsValid)
            {
                var accountSignUpService = new SignUpAccountService();

                SignUpAccountDTO accountVM = accountSignUpService.editAccount(suaccountVM);

                if (accountVM == null)
                {
                    return(NotFound());
                }

                return(Ok(accountVM));
            }
            else
            {
                return(BadRequest("The model is not valid"));
            }
        }
        public void AddAccountWithTheSameUserName()
        {
            AdressDTO address = new AdressDTO();

            address.latitude  = 50;
            address.longitude = 30;
            address.address   = "Beautiful city";

            SignUpAccountDTO account = new SignUpAccountDTO();

            account.FirstName = "Ion";
            account.LastName  = "Popescu";
            account.UserName  = "******";
            account.Email     = "*****@*****.**";
            account.Adress    = address;
            account.Password  = "******";


            SignUpAccountService signUpAccountService = new SignUpAccountService();
            AccountSimpleDTO     account1             = signUpAccountService.addAccount(account);

            SignUpAccountDTO account2 = new SignUpAccountDTO();

            account2.FirstName = "Ion";
            account2.LastName  = "Rotari";
            account2.UserName  = "******";
            account2.Email     = "*****@*****.**";
            account2.Adress    = address;
            account2.Password  = "******";

            AccountSimpleDTO account3 = signUpAccountService.addAccount(account2);

            AccountService accountService = new AccountService();

            accountService.deleteAccount(account1.Id);

            Assert.IsNotNull(account1);
            Assert.IsNull(account3);
        }
        public void EditAccount()
        {
            AdressDTO address = new AdressDTO();

            address.latitude  = 50;
            address.longitude = 30;
            address.address   = "Beautiful city";

            SignUpAccountDTO account = new SignUpAccountDTO();

            account.FirstName = "Ion";
            account.LastName  = "Popescu";
            account.UserName  = "******";
            account.Email     = "*****@*****.**";
            account.Adress    = address;
            account.Password  = "******";


            SignUpAccountService signUpAccountService = new SignUpAccountService();
            AccountSimpleDTO     ac = signUpAccountService.addAccount(account);

            AccountService accountService = new AccountService();

            SignUpAccountDTO acc = signUpAccountService.getAccountById(ac.Id);

            acc.LastName       = "Casap";
            acc.Adress.address = "Cluj";

            acc = signUpAccountService.editAccount(acc);

            accountService.deleteAccount(ac.Id);

            Assert.IsNotNull(acc);
            Assert.AreEqual(acc.LastName, "Casap");
            Assert.AreEqual(acc.Adress.address, "Cluj");
        }
            public void AddMessageTest()
            {
                SignUpAccountService signUpAccountService = new SignUpAccountService();
                AccountService       accountService       = new AccountService();
                MessengerService     mesService           = new MessengerService();

                AdressDTO address = new AdressDTO();

                address.latitude  = 50;
                address.longitude = 30;
                address.address   = "Beautiful city";

                SignUpAccountDTO account = new SignUpAccountDTO();

                account.FirstName = "Ion";
                account.LastName  = "Popescu";
                account.UserName  = "******";
                account.Email     = "*****@*****.**";
                account.Adress    = address;
                account.Password  = "******";

                SignUpAccountDTO account1 = new SignUpAccountDTO();

                account1.FirstName = "Dfsadsa";
                account1.LastName  = "Ddsadsad";
                account1.UserName  = "******";
                account1.Email     = "*****@*****.**";
                account1.Adress    = address;
                account1.Password  = "******";



                AccountSimpleDTO acc  = signUpAccountService.addAccount(account);
                AccountSimpleDTO acc1 = signUpAccountService.addAccount(account1);


                ConversationDTO conv = new ConversationDTO();

                conv.UserOne = acc;
                conv.UserTwo = acc1;

                conv = mesService.CreateConversation(conv);

                MessageDTO message = new MessageDTO();

                message.User           = acc;
                message.ConversationId = conv.Id;
                message.Text           = "Salut";
                message.Date           = DateTime.Now;

                message = mesService.addMessage(message);

                var messages = mesService.GetMessages(5, 1, acc.Id, acc1.Id);

                MessageDTO myMes = messages.FirstOrDefault();

                mesService.deleteMessage(message.Id);
                mesService.RemoveConversation(conv.Id);
                accountService.deleteAccount(acc.Id);
                accountService.deleteAccount(acc1.Id);


                Assert.IsNotNull(message);
                Assert.IsNotNull(conv);
                Assert.IsNotNull(messages);
                Assert.AreEqual(myMes.Text, "Salut");
            }