Ejemplo n.º 1
0
 public void Cleanup()
 {
     using (var context = new MyContext())
     {
         context.Database.Delete();
     }
 }
Ejemplo n.º 2
0
 public void CreateData()
 {
     using (var context = new MyContext())
     {
         context.Database.Delete();
         context.Database.Create();
         context.Set<Foo>().Add(new Foo { Bar = 1, Baz = 2 });
         context.Set<Foo>().Add(new Foo { Bar = 2, Baz = 1 });
         context.Set<Foo>().Add(new Foo { Bar = 1, Baz = 2 });
         context.SaveChanges();
     }
 }
Ejemplo n.º 3
0
 public void PassesParametersCorrectly()
 {
     using (var context = new MyContext())
     {
         var recordsAffected = context.ExecuteNonQuery("delete Foos where Bar = @Bar and Baz = @Baz",
                                                       new {Baz = 1, Bar = 2});
         Assert.AreEqual(1, recordsAffected);
     }
     using (var context = new MyContext())
     {
         Assert.False(context.Foos.Any(x => x.Bar == 2 && x.Baz == 1));
     }
 }