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(); }
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); }
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"); }
public void Map_correctly_returns_PrismicStructuredText_value() { var result = PrismicMapper.Map <TestMappingClass>(_document); result.StructuredText.getFirstParagraph().Text.Should().Be(GetFragment <StructuredText>("structuredtext").getFirstParagraph().Text); }
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); }
public void Map_correctly_returns_PrismicUid_value() { var result = PrismicMapper.Map <TestMappingClass>(_document); result.Id.Should().Be(_document.Uid); }
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"); }
public void Map_correctly_returns_PrismicChildProperty_value() { var result = PrismicMapper.Map <TestMappingClass>(_document); result.Child.ChildText.Should().Be(GetFragment <Text>("childtext").Value); }
public void Map_correctly_returns_PrismicDate_value_for_named_field() { var result = PrismicMapper.Map <TestMappingClass>(_document); result.NamedDate.Should().Be(GetFragment <Date>("date").Value); }