public void writes_to_azure_tables()
        {
            var table = client.GetTableReference(tableName);
            var query = new TableQuery <TestCloudTableEntry>();

            table.CreateIfNotExists();

            var list = PollingHelper.WaitUntil(() => table.ExecuteQuery(query).ToArray(), l => l.Length >= 4, TimeSpan.FromSeconds(20));

            Assert.AreEqual <int>(4, list.Count());
            Assert.IsTrue(list.Any(x => x.EventId == 1));
            Assert.IsTrue(list.Any(x => x.EventId == 2));
            Assert.IsTrue(list.Any(x => x.EventId == 3));
            Assert.IsTrue(list.Any(x => x.EventId == 4));
        }
Beispiel #2
0
        public void then_writing_more_events_should_flush_only_the_batch_size()
        {
            for (int i = 0; i < BufferingCount + 2; i++)
            {
                var entry = new EventRecord
                {
                    ProviderId       = Guid.NewGuid(),
                    ProviderName     = "TestName",
                    EventId          = 50,
                    Level            = (int)EventLevel.Verbose,
                    Opcode           = 5,
                    Task             = 6,
                    Timestamp        = DateTimeOffset.UtcNow,
                    Version          = 2,
                    InstanceName     = "Custom instance name",
                    FormattedMessage = "Test" + i,
                    Payload          = "{arg0:Test}"
                };

                this.sink.OnNext(entry);
                Thread.Sleep(10);
            }

            int count = PollingHelper.WaitUntil(() =>
            {
                using (var cmd = new SqlCommand("SELECT COUNT(*) FROM Traces", this.LocalDbConnection))
                {
                    return((int)cmd.ExecuteScalar());
                }
            },
                                                c => c > 0,
                                                TimeSpan.FromSeconds(30));

            this.sink.Dispose();

            Assert.AreEqual(BufferingCount, count);
        }
Beispiel #3
0
        public void then_writing_more_events_should_flush_only_the_batch_size()
        {
            for (int i = 0; i < BufferingCount + 2; i++)
            {
                var entry =
                    EventEntryTestHelper.Create(
                        providerId: Guid.NewGuid(),
                        providerName: "TestName",
                        eventId: 50,
                        level: EventLevel.Verbose,
                        opcode: (EventOpcode)5,
                        task: (EventTask)6,
                        timestamp: DateTimeOffset.UtcNow,
                        version: 2,
                        formattedMessage: "Test" + i,
                        payloadNames: new string[] { "arg0" },
                        payload: new object[] { "Test" });

                this.sink.OnNext(entry);
                Thread.Sleep(10);
            }

            int count = PollingHelper.WaitUntil(() =>
            {
                using (var cmd = new SqlCommand("SELECT COUNT(*) FROM Traces", this.localDbConnection))
                {
                    return((int)cmd.ExecuteScalar());
                }
            },
                                                c => c > 0,
                                                TimeSpan.FromSeconds(30));

            this.sink.Dispose();

            Assert.AreEqual(BufferingCount, count);
        }