private DictionaryAtom ExecuteProcedure(DictionaryAtom dbCommand) { Validation.IsNotNull(dbCommand, "dbCommand"); var dbSchema = dbCommand.GetString("schema"); var dbCommandName = dbCommand.GetString("commandName"); var proc = GetProcedure(dbSchema, dbCommandName); if (proc == null) { throw new ObjectNotFoundException(string.Format(Resources.ERR_DB_PROC_NOT_FOUND, dbSchema, dbCommandName)); } var dbParameterSet = dbCommand.GetAtom <DictionaryAtom>("parameters"); var executor = new ProcedureExecutor <SqlCommand>(_connection, _log, proc); var result = executor.ExecuteQuery(dbParameterSet?.ToDictionary()); var dataTable = result.Item2.CastAs <DataTable>(); var resultSet = new DictionaryAtom(); resultSet.Set("Results", dataTable.ToListAtom()); resultSet.Set("Schema", dbSchema); resultSet.Set("CommandName", dbCommandName); dataTable.Dispose(); return(resultSet); }
public void GetValueTest() { const string key = "test"; const int value = 5000; var atom = new DictionaryAtom(); atom.Set(key, value); var actual = atom.GetAtom <IntAtom>("test"); actual.Should().NotBeNull(); actual.Value.Should().Be(value); }
/// <summary> /// Do initialization that cannot be done at construction /// </summary> public void OnInit(DictionaryAtom args) { Validation.IsNotNull(args, "args"); _connectionString = args.GetString("ConnectionString"); Validation.IsNotNullOrEmpty(_connectionString, "_connectionString"); _numberServers = args.GetInt("NumberDBServers"); Validation.Validate <ArgumentOutOfRangeException>(_numberServers >= 1); _log.DebugFormat("{0} asked to spin up {1} database servers.", GetType(), _numberServers); InitDatabaseLoaders(args); _loaderArgs = args.GetAtom <ListAtom>("Loaders"); _eventManager.RegisterListener(this, typeof(OnGameInitialize), Instance_OnGameInitialize); }
public void SetListAtom() { var listAtom = new ListAtom { "1 2 3 4 5" }; var atom = new DictionaryAtom(); atom.Set("TestList", listAtom); atom.ContainsKey("TestList").Should().BeTrue(); var foundAtom = atom.GetAtom <ListAtom>("TestList"); foundAtom.Should().NotBeNull(); foundAtom.Should().BeAssignableTo <ListAtom>(); foundAtom.GetString(0).Should().Be("1 2 3 4 5"); }
public void SetDictionaryAtom() { var setAtom = new DictionaryAtom(); setAtom.Set("Test", "1 2 3 4 5"); var atom = new DictionaryAtom(); atom.Set("TestDictionary", setAtom); atom.ContainsKey("TestDictionary").Should().BeTrue(); var foundAtom = atom.GetAtom <DictionaryAtom>("TestDictionary"); foundAtom.Should().NotBeNull(); foundAtom.Should().BeAssignableTo <DictionaryAtom>(); foundAtom.ContainsKey("Test").Should().BeTrue(); }