Ejemplo n.º 1
0
        public void Serializable()
        {
            var serializableConfiguration = new Allors.Adapters.Object.SqlClient.Configuration
            {
                ConnectionString = ConnectionString,
                ObjectFactory    = this.ObjectFactory,
                IsolationLevel   = IsolationLevel.Serializable
            };

            var serializableDatabase = new Allors.Adapters.Object.SqlClient.Database(CreateServiceProvider(), serializableConfiguration);

            var configuration = new Allors.Adapters.Object.SqlClient.Configuration
            {
                ConnectionString = ConnectionString,
                ObjectFactory    = this.ObjectFactory,
                Serializable     = serializableDatabase
            };

            var database = new Allors.Adapters.Object.SqlClient.Database(CreateServiceProvider(), configuration);

            this.Setup(database, true);

            var id = Guid.NewGuid();

            new CounterBuilder(this.Session).WithUniqueId(id).Build();
            this.Session.Derive(true);
            this.Session.Commit();

            Assert.Equal(1, Counters.NextValue(this.Session, id));
            Assert.Equal(2, Counters.NextValue(this.Session, id));
            Assert.Equal(3, Counters.NextValue(this.Session, id));
            Assert.Equal(4, Counters.NextValue(this.Session, id));
        }
Ejemplo n.º 2
0
        protected ServerTest()
        {
            const string FileName       = @"base.appSettings.json";
            var          userSettings   = $@"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}/allors/{FileName}";
            var          systemSettings = $@"{Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)}/allors/{FileName}";

            this.Configuration = new ConfigurationBuilder()
                                 .AddJsonFile(@"appSettings.json")
                                 .AddJsonFile(systemSettings, true)
                                 .AddJsonFile(userSettings, true)
                                 .AddEnvironmentVariables()
                                 .Build();

            this.ObjectFactory = new ObjectFactory(MetaPopulation.Instance, typeof(User));
            var configuration = new Allors.Adapters.Object.SqlClient.Configuration
            {
                ObjectFactory    = this.ObjectFactory,
                ConnectionString = this.Configuration.GetConnectionString("DefaultConnection")
            };

            var services = new ServiceCollection();

            services.AddAllors();
            var serviceProvider = services.BuildServiceProvider();

            this.HttpClientHandler = new HttpClientHandler();
            this.HttpClient        = new HttpClient(this.HttpClientHandler)
            {
                BaseAddress = new Uri(Url),
            };

            this.HttpClient.DefaultRequestHeaders.Accept.Clear();
            this.HttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));


            var result   = this.HttpClient.GetAsync("Test/Setup").Result;
            var database = new Allors.Adapters.Object.SqlClient.Database(serviceProvider, configuration);

            this.Session = database.CreateSession();
        }