public static Extractor GetExtractor( this SupportEventTypeAssertionEnum enumValue) { switch (enumValue) { case SupportEventTypeAssertionEnum.NAME: return ( desc, eventType) => desc.PropertyName; case SupportEventTypeAssertionEnum.TYPE: return ( desc, eventType) => desc.PropertyType; case SupportEventTypeAssertionEnum.FRAGMENT_TYPE_NAME: return ( desc, eventType) => { var fragType = eventType.GetFragmentType(desc.PropertyName); return fragType?.FragmentType.Name; }; case SupportEventTypeAssertionEnum.FRAGMENT_IS_INDEXED: return ( desc, eventType) => { var fragType = eventType.GetFragmentType(desc.PropertyName); return fragType?.IsIndexed; }; } throw new ArgumentException("value out of bounds", nameof(enumValue)); }
public static void AssertEventTypeProperties( Object[][] expectedArr, EventType eventType, params SupportEventTypeAssertionEnum[] assertions) { for (int propNum = 0; propNum < expectedArr.Length; propNum++) { string message = "Failed assertion for property " + propNum; EventPropertyDescriptor prop = eventType.PropertyDescriptors[propNum]; for (int i = 0; i < assertions.Length; i++) { SupportEventTypeAssertionEnum assertion = assertions[i]; object expected = expectedArr[propNum][i]; object value = assertion.GetExtractor().Invoke(prop, eventType); ScopeTestHelper.AssertEquals(message + " at assertion " + assertion, expected, value); } } }