コード例 #1
0
        public void empty_log_does_not_fail()
        {
            var logBuilder = W3LogBuilder.Create();

            using (var logFile = logBuilder.Build())
            {
                var sut    = this.CreateSut();
                var report = sut.GetTrafficReport(logFile.FileName, new DateTime(2010, 10, 9), new DateTime(2010, 10, 10));
            }
        }
コード例 #2
0
        public void no_crawlers()
        {
            using (var fixture = ProgramFixture.Create())
            {
                fixture.With(W3LogBuilder.Create().WithMultipleRegularUsersFreshEntries());
                var sut = fixture.Build();

                sut.Run();

                fixture.InsertedEntries.Should().BeEmpty();
            }
        }
コード例 #3
0
        public void no_matching_rows_default_timespan_scenario()
        {
            using (var fixture = ProgramFixture.Create())
            {
                fixture.With(W3LogBuilder.Create().WithMultipleCrawlerOldEntries());
                var sut = fixture.Build();

                sut.Run();

                fixture.InsertedEntries.Should().BeEmpty();
            }
        }
コード例 #4
0
        public void success_unbounded_timespan_scenario()
        {
            using (var fixture = ProgramFixture.Create())
            {
                fixture.WithUnboundedTimespan();
                fixture.With(W3LogBuilder.Create().WithMultipleCrawlerOldEntries());
                var sut = fixture.Build();

                sut.Run();

                fixture.InsertedEntries.Should().NotBeEmpty();
            }
        }
コード例 #5
0
        public void date_range_is_non_strict_both_sides()
        {
            var logBuilder = W3LogBuilder.Create().WithEntry(e => e.Timestamp = new DateTime(2010, 10, 10));

            using (var logFile = logBuilder.Build())
            {
                var sut    = this.CreateSut();
                var report = sut.GetTrafficReport(
                    logFile.FileName,
                    new DateTime(2010, 10, 10),
                    new DateTime(2010, 10, 10));

                report.Entries.Should().HaveCount(1);
            }
        }
コード例 #6
0
        public void entries_outside_the_date_are_omitted()
        {
            var logBuilder = W3LogBuilder.Create().WithEntry(e => e.Timestamp = new DateTime(2010, 10, 10));

            using (var logFile = logBuilder.Build())
            {
                var sut    = this.CreateSut();
                var report = sut.GetTrafficReport(
                    logFile.FileName,
                    new DateTime(2010, 10, 11),
                    new DateTime(2010, 10, 12));

                report.Entries.Should().HaveCount(0);
            }
        }
コード例 #7
0
        public void entries_within_the_date_range_get_included()
        {
            var logBuilder = W3LogBuilder.Create().WithEntry(e => e.Timestamp = new DateTime(2010, 10, 10));

            using (var logFile = logBuilder.Build())
            {
                var sut    = this.CreateSut();
                var report = sut.GetTrafficReport(
                    logFile.FileName,
                    new DateTime(2010, 10, 10),
                    new DateTime(2010, 10, 10, 23, 59, 59));

                report.Entries.Should().HaveCount(1);
                report.Entries.First().AccessAttempts.Should().Be(1);
            }
        }
コード例 #8
0
        public void number_of_bytes_sum_up_for_same_ip()
        {
            var logBuilder = W3LogBuilder.Create()
                             .WithEntry(Ip("1.2.3.4"), Sent(1), Received(1))
                             .WithEntry(Ip("1.2.3.4"), Sent(1), Received(1))
                             .WithEntry(Ip("1.2.3.4"), Sent(1), Received(1));

            using (var logFile = logBuilder.Build())
            {
                var sut    = this.CreateSut();
                var report = sut.GetTrafficReport(logFile.FileName, DateTime.MinValue, new DateTime(2020, 01, 01));

                report.Entries.Should().HaveCount(1);
                report.Entries.First().TransferedBytes.Should().Be(6);
            }
        }
コード例 #9
0
        public void number_of_hits_sum_up_for_same_ip()
        {
            var logBuilder = W3LogBuilder.Create()
                             .WithEntry(Ip("1.2.3.4"))
                             .WithEntry(Ip("1.2.3.4"))
                             .WithEntry(Ip("1.2.3.4"));

            using (var logFile = logBuilder.Build())
            {
                var sut    = this.CreateSut();
                var report = sut.GetTrafficReport(logFile.FileName, EarlyEnough, DistantFuture);

                report.Entries.Should().HaveCount(1);
                report.Entries.First().AccessAttempts.Should().Be(3);
            }
        }
コード例 #10
0
        public void matching_entries_from_all_files_get_included()
        {
            var logBuilder = W3LogBuilder.Create().WithEntry();

            using (var logFile1 = logBuilder.Build())
                using (var logFile2 = logBuilder.Build())
                {
                    var sut    = this.CreateSut();
                    var report = sut.GetTrafficReport(
                        $"{logFile1.FileName}, {logFile2.FileName}",
                        EarlyEnough,
                        DistantFuture);

                    report.Entries.Should().HaveCount(1);
                    report.Entries.First().AccessAttempts.Should().Be(2);
                }
        }
コード例 #11
0
        public void big_transfers_should_count_up_correctly()
        {
            var logBuilder =
                W3LogBuilder.Create()
                .WithEntry(Sent(int.MaxValue))
                .WithEntry(Sent(int.MaxValue))
                .WithEntry(Sent(int.MaxValue));

            using (var logFile = logBuilder.Build())
            {
                var sut    = this.CreateSut();
                var report = sut.GetTrafficReport(logFile.FileName, EarlyEnough, DistantFuture);

                report.Entries.Should().HaveCount(1);
                report.Entries.First().TransferedBytes.Should().Be((long)4 * int.MaxValue);
            }
        }