Beispiel #1
0
        public void TearDown()
        {
            try
            {
                Product.DeleteProduct(TestProductID2);
            }
            catch (Exception) { }
            try
            {
                Product.DeleteProduct(TestProductID);
            }
            catch (Exception) { }

            try
            {
                Category.DeleteCategory(TestCategoryID);
            }
            catch (Exception) { }

            try
            {
                Category.DeleteCategory(TestCategoryID2);
            }
            catch (Exception) { }
        }
Beispiel #2
0
        public void Step_22_Double_Delete()
        {
            Console.WriteLine("20. Deleting the category twice.");
            Stopwatch watch = Stopwatch.StartNew();

            Category category = Category.GetByCategoryId(TestCategoryID);

            Assert.IsTrue(string.Equals(category.CategoryId, TestCategoryID, StringComparison.InvariantCultureIgnoreCase));
            Assert.IsFalse(category.IsDeleted);
            category.Delete();

            //Delete the category the other way before calling save which would call a delete. This should simulate a concurency issue.
            Category.DeleteCategory(TestCategoryID);
            try
            {
                Category.GetByCategoryId(TestCategoryID);
                Assert.Fail("Record exists when it should have been deleted.");
            }
            catch (Exception)
            {
                // Exception was thrown if record doesn't exist.
                Assert.IsTrue(true);
            }

            // Call delete on an already deleted item.
            Assert.IsTrue(category.IsDeleted);

            try
            {
                Assert.IsTrue(category.IsValid, category.BrokenRulesCollection.ToString());
                category = category.Save();
                Assert.Fail("Record exists when it should have been deleted.");
            }
            catch (Exception)
            {
                // Exception was thrown if record doesn't exist.
                Assert.IsTrue(true);
            }

            Assert.IsTrue(string.Equals(category.CategoryId, TestCategoryID, StringComparison.InvariantCultureIgnoreCase));
            Console.WriteLine("Time: {0} ms", watch.ElapsedMilliseconds);
        }