コード例 #1
0
        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
            });
        }
コード例 #2
0
            public When_a_specific_projector_is_requested()
            {
                Given(() =>
                {
                    var nowUtc = 10.July(2017).At(10, 39).AsUtc();
                    var stats  = new ProjectionStats(() => nowUtc);

                    stats.TrackProgress("id1", 1000);
                    stats.StoreProperty("id1", "property1", "value1");

                    var appBuilder = new AppBuilder();
                    appBuilder.UseLiquidProjections(stats);

                    var httpClient = new HttpClient(new OwinHttpMessageHandler(appBuilder.Build()));
                    httpClient.DefaultRequestHeaders.Accept.Add(
                        new MediaTypeWithQualityHeaderValue("application/json"));

                    WithSubject(ct => httpClient);
                });

                When(async() =>
                {
                    return(await Subject.GetAsync("http://localhost/projectionStats/id1"));
                });
            }