public async void SetupLogDocumentMultiTest() { ElasticsearchReporter r = new ElasticsearchReporter(CreateCli <ElasticsearchSetupDocument>().Object); var d = new ElasticsearchSetupDocument(); await r.Post(new ElasticsearchSetupDocument[] { d, d }.AsEnumerable(), "testindex"); // TODO: Verify result }
public async void SetupLogDocumentTest() { ElasticsearchReporter r = new ElasticsearchReporter(CreateCli <ElasticsearchSetupDocument>().Object); var d = new ElasticsearchSetupDocument(); await r.Post(d, "testindex"); // TODO: Verify result }
public async void AcessLogDocumentTest(bool IndexExists_Exists) { var cli = CreateCli <ElasticsearchAccessLogDocument>(IndexExists_Exists: IndexExists_Exists); ElasticsearchReporter r = new ElasticsearchReporter(cli.Object); var d = new ElasticsearchAccessLogDocument("mockid", appName: "mockapp", message: "mock msg", path: "mock path", controllerName: "mock_controller", actionName: "mockAction" , elapsedSeconds: 2, parameters: new Dictionary <string, string>() { { "mockparam1", "mockvalue1" } }, resultCode: 200, stat: new List <StatisticalDocument>() { new StatisticalDocument() { Call = "mockcall" , Comment = "mockcomment" , ElapsedSeconds = 5 } }, headers: new Dictionary <string, string>() { { "mockheader1", "mockheadervalue1" } }); await r.Post(d, "testindex"); cli.Verify(e => e.IndexExistsAsync(It.Is <Nest.Indices>(i => i.Match(all => false, many => many.Indices.Contains("testindex"))) , It.IsAny <Func <IndexExistsDescriptor, IIndexExistsRequest> >() , It.IsAny <CancellationToken>()), Times.Once); if (false == IndexExists_Exists) { cli.Verify(e => e.IndexCreateAsync(It.Is <Nest.IndexName>(i => i.Name == "testindex") , It.IsAny <Func <CreateIndexDescriptor, ICreateIndexRequest> >() , It.IsAny <CancellationToken>()), Times.Once); } cli.Verify(e => e.IndexAsync(It.Is <ElasticsearchAccessLogDocument>(d => d.LogName == "access_log" && d.Timestamp <DateTime.Now && d.Timestamp> DateTime.Now.AddSeconds(-1) && d.Id == "mockid" && d.AppName == "mockapp" && d.RequestParameters.ContainsKey("mockparam1") && d.RequestParameters["mockparam1"] == "mockvalue1" && d.Headers.ContainsKey("mockheader1") && d.Headers["mockheader1"] == "mockheadervalue1" && d.Stat.Count == 1 && d.Stat[0].Call == "mockcall" && d.Stat[0].Comment == "mockcomment" && d.Stat[0].ElapsedSeconds == 5 ) , It.IsAny <Func <IndexDescriptor <ElasticsearchAccessLogDocument>, IIndexRequest <ElasticsearchAccessLogDocument> > >() , It.IsAny <CancellationToken>()), Times.Once); }
public async void IndexDocumentExpectedExceptionTest() { ElasticsearchReporter r = new ElasticsearchReporter(CreateCli <ElasticsearchAccessLogDocument>(IndexResponse_IsValid: false).Object); var d = new ElasticsearchAccessLogDocument(); await Assert.ThrowsAsync <ElasticsearchException>(() => r.Post(d, "testindex", false)); }