using CheckArticlesForSpam.Models;
using CheckArticlesForSpam.ViewModels;
using ChecksArticlesForSpam.ViewModels;

namespace TestCheckArticlesForSpam.Test
{
    [TestClass]
    public class UnitTest
    {
        [TestMethod]
        public void TestMethod_AddUserInDataBase_OneNullField_ExeptedUser_ResultUser()
        {

            RegistrationPageViewModel registrationPageViewModel = new RegistrationPageViewModel(new MlgTeamContext());
            registrationPageViewModel.NewUser.Login = null;
            registrationPageViewModel.NewUser.Username = "nik";
            registrationPageViewModel.NewUser.IdUser = 1;
            registrationPageViewModel.NewUser.Password = "testtest2";
            registrationPageViewModel.RepeatInputPassword = "testtest2";
            registrationPageViewModel.NewUser.Phone = "+79234560134";
            User? exepted = null;
            User? result = registrationPageViewModel.AddUserInDataBase();
            Assert.AreEqual(exepted, result);
        }
        [TestMethod]
        public void TestMethod_AddUserInDataBase_OneEmptyField_ExeptedUser_ResultUser()
        {

            RegistrationPageViewModel registrationPageViewModel = new RegistrationPageViewModel(new MlgTeamContext());
            registrationPageViewModel.NewUser.Login = "";
            registrationPageViewModel.NewUser.Username = "nik";
            registrationPageViewModel.NewUser.IdUser = 1;
            registrationPageViewModel.NewUser.Password = "testtest2";
            registrationPageViewModel.RepeatInputPassword = "testtest2";
            registrationPageViewModel.NewUser.Phone = "+79234560134";
            User? exepted = null;
            User? result = registrationPageViewModel.AddUserInDataBase();
            Assert.AreEqual(exepted, result);
        }
        [TestMethod]
        public void TestMethod_AddUserInDataBase_NotCorrectPhone_ExeptedUser_ResultUser()
        {

            RegistrationPageViewModel registrationPageViewModel = new RegistrationPageViewModel(new MlgTeamContext());
            registrationPageViewModel.NewUser.Login = "TestinUser";
            registrationPageViewModel.NewUser.Username = "nik";
            registrationPageViewModel.NewUser.IdUser = 100;
            registrationPageViewModel.NewUser.Password = "testtest2";
            registrationPageViewModel.RepeatInputPassword = "testtest2";
            registrationPageViewModel.NewUser.Phone = "79234560134";
            User? exepted = null;
            User? result = registrationPageViewModel.AddUserInDataBase();
            Assert.AreEqual(exepted, result);
        }
        [TestMethod]
        public void TestMethod_AddUserInDataBase_BusyLogin_ExeptedUser_ResultUser()
        {

            RegistrationPageViewModel registrationPageViewModel = new RegistrationPageViewModel(new MlgTeamContext());
            registrationPageViewModel.NewUser.Login = "1";
            registrationPageViewModel.NewUser.Username = "nik";
            registrationPageViewModel.NewUser.IdUser = 100;
            registrationPageViewModel.NewUser.Password = "testtest2";
            registrationPageViewModel.RepeatInputPassword = "testtest2";
            registrationPageViewModel.NewUser.Phone = "79234560134";
            User? exepted = null;
            User? result = registrationPageViewModel.AddUserInDataBase();
            Assert.AreEqual(exepted, result);
        }
        [TestMethod]
        public void TestMethod_AddUserInDataBase_PasswordLess6Symbol_ExeptedUser_ResultUser()
        {

            RegistrationPageViewModel registrationPageViewModel = new RegistrationPageViewModel(new MlgTeamContext());
            registrationPageViewModel.NewUser.Login = "TestingUser";
            registrationPageViewModel.NewUser.Username = "nik";
            registrationPageViewModel.NewUser.IdUser = 100;
            registrationPageViewModel.NewUser.Password = "test";
            registrationPageViewModel.RepeatInputPassword = "test";
            registrationPageViewModel.NewUser.Phone = "+79234560134";
            User? exepted = null;
            User? result = registrationPageViewModel.AddUserInDataBase();
            Assert.AreEqual(exepted, result);
        }
        [TestMethod]
        public void TestMethod_AddUserInDataBase_PasswordNotHaveNum_ExeptedUser_ResultUser()
        {

            RegistrationPageViewModel registrationPageViewModel = new RegistrationPageViewModel(new MlgTeamContext());
            registrationPageViewModel.NewUser.Login = "TestingUser";
            registrationPageViewModel.NewUser.Username = "nik";
            registrationPageViewModel.NewUser.IdUser = 100;
            registrationPageViewModel.NewUser.Password = "testtest";
            registrationPageViewModel.RepeatInputPassword = "testtest";
            registrationPageViewModel.NewUser.Phone = "+79234560134";
            User? exepted = null;
            User? result = registrationPageViewModel.AddUserInDataBase();
            Assert.AreEqual(exepted, result);
        }
        [TestMethod]
        public void TestMethod_AddUserInDataBase_PasswordDoesNotMatchWithRepeatInputPassword_ExeptedUser_ResultUser()
        {

            RegistrationPageViewModel registrationPageViewModel = new RegistrationPageViewModel(new MlgTeamContext());
            registrationPageViewModel.NewUser.Login = "TestingUser";
            registrationPageViewModel.NewUser.Username = "nik";
            registrationPageViewModel.NewUser.IdUser = 100;
            registrationPageViewModel.NewUser.Password = "testtest";
            registrationPageViewModel.RepeatInputPassword = "3";
            registrationPageViewModel.NewUser.Phone = "+79234560134";
            User? exepted = null;
            User? result = registrationPageViewModel.AddUserInDataBase();
            Assert.AreEqual(exepted, result);
        }
        [TestMethod]
        public void TestMethod_GetDataArticle_TitleArticleNull_ExeptedKey1_ResultKey1()
        {
            ArticleDataPageViewModel articleDataPageViewModel = new ArticleDataPageViewModel();
            string exepted = "1";
            articleDataPageViewModel.TitleArticle = null;
            Dictionary<string, Article> resultDictionary = articleDataPageViewModel.GetDataArticle(new User() { IdUser = 100 });
            string result = resultDictionary.Keys.First();
            Assert.AreEqual(exepted, result);
        }
        [TestMethod]
        public void TestMethod_GetDataArticle_TitleArticleNull_ExeptedKey2_ResultKey2()
        {
            ArticleDataPageViewModel articleDataPageViewModel = new ArticleDataPageViewModel();
            string exepted = "2";
            articleDataPageViewModel.TitleArticle = "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest";
            Dictionary<string, Article> resultDictionary = articleDataPageViewModel.GetDataArticle(new User() { IdUser = 100 });
            string result = resultDictionary.Keys.First();
            Assert.AreEqual(exepted, result);
        }
        public void TestMethod_GetDataArticle_CorrectArticle_ExeptedKey3_ResultKey3()
        {
            ArticleDataPageViewModel articleDataPageViewModel = new ArticleDataPageViewModel();
            string exepted = "3";
            articleDataPageViewModel.TitleArticle = "test";
            Dictionary<string, Article> resultDictionary = articleDataPageViewModel.GetDataArticle(new User() { IdUser = 100 });
            string result = resultDictionary.Keys.First();
            Assert.AreEqual(exepted, result);
        }
    }
}