Пример #1
0
        public void WithPrefixAndOneForType_should_be_date()
        {
            var cfg = new Mock <IConfigurationValueProvider>();

            cfg.Setup(x => x.GetValue(ConfigurationKeys.EsOneIndexPerType)).Returns(true.ToString());
            cfg.Setup(x => x.GetValue(ConfigurationKeys.EsIndexPrefix)).Returns("PREFIX-");
            var indexNamer = new IndexNamer(cfg.Object);

            Assert.Equal("PREFIX-vavavoom-19690818", indexNamer.BuildName(_date, TypeName));
        }
Пример #2
0
        public void TriesMultipleTimesAndSucceed()
        {
            var client     = new Mock <IHttpClient>(MockBehavior.Loose);
            var indexNamer = new IndexNamer(new AzureConfigurationValueProvider());
            var pusher     = new ElasticsearchBatchPusher(client.Object, new AzureConfigurationValueProvider(), "http://google.com", indexNamer);
            var summary    = new DiagnosticsSourceSummary()
            {
                ConnectionString = String.Empty,
                PartitionKey     = "pk",
                RowKey           = "rk"
            };

            pusher.PushAsync(new DynamicTableEntity("pk", "rk"), summary).Wait();
            pusher.PushAsync(new DynamicTableEntity("pk", "rk"), summary).Wait();
            pusher.PushAsync(new DynamicTableEntity("pk", "rk"), summary).Wait();
            pusher.PushAsync(new DynamicTableEntity("pk", "rk"), summary).Wait();
            client.Setup(x => x.PostAsync(It.IsAny <string>(), It.IsAny <HttpContent>())).ReturnsAsync(
                new HttpResponseMessage(HttpStatusCode.Accepted)
            {
                Content = new StringContent(File.ReadAllText(@"data\es_response_allsuxes.json"))
            });

            pusher.FlushAsync().Wait();
        }