Пример #1
0
        public void Select_Single_Returns_Single_Element_Matching_SellerId()
        {
            BagDML bagdml = new BagDML();

            ClearDatabase();
            InsertTestData();
            Bag expected = new Bag(1);

            Bag actual = bagdml.Select_Single("sellerId:1");

            Assert.AreEqual(expected, actual);
        }
Пример #2
0
        public void Insert_Single_Inserts_Bag()
        {
            ClearDatabase();
            BagDML bagdml   = new BagDML();
            Bag    expected = new Bag(0);

            bagdml.Insert_Single(expected);
            Bag  actual = getMultipleBags()[0];
            bool eql    = expected.Equals(actual);

            Assert.AreEqual(expected, actual);
        }
Пример #3
0
        public void Update_Single_Updates_Row_Matching_Id()
        {
            ClearDatabase();
            InsertTestData();
            BagDML bagdml   = new BagDML();
            Bag    expected = new Bag(1, 2, DateTime.Now);

            bagdml.Update_Single(expected);

            Bag actual = getBagById(1);

            Assert.AreEqual(expected, actual);
        }
Пример #4
0
        public void Select_Single_With_No_Conditions_Throws_ArgumentException()
        {
            BagDML            bagdml   = new BagDML();
            ArgumentException expected = null;

            try
            {
                bagdml.Select_Single("");
            }
            catch (ArgumentException e)
            {
                expected = e;
            }

            Assert.IsNotNull(expected);
        }
Пример #5
0
        public void Update_Single_Given_Bag_Without_Id_Throws_ArgumentException()
        {
            BagDML            bagdml   = new BagDML();
            ArgumentException expected = null;
            Bag bag = new Bag(0);

            try
            {
                bagdml.Update_Single(bag);
            }
            catch (ArgumentException e)
            {
                expected = e;
            }

            Assert.IsNotNull(expected);
        }
Пример #6
0
        public void Insert_Single_Runs_Without_Errors()
        {
            ClearDatabase();
            BagDML bagdml = new BagDML();
            Bag    bag    = new Bag(0);

            try
            {
                bagdml.Insert_Single(bag);
                Assert.IsTrue(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Assert.Fail();
            }
        }
Пример #7
0
        public void Delete_Single_Deletes_Single_Entry()
        {
            BagDML bagDML = new BagDML();

            ClearDatabase();
            InsertTestData();

            int expected = Count() - 1;

            Bag bag = new Bag(1, 1, DateTime.Now);

            bagDML.Delete_Single(bag);

            int actual = Count();

            Assert.AreEqual(expected, actual);
        }
Пример #8
0
        public void Insert_Multiple_Inserts_Bags()
        {
            ClearDatabase();
            BagDML     bagdml   = new BagDML();
            List <Bag> expected = new List <Bag>()
            {
                new Bag(0),
                new Bag(0)
            };

            bagdml.Insert_Multiple(expected);
            List <Bag> actual = getMultipleBags();

            for (int i = 0; i < actual.Count; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
        }
Пример #9
0
        public void Select_Multiple_Returns_Multiple_Elements_Matching_SellerId()
        {
            ClearDatabase();
            BagDML bagdml = new BagDML();

            InsertTestData();
            List <Bag> expected = new List <Bag> {
                new Bag(1),
                new Bag(1)
            };

            List <Bag> actual = bagdml.Select_Multiple("sellerId:1");

            // Do not know another way to compare list items
            for (int i = 0; i < actual.Count; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
        }
Пример #10
0
        public void Update_Multiple_Given_Bag_Without_Id_Throws_ArgumentException()
        {
            BagDML            bagdml   = new BagDML();
            ArgumentException expected = null;
            List <Bag>        bags     = new List <Bag> {
                new Bag(0),
                new Bag(0)
            };

            try
            {
                bagdml.Update_Multiple(bags);
            }
            catch (ArgumentException e)
            {
                expected = e;
            }

            Assert.IsNotNull(expected);
        }
Пример #11
0
        public void Update_Multiple_Updates_Row_Matching_Id()
        {
            BagDML bagdml = new BagDML();

            ClearDatabase();
            InsertTestData();
            List <Bag> expected = new List <Bag> {
                new Bag(1, 2, DateTime.Now),
                new Bag(2, 2, DateTime.Now),
                new Bag(3, 1, DateTime.Now)
            };

            bagdml.Update_Multiple(expected);

            List <Bag> actual = getMultipleBags();

            for (int i = 0; i < actual.Count; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
        }
Пример #12
0
        public void Delete_Multiple_Deletes_Multiple_Entries()
        {
            BagDML bagdml = new BagDML();

            ClearDatabase();
            InsertTestData();

            int expected = Count() - 2;

            List <Bag> bags = new List <Bag>
            {
                new Bag(1, 1, DateTime.Now),
                new Bag(2, 1, DateTime.Now),
            };

            bagdml.Delete_Multiple(bags);

            int actual = Count();

            Assert.AreEqual(expected, actual);
        }
Пример #13
0
        public void Insert_Multiple_Runs_Without_Errors()
        {
            ClearDatabase();
            BagDML     bagdml = new BagDML();
            List <Bag> bags   = new List <Bag>()
            {
                new Bag(0),
                new Bag(0)
            };

            try
            {
                bagdml.Insert_Multiple(bags);
                // Pass test if it runs without error
                Assert.IsTrue(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Assert.Fail();
            }
        }
Пример #14
0
        public void Delete_Multiple_Runs_Without_Errors()
        {
            BagDML     bagdml = new BagDML();
            List <Bag> bags   = new List <Bag>
            {
                new Bag(0),
                new Bag(0)
            };

            ArgumentException expected = null;

            try
            {
                bagdml.Delete_Multiple(bags);
            }
            catch (ArgumentException e)
            {
                expected = e;
            }

            Assert.IsNotNull(expected);
        }