コード例 #1
0
        public MongoApmTests(MongoFixture <MongoConfiguration, BsonDocument> fixture)
        {
            _documents     = fixture.Collection ?? throw new ArgumentNullException(nameof(fixture.Collection));
            _payloadSender = new MockPayloadSender();

            var configurationReaderMock = new Mock <IConfigurationReader>();

            configurationReaderMock.Setup(x => x.TransactionSampleRate)
            .Returns(() => 1.0);
            configurationReaderMock.Setup(x => x.TransactionMaxSpans)
            .Returns(() => 50);
            configurationReaderMock.Setup(x => x.Enabled)
            .Returns(() => true);
            configurationReaderMock.Setup(x => x.Recording)
            .Returns(() => true);

            var config = new AgentComponents(configurationReader: configurationReaderMock.Object,
                                             payloadSender: _payloadSender);

            var apmAgentType = typeof(IApmAgent).Assembly.GetType("Elastic.Apm.ApmAgent");

            if (apmAgentType == null)
            {
                throw new InvalidOperationException("Cannot get `Elastic.Apm.ApmAgent` type with reflection");
            }

            _agent = (IApmAgent)apmAgentType.GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance).First()
                     .Invoke(new object[] { config });
            _agent.Subscribe(new MongoDiagnosticsSubscriber());
        }
コード例 #2
0
        public MongoApmTests(MongoFixture <MongoConfiguration, BsonDocument> fixture)
        {
            _documents     = fixture.Collection ?? throw new ArgumentNullException(nameof(fixture.Collection));
            _payloadSender = new MockPayloadSender();

            var config = new TestAgentComponents(configuration:
                                                 new MockConfiguration(transactionSampleRate: "1.0", transactionMaxSpans: "50"),
                                                 payloadSender: _payloadSender);

            _agent = new ApmAgent(config);
            _agent.Subscribe(new MongoDbDiagnosticsSubscriber());
        }
コード例 #3
0
        protected override void ConfigureWebHost(IWebHostBuilder builder)
        {
            mongoFixture = new MongoFixture();
            mongoFixture.InitializeAsync().Wait();

            builder.ConfigureServices(services =>
            {
                services.AddSingleton(mongoFixture);

                ReplaceMongo(services);

                var sp = services.BuildServiceProvider();

                using (var scope = sp.CreateScope())
                {
                    var scopedServices = scope.ServiceProvider;
                    var logger         = scopedServices
                                         .GetRequiredService <ILogger <CustomWebApplicationFactory <TStartup> > >();
                }
            });
        }
コード例 #4
0
 public ShouldInitializeUsing(MongoFixture fixture)
 {
     _fixture = fixture;
 }
コード例 #5
0
 public StoriesModuleWebApiTests(WebApplicationFactory <Program> factory, MongoFixture mongo)
     : base(factory, mongo)
 {
     SetPath("stories-module");
 }
コード例 #6
0
 public StoryScenarioTests(WebApplicationFactory <Program> factory, MongoFixture mongo) : base(factory, mongo,
                                                                                               "test-e2e")
 {
 }
コード例 #7
0
 public ShouldCreate(MongoFixture fixture)
 {
     _fixture = fixture;
 }
コード例 #8
0
 public HomeControllerTests(WebApplicationFactory <Program> factory, MongoFixture mongo) : base(factory, mongo)
 {
 }
コード例 #9
0
 public ShoudNotCreate(MongoFixture fixture)
 {
     _fixture = fixture;
 }