-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Accounted for rare state when namespace prefix is
null
.
This is a rare state caused by the combination of several factors and extensions. Let's hope it doesn't break something else out there. :p
- Loading branch information
1 parent
e8abfa3
commit 02adccc
Showing
2 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
test/ExtendedXmlSerializer.Tests.ReportedIssues/Issue423Tests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
using ExtendedXmlSerializer.Configuration; | ||
using ExtendedXmlSerializer.Tests.ReportedIssues.Support; | ||
using FluentAssertions; | ||
using JetBrains.Annotations; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Xunit; | ||
|
||
namespace ExtendedXmlSerializer.Tests.ReportedIssues | ||
{ | ||
public sealed class Issue423Tests | ||
{ | ||
[Fact] | ||
public void Verify() | ||
{ | ||
var subject = new Subject {Values = {"Hello", "World!"}}; | ||
var element = new[] {subject}; | ||
|
||
var serializer = new ConfigurationContainer().UseOptimizedNamespaces() | ||
.EnableImplicitTyping(typeof(Subject)) | ||
.Create() | ||
.ForTesting(); | ||
serializer.Cycle(element).Should().BeEquivalentTo(element.Cast<Subject>()); | ||
} | ||
|
||
[Fact] | ||
public void VerifyReported() | ||
{ | ||
var config = new NewOptionSetFieldInfo | ||
{ | ||
Values = | ||
{ | ||
{123, "abc"}, | ||
{456, "def"} | ||
} | ||
}; | ||
var element = new[] {config}; | ||
|
||
var serializer = new ConfigurationContainer().UseOptimizedNamespaces() | ||
.EnableImplicitTypingFromPublicNested<Issue423Tests>() | ||
.EnableParameterizedContentWithPropertyAssignments() | ||
.Create() | ||
.ForTesting(); | ||
|
||
serializer.Cycle(config).Should().BeEquivalentTo(config); | ||
serializer.Cycle(element).Should().BeEquivalentTo(element.Cast<NewOptionSetFieldInfo>()); | ||
} | ||
|
||
public class ExistingOptionSetFieldInfo : NewFieldInfo | ||
{ | ||
public ExistingOptionSetFieldInfo() : base(FieldType.OptionSet) | ||
{ | ||
IsExistsOnSource = true; | ||
} | ||
|
||
public bool IsExistsOnSource { get; protected set; } | ||
|
||
public string OptionSetName { get; set; } | ||
} | ||
|
||
public enum FieldType | ||
{ | ||
OptionSet | ||
} | ||
|
||
public class NewFieldInfo | ||
{ | ||
public NewFieldInfo(FieldType type) | ||
{ | ||
Type = type; | ||
} | ||
|
||
public FieldType Type { get; } | ||
|
||
public string Name { get; set; } | ||
|
||
public string Description { get; set; } = null; | ||
|
||
public bool IsRequired { get; set; } | ||
|
||
public string TargetName { get; set; } | ||
|
||
public bool ShouldCreateFieldOnTarget { get; set; } | ||
} | ||
|
||
public class NewOptionSetFieldInfo : ExistingOptionSetFieldInfo | ||
{ | ||
public NewOptionSetFieldInfo() | ||
{ | ||
IsExistsOnSource = false; | ||
} | ||
|
||
public Dictionary<int, string> Values { get; } = new Dictionary<int, string>(); | ||
} | ||
|
||
sealed class Subject | ||
{ | ||
[UsedImplicitly] | ||
public List<string> Values { get; } = new List<string>(); | ||
} | ||
} | ||
} |