Skip to content

Commit fabeb82

Browse files
committed
Introduced unit test for MaybeCompatible
This unit test assesses the new `CustomTopicTopicViewModel` (5310655) and confirms that it correctly detects compatible or convertible properties from `CustomTopic` (or inherited from `Topic`), while correctly identifying that missing or incompatible types not compatible. This completes Feature #102.
1 parent c6bb730 commit fabeb82

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

OnTopic.Tests/TypeAccessorTest.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using OnTopic.Tests.BindingModels;
1212
using OnTopic.Tests.Fixtures;
1313
using OnTopic.Tests.ViewModels;
14+
using OnTopic.Tests.ViewModels.Metadata;
1415
using Xunit;
1516

1617
namespace OnTopic.Tests {
@@ -625,6 +626,27 @@ public void SetMethodValue_NullReferenceValue_DoesNotSetValue() {
625626

626627
}
627628

629+
/*==========================================================================================================================
630+
| TEST: MAYBE COMPATIBLE: CORRESPONDING TOPIC: CORRECTLY SET
631+
\-------------------------------------------------------------------------------------------------------------------------*/
632+
/// <summary>
633+
/// Establishes a <see cref="TypeAccessor"/> and based on the <see cref="ContentTypeDescriptorTopicViewModel"/> and
634+
/// confirms that the underlying <see cref="MemberAccessor"/> instances are correctly marked as <see cref="ItemMetadata.
635+
/// MaybeCompatible"/> based on the association with the <see cref="ContentTypeDescriptor"/>.
636+
/// </summary>
637+
[Fact]
638+
public void MaybeCompatible_CorrespondingTopic_CorrectlySet() {
639+
640+
var typeAccessor = TypeAccessorCache.GetTypeAccessor<CustomTopicTopicViewModel>();
641+
642+
Assert.Equal(9, typeAccessor.GetMembers(MemberTypes.Property).Count(m => m.MaybeCompatible));
643+
Assert.Equal(2, typeAccessor.GetMembers(MemberTypes.Property).Count(m => !m.MaybeCompatible));
644+
Assert.Equal(9, typeAccessor.ConstructorParameters.Count(m => m.MaybeCompatible));
645+
Assert.Equal(2, typeAccessor.ConstructorParameters.Count(m => !m.MaybeCompatible));
646+
Assert.True(typeAccessor.GetMember(nameof(CustomTopicTopicViewModel.TopicReference))?.MaybeCompatible);
647+
648+
}
649+
628650
/*==========================================================================================================================
629651
| TEST: SET PROPERTY VALUE: REFLECTION PERFORMANCE
630652
\-------------------------------------------------------------------------------------------------------------------------*/

0 commit comments

Comments
 (0)