public async Task Map_Existing_ReturnsUpdatedTopic() { var mappingService = new ReverseTopicMappingService(_topicRepository); var bindingModel = new TextAttributeTopicBindingModel() { Key = "Test", ContentType = "TextAttribute", Title = null, DefaultValue = "World", IsRequired = false }; var target = (TextAttribute?)TopicFactory.Create("Test", "TextAttribute"); target.Title = "Original Attribute"; target.DefaultValue = "Hello"; target.IsRequired = true; target.IsExtendedAttribute= false; target.Attributes.SetValue("Description", "Original Description"); target = (TextAttribute?)await mappingService.MapAsync(bindingModel, target).ConfigureAwait(false); Assert.AreEqual<string>("Test", target.Key); Assert.AreEqual<string>("TextAttribute", target.ContentType); Assert.AreEqual<string>("Test", target.Title); //Should inherit from "Key" since it will be null Assert.AreEqual<string>("World", target.DefaultValue); Assert.AreEqual<bool>(false, target.IsRequired); Assert.AreEqual<bool>(false, target.IsExtendedAttribute); Assert.AreEqual<string>("Original Description", target.Attributes.GetValue("Description")); }
public async Task Map_Generic_ReturnsNewTopic() { var mappingService = new ReverseTopicMappingService(_topicRepository); var bindingModel = new TextAttributeTopicBindingModel() { Key = "Test", ContentType = "TextAttribute", Title = "Test Attribute", DefaultValue = "Hello", IsRequired = true }; var target = await mappingService.MapAsync<TextAttribute>(bindingModel).ConfigureAwait(false); Assert.AreEqual<string>("Test", target.Key); Assert.AreEqual<string>("TextAttribute", target.ContentType); Assert.AreEqual<string>("Test Attribute", target.Title); Assert.AreEqual<string>("Hello", target.DefaultValue); Assert.AreEqual<bool>(true, target.IsRequired); }