public void CtorShouldSucceed() { // Arrange var connectionString = "connectionStringValue"; // Act IPersistenceConfiguration result = new PersistenceConfiguration(connectionString); // Assert result.ConnectionString.Should().Be(connectionString); result.Database.Should().Be("Brix-EccSetup"); }
public SqlQueries(PersistenceConfiguration configuration) { AddBook = CreateInsertQueryForEntity <BookEntity>(configuration.BookTable); IsAnyNotFilled = $"SELECT EXISTS(SELECT 1 FROM `{configuration.BookTable}` WHERE `Filled` = 0 LIMIT 1);"; GetRandomNotFilledBook = $"SELECT * FROM `{configuration.BookTable}` WHERE `Filled` = 0 ORDER BY RANDOM() LIMIT 1;"; UpdateBook = CreateUpdateQueryForEntity <BookEntity>(configuration.BookTable); AddProperty = CreateInsertQueryForEntity <PropertyNumberEntity>(configuration.PropertyTable); }
public void CtorShouldSucceed() { //Arrange var persistenceConfiguration = new PersistenceConfiguration("mongodb://*****:*****@localhost:10255/admin?ssl=true"); var dataContext = new Mock <DataContext>(persistenceConfiguration).Object; // Act Action ctor = () => { new DamageCodeReadRepository(dataContext); }; // Assert ctor.Should().NotThrow(); }
public void CtorShouldFailWhenModelConverterNull() { // Arrange var persistenceConfiguration = new PersistenceConfiguration("mongodb://*****:*****@localhost:10255/admin?ssl=true"); IPersistenceContext persistenceContext = new PersistenceContext(persistenceConfiguration); IModelConverter modelConverter = null; // Act Action ctor = () => { new WorkOrderWriteRepository(persistenceContext, modelConverter); }; // Assert ctor.Should().Throw <ArgumentNullException>(); }
public void CtorShouldSucceed() { #if DEBUG // Arrange var persistenceConfiguration = new PersistenceConfiguration("mongodb://*****:*****@localhost:10255/admin?ssl=true"); IPersistenceContext persistenceContext = new PersistenceContext(persistenceConfiguration); // Act Action ctor = () => { new OperatorReadRepository(persistenceContext); }; // Assert ctor.Should().NotThrow(); #endif }
public void CtorShouldSucceed() { #if DEBUG // Arrange var persistenceConfiguration = new PersistenceConfiguration("mongodb://*****:*****@localhost:10255/admin?ssl=true"); IPersistenceContext persistenceContext = new PersistenceContext(persistenceConfiguration); IOdataProvider odataProvider = new Mock <IOdataProvider>().Object; IModelConverter modelConverter = new Mock <IModelConverter>().Object; // Act Action ctor = () => { new WorkOrderReadRepository(persistenceContext, odataProvider, modelConverter); }; // Assert ctor.Should().NotThrow(); #endif }
private static void ConfigurarStringConexao <TThisConfiguration, TConnectionString>( this FluentConfiguration configFluente, PersistenceConfiguration <TThisConfiguration, TConnectionString> persistenceConfiguration, bool showSql) where TThisConfiguration : PersistenceConfiguration <TThisConfiguration, TConnectionString> where TConnectionString : ConnectionStringBuilder, new() { const string connectionStringKey = "ExemploConexao"; if (showSql) { persistenceConfiguration.ShowSql(); } persistenceConfiguration.ConnectionString(c => c.FromConnectionStringWithKey(connectionStringKey)); configFluente.Database(persistenceConfiguration); }
public BaseMongoRepository(IMongoClient mongoClient, IOptions <PersistenceConfiguration> config) { _mongoClient = mongoClient; _config = config.Value; // Connect to database --> Find database by name or create if none exists Database = _mongoClient.GetDatabase(_config.DefaultDatabaseName); // Search for collection of type TEntity, if none exists create an empty collection if (!CollectionExists(Database, CollectionName)) { Database.CreateCollection(CollectionName); } ApplyConventions(); }
public void Initialized_Sqlite_Data_Is_Persistent() { var repository = LogManager.GetRepository(Assembly.GetEntryAssembly()); log4net.Config.BasicConfigurator.Configure(repository); var config = new PersistenceConfiguration(StorageEngine.Sqlite) { ConnectionString = $"Data Source={nameof(this.Initialized_Sqlite_Data_Is_Persistent)}.db;", SchemaOperation = SchemaOperation.Recreate, }; this.ValidatePersistenceCache(new PersistenceContextProvider(config)); config.SchemaOperation = SchemaOperation.None; this.ValidateEagerLoadingWithColdCache(new PersistenceContextProvider(config)); }
public void CtorShouldSucceed() { //Arrange var config = new MapperConfiguration(cfg => { cfg.AddProfile <DomainToClassProfile>(); cfg.AddProfile <ClassToDomainProfile>(); }); var mapper = new Mapper(config); var persistenceConfiguration = new PersistenceConfiguration("mongodb://*****:*****@localhost:10255/admin?ssl=true"); var dataContext = new Mock <DataContext>(persistenceConfiguration).Object; // Act Action ctor = () => { new LocationWriteRepository(dataContext, mapper); }; // Assert ctor.Should().NotThrow(); }
protected NHibernateDataContext(PersistenceConfiguration <TThisConfiguration, TConnectionString> configuration, string prefix = null, string nameOrConnectionString = null, string assemblyNameOrLocation = null, Assembly configurationAssembly = null) { _configuration = configuration; _prefix = prefix; _nameOrConnectionString = nameOrConnectionString; _configurationAssembly = configurationAssembly; if (configurationAssembly == null) { _assemblyNameOrLocation = assemblyNameOrLocation; } _connectionString = GetConnectionString(); _session = (ISession)DataContextCache.Current.Get(_connectionString); }
/// <summary>The server entry point.</summary> public static void Main() { ConfigureLogging(); using (var persistenceContextProvider = new PersistenceContextProvider(PersistenceConfiguration.InMemory())) { var initializer = new PersistenceInitializer(persistenceContextProvider); Logger.Info("Creating configuration & test data"); initializer.CreateConfiguration(); initializer.CreateTestData(); using (var connectServer = CreateConnectServer()) using (var loginServer = CreateLoginServer(persistenceContextProvider)) using (var gameServer = CreateGameServer(persistenceContextProvider, connectServer, loginServer)) using (BeginServerStart(connectServer)) using (BeginServerStart(loginServer)) using (BeginServerStart(gameServer)) { Task.WaitAny(gameServer.ShutdownTask, connectServer.ShutdownTask, InterruptSignal()); } } }
/// <inheritdoc /> public async Task SaveAsync(NetworkEntityGuid guid) { //We can only handle players at the moment, not sure how NPC data would be saved. if (guid.EntityType != EntityType.Player) { return; } //Player ALWAYS has this existing. EntitySaveableConfiguration saveConfig = PersistenceConfiguration.RetrieveEntity(guid); EntityFieldDataCollection entityData = EntityDataMappable.RetrieveEntity(guid); await ZonePersistenceQueueable.SaveFullCharacterDataAsync(guid.EntityId, new FullCharacterDataSaveRequest(true, saveConfig.isCurrentPositionSaveable, CreatedLocationSaveData(guid), entityData)); //We cleanup player data on the zoneserver in a different place //here, because we needed it until this very last moment. foreach (var ed in DataCollections) { ed.RemoveEntityEntry(guid); } }
private static async Task Main(string[] args) { _logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.Console() .CreateLogger() .ForContext <Program>(); var dbConfiguration = new PersistenceConfiguration() { BookTable = "Book", PropertyTable = "Property" }; var dbManager = new DbManager(dbConfiguration); ShowAvailableDatabasesInfo(dbManager); var input = ReadProgramInput(args); var inputLines = input.ToString().Split(Environment.NewLine); foreach (var inputLine in inputLines) { _logger.Information(inputLine); } await using var connection = dbManager.Exists(input.DatabaseFile) ? await dbManager.Connect(input.DatabaseFile) : await dbManager.Create(input.DatabaseFile); var repository = new BooksRepository(connection); await SeedDatabaseIfNeed(repository, input); var explorer = CreateExplorer(input, repository); await explorer.Explore(CancellationToken.None); }
public static IContext CreateContext() { // The only reason for all this code is to relate the XML persistence location // to the web root, which is not the same as the current directory. PersistenceConfiguration persistenceConfiguration = PersistenceConfigurationHelper.GetPersistenceConfiguration(); string location = persistenceConfiguration.Location; bool isXmlContext = persistenceConfiguration.ContextType == "Xml"; if (isXmlContext) { location = HostingEnvironment.MapPath("~/" + location); } IContext context = ContextFactory.CreateContext( persistenceConfiguration.ContextType, location, persistenceConfiguration.ModelAssembly, persistenceConfiguration.MappingAssembly, persistenceConfiguration.Dialect); return(context); }
/// <summary> /// Creates the SQL configuration. /// </summary> /// <typeparam name="TThisConfiguration">The type of the configuration.</typeparam> /// <typeparam name="TConnectionString">The type of connection string.</typeparam> /// <param name="provider">The SQL configuration provider.</param> /// <returns>Created SQL configuration</returns> private IPersistenceConfigurer CreateSqlConfiguration <TThisConfiguration, TConnectionString>(PersistenceConfiguration <TThisConfiguration, TConnectionString> provider) where TThisConfiguration : PersistenceConfiguration <TThisConfiguration, TConnectionString> where TConnectionString : ConnectionStringBuilder, new() { PersistenceConfiguration <TThisConfiguration, TConnectionString> sqlConfiguration; if (!string.IsNullOrEmpty(configuration.Database.ConnectionString)) { sqlConfiguration = provider.ConnectionString(configuration.Database.ConnectionString); } else if (!string.IsNullOrEmpty(configuration.Database.ConnectionStringName)) { sqlConfiguration = provider.ConnectionString(f => f.FromConnectionStringWithKey(configuration.Database.ConnectionStringName)); } else { sqlConfiguration = null; } if (sqlConfiguration != null) { if (!string.IsNullOrEmpty(configuration.Database.SchemaName)) { sqlConfiguration.DefaultSchema(configuration.Database.SchemaName); } } return(sqlConfiguration); }
public DbManager(PersistenceConfiguration persistenceConfiguration) { _persistenceConfiguration = persistenceConfiguration; }
public void Initialized_In_Memory_Data_Is_Persistent() { var config = PersistenceConfiguration.InMemory(); this.ValidatePersistenceCache(new PersistenceContextProvider(config)); }
public SQLiteDbAccess(string databaseFile, PersistenceConfiguration persistenceConfiguration) { Db = new SQLiteConnection("Data Source=" + databaseFile); Queries = new SqlQueries(persistenceConfiguration); }
/// <summary> /// Initializes a new instance of the <see cref="FactoryContext"/> class. /// </summary> /// <param name="configuration"> /// The persistence configuration. /// </param> /// <param name="context"> /// The database context. /// </param> /// <param name="disposeContext"> /// Flag indicating whether this factory context owns the database context. /// </param> /// <exception cref="ArgumentNullException"> /// If <paramref name="configuration"/> is null. /// </exception> /// <exception cref="ArgumentNullException"> /// If <paramref name="context"/> is null. /// </exception> internal FactoryContext(PersistenceConfiguration configuration, IContext context, bool disposeContext) { if (configuration == null) { throw new ArgumentNullException("configuration"); } if (context == null) { throw new ArgumentNullException("context"); } this.configuration = configuration; this.context = context; this.disposeContext = disposeContext; this.client = context.CreateClient(); }
public static IContext CreateContext() { PersistenceConfiguration persistenceConfiguration = PersistenceConfigurationHelper.GetPersistenceConfiguration(); return(ContextFactory.CreateContextFromConfiguration()); }