public void GivenPerson_WhenSearching_IsAbleToFindHim() { int contextId; // Arrange using (var entities = new DataContextModelContainer()) { var currentContext = new Context { Name = "Testcontext 1234", IsTest = true, DateCreated = DateTime.Now }; entities.Contexts.AddObject(currentContext); var person = new Person { FirstName = "Rune", LastName = "Rystad" }; person.ContextId = currentContext.Id; entities.People.AddObject(person); entities.SaveChanges(); contextId = currentContext.Id; } // Act using (var search = new DataContextModelContainer()) { var people = from p in search.People where p.FirstName == "Rune" && p.ContextId == contextId select p; // Assert Assert.AreEqual(1, people.Count()); Assert.AreEqual("Rystad", people.First().LastName); } }
public void Setup() { using (var entities = new DataContextModelContainer()) { var currentContext = new Context(); currentContext.Name = "Testcontext 1234"; currentContext.IsTest = true; currentContext.DateCreated = DateTime.Now; entities.Contexts.AddObject(currentContext); entities.SaveChanges(); CurrentContextId = currentContext.Id; } }
/// <summary> /// Create a new Context object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="isTest">Initial value of the IsTest property.</param> /// <param name="dateCreated">Initial value of the DateCreated property.</param> public static Context CreateContext(global::System.Int32 id, global::System.String name, global::System.Boolean isTest, global::System.DateTime dateCreated) { Context context = new Context(); context.Id = id; context.Name = name; context.IsTest = isTest; context.DateCreated = dateCreated; return context; }
/// <summary> /// Deprecated Method for adding a new object to the Contexts EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToContexts(Context context) { base.AddObject("Contexts", context); }