diff --git a/OnTopic.Tests/TopicMappingServiceTest.cs b/OnTopic.Tests/TopicMappingServiceTest.cs index b21bcbc5..81d6b8bc 100644 --- a/OnTopic.Tests/TopicMappingServiceTest.cs +++ b/OnTopic.Tests/TopicMappingServiceTest.cs @@ -295,13 +295,29 @@ public class TopicMappingServiceTest { var topic = new Topic("Test", "Page"); var lastModified = new DateTime(2021, 12, 22); - topic.Attributes.SetValue("Subtitle", "Value"); + topic.Attributes.SetValue("Title", "Value"); + topic.Attributes.SetValue("ShortTitle", "Short Title"); + topic.Attributes.SetValue("Subtitle", "Subtitle"); + topic.Attributes.SetValue("MetaTitle", "Meta Title"); + topic.Attributes.SetValue("MetaDescription", "Meta Description"); + topic.Attributes.SetValue("MetaKeywords", "Load;Test;Keywords"); + topic.Attributes.SetValue("NoIndex", "0"); + topic.Attributes.SetValue("Body", "Body of test topic"); + topic.Attributes.SetValue("MappedProperty", "Mapped Value"); + topic.Attributes.SetValue("UnmappedProperty", "Unmapped Value"); topic.VersionHistory.Add(lastModified); - var target = await _mappingService.MapAsync(topic).ConfigureAwait(false); - - Assert.Equal("Test", target?.Title); - Assert.Equal("Value", target?.Subtitle); + var target = await _mappingService.MapAsync(topic).ConfigureAwait(false); + + Assert.Equal("Value", target?.Title); + Assert.Equal("Short Title", target?.ShortTitle); + Assert.Equal("Subtitle", target?.Subtitle); + Assert.Equal("Meta Title", target?.MetaTitle); + Assert.Equal("Meta Description", target?.MetaDescription); + Assert.Equal(false, target?.NoIndex); + Assert.Equal("Load;Test;Keywords", target?.MetaKeywords); + Assert.Equal("Mapped Value", target?.MappedProperty); + Assert.Null(target?.UnmappedProperty); Assert.Equal(lastModified, target?.LastModified); } diff --git a/OnTopic.Tests/ViewModels/AttributeDictionaryConstructorTopicViewModel.cs b/OnTopic.Tests/ViewModels/AttributeDictionaryConstructorTopicViewModel.cs new file mode 100644 index 00000000..e3c1752d --- /dev/null +++ b/OnTopic.Tests/ViewModels/AttributeDictionaryConstructorTopicViewModel.cs @@ -0,0 +1,48 @@ +/*============================================================================================================================== +| Author Ignia, LLC +| Client Ignia, LLC +| Project Topics Library +\=============================================================================================================================*/ + +using OnTopic.Attributes; + +namespace OnTopic.Tests.ViewModels { + + /*============================================================================================================================ + | VIEW MODEL: ATTRIBUTE DICTIONARY CONSTRUCTOR + \---------------------------------------------------------------------------------------------------------------------------*/ + /// + /// Provides a strongly-typed data transfer object for testing a constructor with a . + /// + /// + /// This is a sample class intended for test purposes only; it is not designed for use in a production environment. + /// + public record AttributeDictionaryConstructorTopicViewModel: PageTopicViewModel { + + /*========================================================================================================================== + | CONSTRUCTOR + \-------------------------------------------------------------------------------------------------------------------------*/ + /// + /// Initializes a new with an + /// dictionary. + /// + /// An of attribute values. + public AttributeDictionaryConstructorTopicViewModel(AttributeDictionary attributes) : base(attributes) { + Contract.Requires(attributes, nameof(attributes)); + MappedProperty = attributes.GetValue(nameof(MappedProperty)); + } + + /// + /// Initializes a new with no parameters. + /// + public AttributeDictionaryConstructorTopicViewModel() { } + + /*========================================================================================================================== + | PROPERTIES + \-------------------------------------------------------------------------------------------------------------------------*/ + public string? MappedProperty { get; init; } + public string? UnmappedProperty { get; init; } + + + } //Class +} //Namespace \ No newline at end of file