public ExtendedContextTests()
 {
     _storeName = Guid.NewGuid().ToString();
     using (var context = GetContext())
     {
         // Put in data
         context.Companies.Add(new Company
             {
                 Name = "NetworkedPlanet",
                 TickerSymbol = "NP",
                 HeadCount = 4,
                 CurrentSharePrice = 1.0m
             });
         var ftse = context.Markets.Create();
         ftse.Name = "FTSE";
         var cac = new Company
             {
                 Name = "CAC Limited",
                 TickerSymbol = "CAC",
                 ListedOn = ftse,
                 HeadCount = 200,
                 CurrentSharePrice = 1.0m
             };
         context.Companies.Add(cac);
         context.SaveChanges();
     }
 }
 public void SetUp()
 {
     _context = new MyEntityContext("type=embedded;storesDirectory=" + Configuration.StoreLocation + ";storeName=EFStringComparisonTests_" + DateTime.Now.Ticks);
     var np = new Company {Name = "NetworkedPlanet"};
     var apple = new Company {Name = "Apple"};
     _context.Companies.Add(np);
     _context.Companies.Add(apple);
     _context.SaveChanges();
 }
        public void TestAddGeneratesIdentity()
        {
            string storeName = Guid.NewGuid().ToString();
            var dataObjectStore = _dataObjectContext.CreateStore(storeName);
            var context = new MyEntityContext(dataObjectStore);
            var skill = new Skill {Name = "Bar"};
            var person = new Person {Name = "Kal"};
            //var person2 = new Person2 {Name = "Jen"};
            var company = new Company {Name = "NetworkedPlanet"};
            context.Persons.Add(person);
            //context.Person2s.Add(person2);
            context.Skills.Add(skill);
            context.Companies.Add(company);
            context.SaveChanges();

            dataObjectStore = _dataObjectContext.OpenStore(storeName);
            context = new MyEntityContext(dataObjectStore);
            var foundPerson = context.Persons.Where(p => p.Name.Equals("Kal")).FirstOrDefault();
            //var foundPerson2 = context.Person2s.Where(p => p.Name.Equals("Jen")).FirstOrDefault();
            var foundSkill = context.Skills.FirstOrDefault(s => s.Name.Equals("Bar"));
            var foundCompany = context.Companies.FirstOrDefault(s => s.Name.Equals("NetworkedPlanet"));
            Assert.IsNotNull(foundPerson);
            //Assert.IsNotNull(foundPerson2);
            Assert.IsNotNull(foundSkill);
            Assert.IsNotNull(foundCompany);

            Assert.IsTrue(foundPerson.Id.StartsWith(Constants.GeneratedUriPrefix));
            Assert.IsTrue(foundCompany.Id.StartsWith(Constants.GeneratedUriPrefix));
            Guid guid;
            Assert.IsTrue(Guid.TryParse(foundSkill.Id, out guid));
        }