Exemplo n.º 1
0
        public async Task UpgradeGeneratorsFirebirdAsyncTest()
        {
            Require.ProviderIs(StorageProvider.Firebird);

            var generatorCacheSize = 3;

            await BuildDomainAsync("1", DomainUpgradeMode.Recreate, generatorCacheSize, typeof(Address), typeof(Person));

            using (var session = domain.OpenSession())
                using (var t = session.OpenTransaction()) {
                    for (var i = 0; i < generatorCacheSize; i++)
                    {
                        _ = new Person {
                            Address = new Address {
                                City = "City", Country = "Country"
                            }
                        };
                    }

                    Assert.LessOrEqual(session.Query.All <Person>().Max(p => p.Id), 4);
                    Assert.GreaterOrEqual(session.Query.All <Person>().Max(p => p.Id), 3);
                    t.Complete();
                }

            await BuildDomainAsync("1", DomainUpgradeMode.Perform, generatorCacheSize, typeof(Address), typeof(Person));

            using (var session = domain.OpenSession())
                using (var t = session.OpenTransaction()) {
                    for (var i = 0; i < generatorCacheSize; i++)
                    {
                        _ = new Person {
                            Address = new Address {
                                City = "City", Country = "Country"
                            }
                        };
                    }

                    Assert.LessOrEqual(session.Query.All <Person>().Max(p => p.Id), 8);
                    Assert.GreaterOrEqual(session.Query.All <Person>().Max(p => p.Id), 6);
                    t.Complete();
                }

            generatorCacheSize = 2;// ignored because Firebird sequences has no increment support
            await BuildDomainAsync("1", DomainUpgradeMode.Perform, generatorCacheSize, typeof(Address), typeof(Person));

            using (var session = domain.OpenSession())
                using (var t = session.OpenTransaction()) {
                    _ = new Person {
                        Address = new Address {
                            City = "City", Country = "Country"
                        }
                    };
                    _ = new Person {
                        Address = new Address {
                            City = "City", Country = "Country"
                        }
                    };
                    _ = new Person {
                        Address = new Address {
                            City = "City", Country = "Country"
                        }
                    };
                    Assert.LessOrEqual(session.Query.All <Person>().Max(p => p.Id), 10);
                    Assert.GreaterOrEqual(session.Query.All <Person>().Max(p => p.Id), 9);
                    t.Complete();
                }
        }
Exemplo n.º 2
0
        public async Task UpgradeGeneratorsAsyncTest()
        {
            Require.ProviderIsNot(StorageProvider.Firebird);
            Require.AnyFeatureSupported(ProviderFeatures.Sequences | ProviderFeatures.ArbitraryIdentityIncrement);

            var generatorCacheSize = 3;

            await BuildDomainAsync("1", DomainUpgradeMode.Recreate, generatorCacheSize, typeof(Address), typeof(Person));

            using (var session = domain.OpenSession())
                using (var t = session.OpenTransaction()) {
                    for (var i = 0; i < generatorCacheSize; i++)
                    {
                        _ = new Person {
                            Address = new Address {
                                City = "City", Country = "Country"
                            }
                        };
                    }
                    Assert.LessOrEqual(session.Query.All <Person>().Max(p => p.Id), 4);
                    Assert.GreaterOrEqual(session.Query.All <Person>().Max(p => p.Id), 3);
                    t.Complete();
                }

            await BuildDomainAsync("1", DomainUpgradeMode.Perform, generatorCacheSize, typeof(Address), typeof(Person));

            using (var session = domain.OpenSession())
                using (var t = session.OpenTransaction()) {
                    for (int i = 0; i < generatorCacheSize; i++)
                    {
                        _ = new Person {
                            Address = new Address {
                                City = "City", Country = "Country"
                            }
                        };
                    }

                    Assert.LessOrEqual(session.Query.All <Person>().Max(p => p.Id), 8);
                    Assert.GreaterOrEqual(session.Query.All <Person>().Max(p => p.Id), 6);
                    t.Complete();
                }

            generatorCacheSize = 2;
            await BuildDomainAsync("1", DomainUpgradeMode.Perform, generatorCacheSize, typeof(Address), typeof(Person));

            using (var session = domain.OpenSession())
                using (var t = session.OpenTransaction()) {
                    _ = new Person {
                        Address = new Address {
                            City = "City", Country = "Country"
                        }
                    };
                    _ = new Person {
                        Address = new Address {
                            City = "City", Country = "Country"
                        }
                    };
                    _ = new Person {
                        Address = new Address {
                            City = "City", Country = "Country"
                        }
                    };
                    Assert.LessOrEqual(session.Query.All <Person>().Max(p => p.Id), 13);
                    Assert.GreaterOrEqual(session.Query.All <Person>().Max(p => p.Id), 12);
                    t.Complete();
                }
        }