Пример #1
0
            public void Insert(string s, int i, TestUnique.R r, bool shouldFail = false)
            {
                string error   = null;
                var    newItem = new TestUnique.Multi {
                    S = s, I = i, RID = r.ID, ID = Guid.NewGuid()
                };

                try
                {
                    Console.WriteLine("Inserting " + s + ", " + i + " ...");
                    _repository.TestUnique.Multi.Insert(new[] { newItem });
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.GetType().Name + ": " + ex.Message);
                    error = ex.Message;
                    if (!shouldFail)
                    {
                        throw;
                    }
                }
                if (shouldFail)
                {
                    Assert.IsNotNull(error, "Insert should have failed with an exception.");
                    TestUtility.AssertContains(error, "Cannot insert duplicate key");
                }
            }
Пример #2
0
 public void Insert(string s, int i, TestUnique.R r, bool shouldFail = false)
 {
     string error = null;
     var newItem = new TestUnique.Multi { S = s, I = i, R = r, ID = Guid.NewGuid() };
     try
     {
         Console.WriteLine("Inserting " + s + ", " + i + " ...");
         _repository.TestUnique.Multi.Insert(new[] { newItem });
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.GetType().Name + ": " + ex.Message);
         error = ex.Message;
         if (!shouldFail)
             throw;
     }
     if (shouldFail)
     {
         Assert.IsNotNull(error, "Insert should have failed with an exception.");
         TestUtility.AssertContains(error, "Cannot insert duplicate key");
     }
 }