public List <string> PostgreSQLtest1() { try { _conf = TestsConfiguration.Instance; string connstring = _conf.Connstring; NpgsqlConnection connection = new NpgsqlConnection(connstring); connection.Open(); NpgsqlCommand command = new NpgsqlCommand("SELECT * FROM login", connection); NpgsqlDataReader dataReader = command.ExecuteReader(); for (int i = 0; dataReader.Read(); i++) { dataItems.Add(/*dataReader[0].ToString() + "," +*/ dataReader[1].ToString() + "," + dataReader[2].ToString() + "\r\n"); PropertiesCollection._reportingTasks.Log(Status.Info, "<b>" + "This data from DB Postgres " + "</b>" + dataItems[i]); } connection.Close(); return(dataItems); } catch (Exception msg) { Console.WriteLine(msg.ToString()); PropertiesCollection._reportingTasks.Log(Status.Error, msg.ToString()); throw; } }
public void PostgreTestInsert() { _conf = TestsConfiguration.Instance; string pth = System.Reflection.Assembly.GetCallingAssembly().CodeBase; string actualPath = pth.Substring(0, pth.IndexOf("bin")); string projectPth = new Uri(actualPath).LocalPath; try { string connstring = _conf.Connstring; NpgsqlConnection connection = new NpgsqlConnection(connstring); FileInfo file = new FileInfo(projectPth + @"DB connectors\InsertLoginTable.sql"); string script = file.OpenText().ReadToEnd(); connection.Open(); NpgsqlCommand cmd = new NpgsqlCommand(script, connection); cmd.ExecuteNonQuery(); connection.Close(); } catch (Exception msg1) { Console.WriteLine(msg1.ToString()); PropertiesCollection._reportingTasks.Log(Status.Error, msg1.ToString()); throw; } }
public bool StartCreation(DbSample sample) { var creationScript = new CreationScript(TestsConfiguration.MakeSQLScriptPath(sample.SqlFile), sample.TypedVersion); var createModel = new MySqlDbCreateModel(this, creationScript); return(createModel.RunCreation(server.AddressAndPort, sample.DbName, server.Login, server.Password)); }
protected void StartReport() { _config = TestsConfiguration.Instance; ExtentReports extentReports = ReportingManager.Instance; _reportingTasks = new ReportingTasks(extentReports); }
public UniqueConstraintServiceTests() { var cfg = new TestsConfiguration(); var account = CloudStorageAccount.Parse(cfg.StorageAccount.ConnectionString); uniqueConstraintService = new UniqueConstraintService(account); var client = account.CreateCloudTableClient(); table = client.GetTableReference(typeof(UniqueConstraintService).Name); }
public static TestsConfiguration getTestConfiguration() { var configuration = new TestsConfiguration(); var iConfiguration = getConfiguration(); iConfiguration .GetSection("ConnectionStrings:TestsDBConnectionString") .Bind(configuration); return(configuration); }
public StorageAccountFixture() { Configuration = new TestsConfiguration(); ExecutionContext = new TestsExecutionContext(); var storageAccount = CloudStorageAccount .Parse(Configuration.StorageAccount.ConnectionString); this.tableClient = storageAccount.CreateCloudTableClient(); this.blobClient = new BlobServiceClient(Configuration.StorageAccount.ConnectionString); }
public async Task SetUpContainer() { var config = new TestsConfiguration(); Builder = new ContainerBuilder(); Builder.RegisterType <TestsConfiguration>().SingleInstance(); EndpointConfiguration = new EndpointConfiguration(config.AcceptanceTestsEndpointName); EndpointConfiguration.SendFailedMessagesTo(config.AcceptanceTestsEndpointName + "-errors"); EndpointConfiguration.UseSerialization <NewtonsoftSerializer>(); EndpointConfiguration.EnableInstallers(); Builder.RegisterInstance(EndpointConfiguration) .SingleInstance(); var conventions = EndpointConfiguration.Conventions(); conventions.DefiningMessagesAs(type => type.IsMessage()); conventions.DefiningEventsAs(type => type.IsEvent <IPaymentsEvent>()); conventions.DefiningCommandsAs(type => type.IsCommand <PaymentsCommand>()); var persistence = EndpointConfiguration.UsePersistence <AzureStoragePersistence>(); persistence.ConnectionString(config.StorageConnectionString); EndpointConfiguration.DisableFeature <TimeoutManager>(); var transport = EndpointConfiguration.UseTransport <AzureServiceBusTransport>(); transport.UseForwardingTopology(); transport .ConnectionString(config.GetConnectionString("ServiceBusConnectionString")) .Transactions(TransportTransactionMode.ReceiveOnly); transport.Routing().RouteToEndpoint(typeof(PeriodEndRequestReportsEvent).Assembly, "sfa-das-payments-monitoring-metrics-periodend"); EndpointConfiguration.SendOnly(); var dbContextOptions = new DbContextOptionsBuilder().UseSqlServer( config.PaymentsConnectionString, optionsBuilder => optionsBuilder.CommandTimeout(270)).Options; Builder.Register(c => new JobsDataContext(config.PaymentsConnectionString)) .InstancePerDependency(); Builder.Register(c => new DcMetricsDataContext(dbContextOptions)) .InstancePerDependency(); Builder.Register(c => new MetricsPersistenceDataContext(dbContextOptions)) .InstancePerDependency(); Container = Builder.Build(); EndpointConfiguration.UseContainer <AutofacBuilder>(c => c.ExistingLifetimeScope(Container)); MessageSession = await Endpoint.Start(EndpointConfiguration); }
/// <summary> /// Initializes a new instance of the <see cref="BaseTest"/> class. /// </summary> public BaseTest() { JsonConvert.DefaultSettings = CqrsSettings.JsonConfig; BusMock = new Mock <IEventBus>(); var cfg = new TestsConfiguration(); Store = new AzureTableEventStore(cfg.StorageAccount.ConnectionString); var account = CloudStorageAccount.Parse(cfg.StorageAccount.ConnectionString); var tableClient = account.CreateCloudTableClient(); AggregateTable = tableClient.GetTableReference("AggregateStore"); EventTable = tableClient.GetTableReference(nameof(EventStore)); }
public int ConnectToDbTest() { /* if we have more than 1 column * List<string> dataFromDb = new List<string>();*/ string dataFromDb = ""; _conf = TestsConfiguration.Instance; string pth = System.Reflection.Assembly.GetCallingAssembly().CodeBase; string actualPath = pth.Substring(0, pth.IndexOf("bin")); string projectPth = new Uri(actualPath).LocalPath; FileInfo file = new FileInfo(projectPth + @"DBcon\myQuery.sql"); string script = file.OpenText().ReadToEnd(); try { _conf = TestsConfiguration.Instance; string connstring = _conf.Connstring; using (SqlConnection connection = new SqlConnection(connstring)) { connection.Open(); SqlCommand command = new SqlCommand(script, connection); SqlDataReader dataReader = command.ExecuteReader(); while (dataReader.Read()) { //dataFromDb.Add(dataReader[0].ToString() + " " + dataReader[1].ToString() + " " + dataReader[2].ToString() + " "); dataFromDb = dataReader[0].ToString(); } PropertiesCollection._reportingTasks.Log(Status.Info, "<b>" + "There are records in the table : " + dataFromDb + "<br>"); connection.Close(); int counts = Int32.Parse(dataFromDb); return(counts); } } catch (Exception msg) { Console.WriteLine(msg.ToString()); PropertiesCollection._reportingTasks.Log(Status.Error, msg.ToString()); throw; } }
public TestConfigurationHelper(TestsConfiguration config) { this.config = config ?? throw new ArgumentNullException(nameof(config)); }
public async Task SetUpContainer() { var config = new TestsConfiguration(); Builder = new ContainerBuilder(); Builder.RegisterType <TestsConfiguration>().SingleInstance(); Builder.RegisterType <DcHelper>().SingleInstance(); EndpointConfiguration = new EndpointConfiguration(config.AcceptanceTestsEndpointName); Builder.RegisterInstance(EndpointConfiguration) .SingleInstance(); var conventions = EndpointConfiguration.Conventions(); conventions.DefiningMessagesAs(type => type.IsMessage()); conventions.DefiningEventsAs(type => type.IsEvent <IPaymentsEvent>()); conventions.DefiningCommandsAs(type => type.IsCommand <PaymentsCommand>()); EndpointConfiguration.UsePersistence <AzureStoragePersistence>() .ConnectionString(config.StorageConnectionString); EndpointConfiguration.DisableFeature <TimeoutManager>(); var transportConfig = EndpointConfiguration.UseTransport <AzureServiceBusTransport>(); Builder.RegisterInstance(transportConfig) .As <TransportExtensions <AzureServiceBusTransport> >() .SingleInstance(); transportConfig .UseForwardingTopology() .ConnectionString(config.ServiceBusConnectionString) .Transactions(TransportTransactionMode.ReceiveOnly); var routing = transportConfig.Routing(); routing.RouteToEndpoint(typeof(ProcessLearnerCommand), EndpointNames.EarningEvents); routing.RouteToEndpoint(typeof(ProcessProviderMonthEndCommand), EndpointNames.ProviderPayments); routing.RouteToEndpoint(typeof(RecordEarningsJob), EndpointNames.JobMonitoring); routing.RouteToEndpoint(typeof(ProcessLevyPaymentsOnMonthEndCommand).Assembly, EndpointNames.FundingSource); routing.RouteToEndpoint(typeof(ResetActorsCommand).Assembly, EndpointNames.DataLocks); var sanitization = transportConfig.Sanitization(); var strategy = sanitization.UseStrategy <ValidateAndHashIfNeeded>(); strategy.RuleNameSanitization( ruleNameSanitizer: ruleName => ruleName.Split('.').LastOrDefault() ?? ruleName); EndpointConfiguration.UseSerialization <NewtonsoftSerializer>(); EndpointConfiguration.EnableInstallers(); Builder.RegisterType <EarningsJobClient>() .As <IEarningsJobClient>() .SingleInstance(); Builder.RegisterType <EarningsJobClientFactory>() .As <IEarningsJobClientFactory>() .SingleInstance(); Builder.Register((c, p) => { var configHelper = c.Resolve <TestsConfiguration>(); return(new TestPaymentsDataContext(configHelper.PaymentsConnectionString)); }).As <IPaymentsDataContext>().AsSelf().InstancePerDependency(); Builder.Register((c, p) => { var configHelper = c.Resolve <TestsConfiguration>(); return(new JobsDataContext(configHelper.PaymentsConnectionString)); }).InstancePerDependency(); DcHelper.AddDcConfig(Builder); Builder.RegisterType <EndpointInstanceFactory>() .As <IEndpointInstanceFactory>() .SingleInstance(); Container = Builder.Build(); EndpointConfiguration.UseContainer <AutofacBuilder>(c => c.ExistingLifetimeScope(Container)); MessageSession = await Container.Resolve <IEndpointInstanceFactory>().GetEndpointInstance().ConfigureAwait(false);// await Endpoint.Start(EndpointConfiguration); LearnerStartTimes = new Dictionary <string, DateTime>(); }