public void When_checking_in_multiple_times_for_a_projector_it_should_remember_the_last_only()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            DateTime nowUtc = 16.June(2017).At(15, 00).AsUtc();

            var stats = new ProjectionStats(() => nowUtc);

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            stats.TrackProgress("myProjector", 1000);

            nowUtc = nowUtc.Add(1.Hours());

            stats.TrackProgress("myProjector", 2000);

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            var projectorStats = stats.Should().ContainSingle(s => s.ProjectorId == "myProjector").Subject;

            projectorStats.LastCheckpoint.Checkpoint.Should().Be(2000);
            projectorStats.LastCheckpoint.TimestampUtc.Should().Be(nowUtc);
        }
        public void When_multiple_properties_are_registered_under_the_same_name_it_should_only_remember_the_last_one()
        {
            DateTime nowUtc = 16.June(2017).At(15, 00).AsUtc();

            var stats = new ProjectionStats(() => nowUtc);

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            stats.StoreProperty("myProjector", "theName", "aValue");

            nowUtc = nowUtc.Add(1.Hours());

            stats.StoreProperty("myProjector", "theName", "anotherValue");

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            var projectorStats = stats.Should().ContainSingle(s => s.ProjectorId == "myProjector").Subject;

            projectorStats.GetProperties().Should().ContainKey("theName");
            projectorStats.GetProperties()["theName"].Should().BeEquivalentTo(new
            {
                Value        = "anotherValue",
                TimestampUtc = nowUtc
            });
        }
        public void When_multiple_events_are_registered_it_should_remember_their_timestamps()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            DateTime nowUtc = 16.June(2017).At(15, 00).AsUtc();

            var stats = new ProjectionStats(() => nowUtc);

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            stats.LogEvent("myProjector", "first event");

            nowUtc = nowUtc.At(16, 00).AsUtc();
            stats.LogEvent("myProjector", "second event");

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            var projectorStats = stats.Should().ContainSingle(s => s.ProjectorId == "myProjector").Subject;

            projectorStats.GetEvents().Should().BeEquivalentTo(new[]
            {
                new
                {
                    Body         = "first event",
                    TimestampUtc = nowUtc.At(15, 00)
                },
                new
                {
                    Body         = "second event",
                    TimestampUtc = nowUtc.At(16, 00)
                }
            });
        }