Example #1
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");
        }
Example #2
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");
        }
Example #3
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");
        }
Example #4
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");
        }
Example #5
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");
        }