Пример #1
0
        public void AddUserItemTest()
        {
            //Arrange
            DatabaseSvc testDAL = new DatabaseSvc(_connectionString);

            UserItem testUser = new UserItem
            {
                FirstName = "Jimmi",
                LastName  = "Test",
                Email     = "*****@*****.**",
                UserName  = "******",
                Password  = "******",
                Salt      = "JimmiSalt",
                IsAdmin   = false
            };

            //Act
            int      testUserId      = testDAL.AddUserItem(testUser);
            UserItem confirmTestUser = testDAL.GetUserItem(testUser.UserName);

            //Assert
            int confirmTestUserId = _userId + 1;

            Assert.AreEqual(confirmTestUserId, confirmTestUser.Id);
            Assert.AreEqual(confirmTestUser.Password, testUser.Password);
            Assert.AreEqual(confirmTestUser.Salt, testUser.Salt);
        }
Пример #2
0
        public void AddTagToCardTest()
        {
            //Arrange
            DatabaseSvc testDAL = new DatabaseSvc(_connectionString);


            string tagName = "AddTag Test";
            int    cardId  = _cardId1;


            //Act
            TagItem  testTagHasId = testDAL.AddTagToCard(tagName, cardId);
            CardItem confirmCard  = testDAL.GetCard(_cardId1);

            //Assert
            bool tagAdded = false;

            foreach (TagItem item in confirmCard.Tags)
            {
                if (item.TagName == tagName)
                {
                    tagAdded = true;
                }
            }

            Assert.AreEqual(true, tagAdded, "Confirm tag was added");
        }
Пример #3
0
        public void GetAllCardsInDeckTest()
        {
            //Arrange
            DatabaseSvc testDAL = new DatabaseSvc(_connectionString);

            //Act
            List <CardItem> cards = testDAL.GetAllCardsForDeck(_deckId1);

            //Assert
            Assert.AreEqual(1, cards.Count(), "Confirm number of tags");
            Assert.AreEqual(TestCard1Term, cards[0].Term);
        }
Пример #4
0
        public void GetAllDecksForCardTest()
        {
            //Arrange
            DatabaseSvc testDAL = new DatabaseSvc(_connectionString);

            //Act
            List <DeckItem> decks = testDAL.GetAllDecksForCard(_cardId1, _userId);

            //Assert
            Assert.AreEqual(1, decks.Count(), "Confirm number of Decks");
            Assert.AreEqual(TestDeckName, decks[0].Name, "Confirm Deck Name");
        }
Пример #5
0
        public void GetUserItemTest()
        {
            //Arrange
            DatabaseSvc testDAL = new DatabaseSvc(_connectionString);

            //Act
            UserItem user = testDAL.GetUserItem(TestUserName);

            //Assert
            Assert.AreEqual(_userId, user.Id);
            Assert.AreEqual(TestPassword, user.Password);
            Assert.AreEqual(TestSalt, user.Salt);
        }
Пример #6
0
        public void DeleteAllTagsOnCardTest()
        {
            //Arrange
            DatabaseSvc testDAL = new DatabaseSvc(_connectionString);

            int testId = _cardId1;

            //Act
            bool testDeletionSuccess = testDAL.DeleteAllTagsOnCard(testId);

            //Assert
            Assert.AreEqual(true, testDeletionSuccess, "Confirm deletion");
        }
Пример #7
0
        public void GetAllTagsForCardTest()
        {
            //Arrange
            DatabaseSvc testDAL = new DatabaseSvc(_connectionString);

            //Act
            List <TagItem> tags = testDAL.GetAllTagsForCard(_cardId1);

            //Assert
            Assert.AreEqual(2, tags.Count(), "Confirm number of tags");
            Assert.AreEqual(TestTag1Name, tags[0].TagName);
            Assert.AreEqual(TestTag2Name, tags[1].TagName);
        }
Пример #8
0
        public void GetDeckTest()
        {
            //Arrange
            DatabaseSvc testDAL = new DatabaseSvc(_connectionString);

            //Act
            DeckItem deck = testDAL.GetDeck(_deckId1);

            //Assert
            Assert.AreEqual(_deckId1, deck.Id, "Confirm deck id");
            Assert.AreEqual(TestDeckName, deck.Name, "Confirm deck name");
            Assert.AreEqual(TestDeckDescription, deck.Description, "Confirm deck description");
            Assert.AreEqual(1, deck.CardCount, "Confirm number of cards");
        }
