protected override void Context() { DbContext = new PRToolsEntities(); DocumentRepository = new DocumentRepository(DbContext, new TimeProvider()); _transactionScope = new TransactionScope(); using (_transactionScope) { TestCustomer = new Customer { CustomerType = DbContext.CustomerTypes.FirstOrDefault(), GooglePlacesURL = "GooglePlacesURL", TwitterHandle = "TwitterHandle", WebsiteURL = "WebsiteURL", ListName = "ListName", Name = "Name", ParentCustomerId = 0, Phone = "555-555-5555", }; DbContext.Customers.AddObject(TestCustomer); TestDocument = new Document { Title = "TestTitle", Body = "This is a test body", CreatedByUsername = "******", CreatedDate = new DateTime(2011, 1, 1), }; DbContext.Documents.AddObject(TestDocument); DbContext.SaveChanges(); } }
protected override void Context() { DBContext = new PRToolsEntities(); TimeProvider = new TimeProvider(); DocumentRepository = new DocumentRepository(DBContext, TimeProvider); _testConntection = new SqlConnection("Server=SULPYWIN7;Database=PRTools;Integrated Security=True;"); _testConntection.Open(); _transactionScope = new TransactionScope(); using (_transactionScope) { var sql = @"SET IDENTITY_INSERT Customers ON INSERT INTO Customers ([CustomerId], [CustomerTypeKey], [GooglePlacesURL], [ListName], [Name], [ParentCustomerId], [Phone], [TwitterHandle], [WebsiteURL]) VALUES ("+CustomerId+@", 'CorporateClient', 'googlePlacesURL', 'ListName', 'Name', 0, '555-555-5555', '@twitterhandle', 'www.website.com') SET IDENTITY_INSERT Customers OFF SET IDENTITY_INSERT CustomLocalizationFields ON INSERT INTO CustomLocalizationFields ([CustomLocalizationFieldId], [FieldName]) VALUES (1, '"+SomeCustomField+@"') SET IDENTITY_INSERT CustomLocalizationFields OFF SET IDENTITY_INSERT CustomLocalizationFieldValues ON INSERT INTO CustomLocalizationFieldValues ([CustomLocalizationFieldValueId], [FieldValue], [CustomerId], [CustomLocalizationFieldId]) VALUES (1, '"+SomeCustomFieldValue+@"', 5, 1) SET IDENTITY_INSERT CustomLocalizationFieldValues OFF"; var command = new SqlCommand(sql, _testConntection); command.ExecuteNonQuery(); } }