예제 #1
0
        private static void Main(string[] args)
        {
            Console.WriteLine("Starting benchmark for {0} iteration(s)...", iterations);
            var fragments = GenerateMockDocumentFragments();
            var mockDoc   = GetMockDocument("test", fragments);


            MiniProfiler.Settings.ProfilerProvider = new SingletonProfilerProvider();
            MiniProfiler.Start();

            using (MiniProfiler.Current.Step("Initial Map"))
            {
                PrismicMapper.Map <TestMappingClass>(mockDoc);
            }

            using (MiniProfiler.Current.Step("Repeat Maps"))
            {
                for (var i = 0; i < iterations; i++)
                {
                    PrismicMapper.Map <TestMappingClass>(mockDoc);
                }
            }

            var repeatMaps = MiniProfiler.Current.Root.Children.First(x => x.Name == "Repeat Maps");

            Console.WriteLine(MiniProfiler.Current.RenderPlainText() + "> Average Mapping Time: {0}ms", repeatMaps.DurationMilliseconds.GetValueOrDefault() / iterations);

            MiniProfiler.Stop();
            Console.WriteLine("Press 'Enter' to exit benchmark ...");
            Console.ReadLine();
        }
예제 #2
0
        public void Map_correctly_returns_DateTime_MinValue_when_PrismicDate_is_null()
        {
            var doc = _results.FirstOrDefault(x => x.Id == "WKWNzSwAACoAaS5h");

            var result = PrismicMapper.Map <TestMappingClass>(doc);

            result.Date.Should().Be(DateTime.MinValue);
        }
예제 #3
0
        public void Map_throws_Exception_when_destination_does_not_have_DocumentAttribute()
        {
            Action action = () =>
            {
                PrismicMapper.Map <object>(_document);
            };

            action.ShouldThrow <Exception>().WithMessage("Prismic DocumentAttribute is required");
        }
예제 #4
0
        public void Map_correctly_returns_PrismicStructuredText_value()
        {
            var result = PrismicMapper.Map <TestMappingClass>(_document);

            result.StructuredText.getFirstParagraph().Text.Should().Be(GetFragment <StructuredText>("structuredtext").getFirstParagraph().Text);
        }
예제 #5
0
        public void Map_correctly_returns_PrismicText_value_for_named_field()
        {
            var result = PrismicMapper.Map <TestMappingClass>(_document);

            result.NamedText.Should().Be(GetFragment <Text>("text_named").Value);
        }
예제 #6
0
        public void Map_correctly_returns_PrismicUid_value()
        {
            var result = PrismicMapper.Map <TestMappingClass>(_document);

            result.Id.Should().Be(_document.Uid);
        }
예제 #7
0
        public void Map_throws_Exception_when_destination_DocumentAttribute_has_no_name()
        {
            Action action = () => PrismicMapper.Map <TestMappingClassWithNoDocumentName>(_document);

            action.ShouldThrow <Exception>().WithMessage("Document name is required");
        }
예제 #8
0
        public void Map_correctly_returns_PrismicChildProperty_value()
        {
            var result = PrismicMapper.Map <TestMappingClass>(_document);

            result.Child.ChildText.Should().Be(GetFragment <Text>("childtext").Value);
        }
예제 #9
0
        public void Map_correctly_returns_PrismicDate_value_for_named_field()
        {
            var result = PrismicMapper.Map <TestMappingClass>(_document);

            result.NamedDate.Should().Be(GetFragment <Date>("date").Value);
        }