Пример #9
0
        public void GetCardTest()
        {
            //Arrange
            DatabaseSvc testDAL = new DatabaseSvc(_connectionString);

            //Act
            CardItem card = testDAL.GetCard(_cardId1);

            //Assert
            Assert.AreEqual(_cardId1, card.Id, "Confirm card id");
            Assert.AreEqual(TestCard1Term, card.Term, "Confirm term");
            Assert.AreEqual(TestCard1Definition, card.Definition, "confirm definition");
            Assert.AreEqual(2, card.Tags.Count(), "Confirm tags were added");
        }
Пример #10
0
        public void AddCardToDeckTest()
        {
            //Arrange
            DatabaseSvc testDAL = new DatabaseSvc(_connectionString);

            //Act
            List <CardItem> oldCards = testDAL.GetAllCardsForDeck(_deckId1);
            DeckItem        deck     = testDAL.AddCardToDeck(_cardId2, _deckId1);
            List <CardItem> newCards = testDAL.GetAllCardsForDeck(_deckId1);

            //Assert
            Assert.AreEqual(1, (newCards.Count() - oldCards.Count()), "Confirm number of cards");
            Assert.AreEqual(TestCard1Term, newCards[0].Term, "Confirm old card term");
            Assert.AreEqual(TestCard2Term, newCards[1].Term, "Confirm new card term");
        }
Пример #11
0
        public void SearchCardsTest()
        {
            //Arrange
            DatabaseSvc testDAL              = new DatabaseSvc(_connectionString);
            string      searchTagTest        = TestTag1Name;
            string      searchTermTest       = TestCard2Term;
            string      searchDefinitionTest = TestCard2Definition;

            string searchTagLikeTest        = "Tag";
            string searchTermLikeTest       = "Term";
            string searchDefinitionLikeTest = "Definition";

            //Act
            //Test Exact Term results
            List <CardItem> tagTestResult        = testDAL.SearchCards(searchTagTest);
            List <CardItem> termTestResult       = testDAL.SearchCards(searchTermTest);
            List <CardItem> definitionTestResult = testDAL.SearchCards(searchDefinitionTest);

            //Test "Like" terms test
            List <CardItem> tagLikeTestResult        = testDAL.SearchCards(searchTagLikeTest);
            List <CardItem> termLikeTestResult       = testDAL.SearchCards(searchTermLikeTest);
            List <CardItem> definitionLikeTestResult = testDAL.SearchCards(searchDefinitionLikeTest);

            //Get cards from database to compare
            CardItem card1 = testDAL.GetCard(_cardId1);
            CardItem card2 = testDAL.GetCard(_cardId2);

            List <CardItem> allCards = new List <CardItem> {
                card1, card2
            };

            //Assert
            Assert.AreEqual(tagTestResult[0].Id, card1.Id, "Exact Tag Test");
            Assert.AreEqual(termTestResult[0].Id, card2.Id, "Exact Term Test");
            Assert.AreEqual(definitionTestResult[0].Id, card2.Id, "Exact Definition Test");

            Assert.AreEqual(tagLikeTestResult[1].Id, card1.Id, "Like Tag Test");
            Assert.AreEqual(termLikeTestResult[3].Id, allCards[0].Id, "Like Term Test id1");
            Assert.AreEqual(termLikeTestResult[4].Id, allCards[1].Id, "Like Term Test id2");
            Assert.AreEqual(5, termLikeTestResult.Count(), "Like Term Count Test");
            Assert.AreEqual(definitionLikeTestResult[1].Id, allCards[0].Id, "Like Definition Test");
            Assert.AreEqual(definitionLikeTestResult[2].Id, allCards[1].Id, "Like Definition Test");
            Assert.AreEqual(3, definitionLikeTestResult.Count(), "Like Definition Count Test");
        }
Пример #12
0
        public void AddCardTest()
        {
            //Arrange
            DatabaseSvc testDAL = new DatabaseSvc(_connectionString);

            CardItem testCardNoId = new CardItem
            {
                Term       = "Front",
                Definition = "Back",
                UserID     = _userId
            };

            //Act
            CardItem testCardHasId   = testDAL.AddCard(testCardNoId);
            CardItem confirmTestCard = testDAL.GetCard(testCardHasId.Id);

            //Assert
            Assert.AreEqual(testCardNoId.Term, confirmTestCard.Term, "Confirm Term");
            Assert.AreEqual(testCardNoId.Definition, confirmTestCard.Definition, "Confirm Definition");
        }
