Example #1
0
        public void Test_Index()
        {
            //Arrange
            MockHandler mock = new MockHandler();
            User        user = new User()
            {
                Username = "******", langPref = "NL"
            };
            Glossary glos = new Glossary()
            {
                GlossaryId = 1, Dutch = "Hallo", English = "Hello", Spanish = "Ola"
            };

            mock.Glossaries = new List <Glossary>()
            {
                glos
            };
            mock.Users = new List <User>()
            {
                user
            };
            mock.SetTempUsername(null, "*****@*****.**");
            mock.SetTempRole(null, "Student");
            HomeController cont = new HomeController(null, mock);

            //Act
            cont.Index("SP");
            string role   = mock.GetTempRole(null);
            var    result = mock.GetUsers().FirstOrDefault();

            //Assert
            Assert.Equal("Student", role);
            Assert.Equal("SP", result.langPref);
        }
Example #2
0
        public void Test_AddFavourite()
        {
            //Arrange
            MockHandler mock = new MockHandler();

            mock.SetTempUsername(null, "Jan");
            Location l1 = new Location()
            {
                LocationId = 150
            };
            Location l2 = new Location()
            {
                LocationId = 1
            };
            Favourite f1 = new Favourite()
            {
                LocationId = l1.LocationId, Username = "******"
            };
            Favourite f2 = new Favourite()
            {
                LocationId = l2.LocationId, Username = "******"
            };

            mock.Locations = new List <Location>()
            {
                l1, l2
            };
            mock.Favourites = new List <Favourite>()
            {
                f1, f2
            };
            HomeController cont = new HomeController(null, mock);

            //Act
            bool falseResult = cont.AddFavourite(150);
            bool trueResult  = cont.AddFavourite(1);

            //Assert
            Assert.True(trueResult);
            Assert.False(falseResult);
        }
Example #3
0
        public void Test_DeleteAccount()
        {
            //Arrange
            MockHandler mock = new MockHandler();

            mock.SetTempUsername(null, "Jan");
            User user = new User()
            {
                Username = "******"
            };

            mock.Users = new List <User>()
            {
                user
            };
            HomeController cont = new HomeController(null, mock);

            //Act
            bool falseResult = cont.DeleteAccount();

            //Assert
            Assert.False(falseResult);
        }