public BloggingContext(CosmosTestStore testStore) { _connectionUri = testStore.ConnectionUri; _authToken = testStore.AuthToken; _name = testStore.Name; }
public async Task Can_add_update_delete_detached_entity_end_to_end_async() { using (var testDatabase = CosmosTestStore.CreateInitialized(DatabaseName)) { var options = Fixture.CreateOptions(testDatabase); var customer = new Customer { Id = 42, Name = "Theon" }; string storeId = null; using (var context = new CustomerContext(options)) { await context.Database.EnsureCreatedAsync(); var entry = context.Add(customer); await context.SaveChangesAsync(); context.Add(customer); storeId = entry.Property <string>("id").CurrentValue; } Assert.NotNull(storeId); using (var context = new CustomerContext(options)) { var customerFromStore = context.Set <Customer>().Single(); Assert.Equal(42, customerFromStore.Id); Assert.Equal("Theon", customerFromStore.Name); } using (var context = new CustomerContext(options)) { customer.Name = "Theon Greyjoy"; var entry = context.Entry(customer); entry.Property <string>("id").CurrentValue = storeId; entry.State = EntityState.Modified; await context.SaveChangesAsync(); } using (var context = new CustomerContext(options)) { var customerFromStore = context.Set <Customer>().Single(); Assert.Equal(42, customerFromStore.Id); Assert.Equal("Theon Greyjoy", customerFromStore.Name); } using (var context = new CustomerContext(options)) { var entry = context.Entry(customer); entry.Property <string>("id").CurrentValue = storeId; entry.State = EntityState.Deleted; await context.SaveChangesAsync(); } using (var context = new CustomerContext(options)) { Assert.Equal(0, context.Set <Customer>().Count()); } } }
public CosmosFixture() { TestStore = CosmosTestStore.Create(DatabaseName); }
public IdentifierShadowValuePresenceTestContext(CosmosTestStore testStore) { _connectionUri = testStore.ConnectionUri; _authToken = testStore.AuthToken; _name = testStore.Name; }
public TestStoreContext(CosmosTestStore testStore) { _testStore = testStore; }
public ReloadTestContext(CosmosTestStore testStore) { _connectionUri = testStore.ConnectionUri; _authToken = testStore.AuthToken; _name = testStore.Name; }
private DbContextOptions CreateOptions(CosmosTestStore testDatabase) => Fixture.AddOptions(testDatabase.AddProviderOptions(new DbContextOptionsBuilder())) .EnableDetailedErrors() .Options;
public BloggingContext(CosmosTestStore testStore) { _connectionString = testStore.ConnectionString; _name = testStore.Name; }
public override TestStore GetOrCreate(string storeName) => CosmosTestStore.GetOrCreate(Name, "Northwind.json");
public ValueTask <bool> IsMetAsync() => CosmosTestStore.IsConnectionAvailableAsync();