public void CanPopulateMultivalueSnapshots()
        {
            string query = "testQuery";

            var context = MockRepository.GenerateMock<DataContextWrapper>();
            context.Expect(c => c.ExecuteQuery<TimeseriesPoint>(query)).Return(new [] { new TimeseriesPoint { Value1 = 1, Value2 = 2 } });

            var source = new SqlServerDataSource("id", "name", context, query);

            var result = source.Snapshot();

            Assert.AreEqual(1, result.Count);
            Assert.AreEqual(5, result[0].Data.Count);
            Assert.AreEqual(1, result[0].Data[0]);
        }
        internal void Initialize(ref string scenario, ref DataSource source)
        {
            // Ignore all asserts from known issues
            var defaultTraceListener = Trace.Listeners["Default"] as DefaultTraceListener;
            if (defaultTraceListener != null)
            {
                var newTraceListener = new FilteredDefaultTraceListener(defaultTraceListener);
                Trace.Listeners.Remove(defaultTraceListener);
                Trace.Listeners.Add(newTraceListener);
            }

            // scenario <=> SqlClientScenario
            if (string.IsNullOrEmpty(scenario))
            {
                _scenario = SqlClientScenario.Sql;
            }
            else
            {
                _scenario = (SqlClientScenario)Enum.Parse(typeof(SqlClientScenario), scenario, true);
            }
            scenario = _scenario.ToString();

            // initialize the source information
            // SNAC/WDAC is using SqlServer sources; JET is using Access
            switch (_scenario)
            {
                case SqlClientScenario.Sql:
                    if (source == null)
                        source = DataStressSettings.Instance.GetDefaultSourceByType(DataSourceType.SqlServer);
                    else if (source.Type != DataSourceType.SqlServer)
                        throw new ArgumentException(string.Format("Given source type is wrong: required {0}, received {1}", DataSourceType.SqlServer, source.Type));
                    break;

                default:
                    throw new ArgumentException("Wrong scenario \"" + scenario + "\"");
            }

            _source = (SqlServerDataSource)source;

            // Only try to add Multisubnet Failover host entries when the settings allow it in the source.
            if (!_source.DisableMultiSubnetFailoverSetup)
            {
                _multiSubnetSetupHelper = new MultiSubnetFailoverSetup(_source);
                _multiSubnetSetupHelper.InitializeFakeHostsForMultiSubnetFailover();
            }
        }
        // Very much not a unit test: todo, mock out the datacontext
        public void SqlServerDataSource_QueriesADatabase()
        {
            var query = "testQuery";

            var context = MockRepository.GenerateMock<DataContextWrapper>();
            context.Expect(c => c.ExecuteQuery<TimeseriesPoint>(query)).Return(new[]
                {
                    new TimeseriesPoint { Value1 = 1, Value2 = 2 },
                    new TimeseriesPoint { Value1 = 1, Value2 = 2 },
                    new TimeseriesPoint { Value1 = 1, Value2 = 2 },
                    new TimeseriesPoint { Value1 = 1, Value2 = 2 },
                    new TimeseriesPoint { Value1 = 1, Value2 = 2 },
                    new TimeseriesPoint { Value1 = 1, Value2 = 2 },
                    new TimeseriesPoint { Value1 = 1, Value2 = 2 },
                    new TimeseriesPoint { Value1 = 1, Value2 = 2 }
                });

            var source = new SqlServerDataSource("id", "name", context, query);

            var timeseries = source.Snapshot();

            Assert.AreEqual(8, timeseries.Count());
        }        
 public BasicStoredProcScenario(SqlServerDataSource dataSource)
 {
     m_DataSource = dataSource;
 }
 public AuditTrailController(ILoggerFactory loggerFactory, SqlServerDataSource sqlServerDataSource,
                             IOptions <WebApiConfiguration> options, ICurrentUserRetriever currentUserRetriever) : base(loggerFactory, sqlServerDataSource, options, currentUserRetriever)
 {
 }
 public ModelWithLookupSimpleScenario(SqlServerDataSource dataSource)
 {
     m_DataSource = dataSource;
 }
 public PlayService(SqlServerDataSource dataSource) : base(dataSource)
 {
 }
Exemple #8
0
 public MultipleCrudScenario(SqlServerDataSource dataSource)
 {
     m_DataSource = dataSource;
 }
 public ResourcePermissionHandler(IHttpContextAccessor httpContextAccessor, ILoggerFactory loggerFactory, IOptions <WebApiConfiguration> options, ICurrentUserRetriever currentUserRetriever, SqlServerDataSource dataSource)
 {
     _httpContext          = httpContextAccessor.HttpContext;
     _logger               = loggerFactory?.CreateLogger <ResourcePermissionHandler>();
     _configuration        = options?.Value;
     _currentUserRetriever = currentUserRetriever;
     _dataSource           = dataSource;
 }
