public void UpdateShouldFail(string s, int i, TestUnique.R r, Guid id) { string error = null; try { Update(s, i, r, id); } catch (Exception ex) { Console.WriteLine(ex.GetType().Name + ": " + ex.Message); error = ex.Message; _executionContext.EntityFrameworkContext.ClearCache(); } Assert.IsNotNull(error, "Update should have failed with an exception."); }
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"); } }
public void Update(string s, int i, TestUnique.R r, Guid id) { _repository.TestUnique.E.Update(new[] { new TestUnique.E { S = s, I = i, R = r, ID = id } }); }
public void InsertShouldFail(string s, int i, TestUnique.R r) { string error = null; try { Insert(s, i, r); } catch (Exception ex) { Console.WriteLine(ex.GetType().Name + ": " + ex.Message); error = ex.Message; _executionContext.NHibernateSession.Clear(); } Assert.IsNotNull(error, "Insert should have failed with an exception."); }
public void Insert(string s, int i, TestUnique.R r, Guid? id = null) { _repository.TestUnique.E.Insert(new[] { new TestUnique.E { S = s, I = i, R = r, ID = id ?? Guid.NewGuid() } }); }