Пример #13
0
        public void UpdateCardTest()
        {
            //Arrange
            DatabaseSvc testDAL = new DatabaseSvc(_connectionString);

            CardItem testCard = new CardItem
            {
                Id         = _cardId1,
                Term       = "Front",
                Definition = "Back",
                UserID     = _userId
            };

            //Act
            bool     CardUpdated     = testDAL.UpdateCard(testCard, _cardId1);
            CardItem confirmTestCard = testDAL.GetCard(_cardId1);

            //Assert
            Assert.AreEqual(testCard.Term, confirmTestCard.Term, "Confirm Term");
            Assert.AreEqual(testCard.Definition, confirmTestCard.Definition, "Confirm Definition");
        }
Пример #14
0
        public void DeleteDeckTest()
        {
            //Arrange
            DatabaseSvc testDAL = new DatabaseSvc(_connectionString);

            int testId = _deckId1;

            //Act
            int  oldDeckCount        = testDAL.GetAllDecksForUser(_userId).Count();
            bool cardDeletionSuccess = testDAL.DeleteDeck(testId);
            int  newDeckCount        = testDAL.GetAllDecksForUser(_userId).Count();
            bool removedDeck         = false;

            if (oldDeckCount - newDeckCount == 1)
            {
                removedDeck = true;
            }

            //Assert
            Assert.AreEqual(true, cardDeletionSuccess, "Confirm method success");
            Assert.AreEqual(true, removedDeck, "Confirm removal from database");
        }
Пример #15
0
        public void UpdateDeckTest()
        {
            //Arrange
            DatabaseSvc testDAL = new DatabaseSvc(_connectionString);

            DeckItem testDeck = new DeckItem
            {
                Id          = _deckId1,
                Name        = "New Test Deck!",
                Description = "Wow a cool new deck for testing updates!",
                UserID      = _userId
            };

            //Act
            bool     deckUpdated     = testDAL.UpdateDeck(testDeck, _deckId1);
            DeckItem confirmTestDeck = testDAL.GetDeck(_deckId1);

            //Assert
            Assert.AreEqual(true, deckUpdated, "Confirm Bool");
            Assert.AreEqual(testDeck.Name, confirmTestDeck.Name, "Confirm Name");
            Assert.AreEqual(testDeck.Description, confirmTestDeck.Description, "Confirm Description");
        }
Пример #16
0
        public void RemoveCardFromDeckTest()
        {
            //Arrange
            DatabaseSvc testDAL = new DatabaseSvc(_connectionString);

            int    cardId  = _cardId1;
            string tagName = TestTag1Name;

            //Act
            int  oldTagCount        = testDAL.GetAllTagsForCard(cardId).Count();
            bool tagDeletionSuccess = testDAL.RemoveTagFromCard(tagName, cardId);
            int  newTagCount        = testDAL.GetAllTagsForCard(cardId).Count();
            bool removedTag         = false;

            if (oldTagCount - newTagCount == 1)
            {
                removedTag = true;
            }

            //Assert
            Assert.AreEqual(true, tagDeletionSuccess, "Confirm method success");
            Assert.AreEqual(true, removedTag, "Confirm removal from database");
        }
Пример #17
0
        public void AddDeckTest()
        {
            //Arrange
            DatabaseSvc testDAL = new DatabaseSvc(_connectionString);

            DeckItem testDeckNoId = new DeckItem
            {
                Name        = "Test Name",
                Description = "Test Description",
                UserID      = _userId
            };

            //Act
            DeckItem testDeckHasId   = testDAL.AddDeck(testDeckNoId);
            DeckItem confirmTestDeck = testDAL.GetDeck(testDeckHasId.Id);

            //Assert
            int confirmTestDeckId = _deckId1 + 1;

            Assert.AreEqual(confirmTestDeckId, testDeckHasId.Id, "Confirm new id");
            Assert.AreEqual(testDeckNoId.Name, confirmTestDeck.Name, "Confirm Name");
            Assert.AreEqual(testDeckNoId.Description, confirmTestDeck.Description, "Confirm Description");
        }