Exemple #10
0
 public CurrentUserRetriever(ILogger <CurrentUserRetriever> logger, IHttpContextAccessor httpContextAccessor, SqlServerDataSource dataSource)
 {
     _cachedUserLock = new object();
     _logger         = logger;
     _httpContext    = httpContextAccessor?.HttpContext;
     _dataSource     = dataSource;
 }
 public ProductCharacteristicController(ILoggerFactory loggerFactory, SqlServerDataSource sqlServerDataSource,
                                        IOptions <WebApiConfiguration> options, ICurrentUserRetriever currentUserRetriever) : base(loggerFactory, sqlServerDataSource, options, currentUserRetriever)
 {
 }
Exemple #12
0
 public SingleModelCrudAsyncCompiledScenario(SqlServerDataSource dataSource)
 {
     m_DataSource = dataSource ??
                    throw new ArgumentNullException(nameof(dataSource), $"{nameof(dataSource)} is null.");
 }
 public DepartmentWithChildRepository(SqlServerDataSource dataSource)
 {
     m_DataSource = dataSource;
 }
Exemple #14
0
 public PaginationScenario(SqlServerDataSource dataSource)
 {
     m_DataSource = dataSource;
 }
 public TryCrudScenario(SqlServerDataSource dataSource)
 {
     m_DataSource = dataSource;
 }
 public SectionService(SqlServerDataSource dataSource) : base(dataSource)
 {
 }
        public void SqlServerDataSourceTests_CreateFromConfig()
        {
            var dataSource = SqlServerDataSource.CreateFromConfig("SqlServerTestDatabase");

            dataSource.TestConnection();
        }
Exemple #18
0
 public DynamicSortingScenario(SqlServerDataSource dataSource)
 {
     m_DataSource = dataSource;
 }
Exemple #19
0
 public ViewsScenario(SqlServerDataSource dataSource)
 {
     m_DataSource = dataSource;
 }
 public LargeBatchScenario(SqlServerDataSource dataSource)
 {
     m_DataSource = dataSource;
 }
Exemple #21
0
 static DapperReadmeVsChain()
 {
     //This would be handled by your Dependency Injection framework
     s_ConnectionString = ConfigurationManager.ConnectionStrings["CodeFirstModels"].ConnectionString;
     s_DataSource       = SqlServerDataSource.CreateFromConfig("CodeFirstModels");
 }
 public ModelWithChildrenScenario(SqlServerDataSource dataSource)
 {
     m_DataSource = dataSource;
 }
 public SingleColumnScenario(SqlServerDataSource dataSource)
 {
     m_DataSource = dataSource;
 }
Exemple #24
0
 public VideoService(SqlServerDataSource dataSource) : base(dataSource)
 {
 }
Exemple #25
0
 public DiscoverTablesAndColumnsScenario(SqlServerDataSource dataSource)
 {
     m_DataSource = dataSource;
 }
Exemple #26
0
 protected ServiceBase(SqlServerDataSource dataSource)
 {
     m_DataSource = dataSource ?? throw new ArgumentNullException(nameof(dataSource));
 }
 internal MultiSubnetFailoverSetup(SqlServerDataSource source)
 {
     this.Source = source;
 }
 public ImageService(SqlServerDataSource dataSource, IOptions <BlobStorageOptions> settings) : base(dataSource)
 {
     Settings = settings.Value;
 }
Exemple #29
0
 public EmployeeRepositoryChain(SqlServerDataSource dataSource)
 {
     m_DataSource = dataSource;
 }
Exemple #30
0
 public TransactionsScenario(SqlServerDataSource dataSource)
 {
     m_DataSource = dataSource;
 }
 internal MultiSubnetFailoverSetup(SqlServerDataSource source)
 {
     this.Source = source;
 }
 public BookService(SqlServerDataSource dataSource) : base(dataSource)
 {
 }
 public BulkInsertScenario(SqlServerDataSource dataSource)
 {
     m_DataSource = dataSource;
 }
 public StatusController(ILoggerFactory loggerFactory, SqlServerDataSource sqlServerDataSource,
                         IOptions <WebApiConfiguration> options, ICurrentUserRetriever currentUserRetriever)
     : base(loggerFactory, sqlServerDataSource, options, currentUserRetriever)
 {
     _appInsightsConfiguration = options?.Value.AppInsightsConfiguration;
 }