<commit_before>﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Microsoft.CSharp.RuntimeBinder;
using NUnit.Framework;
using System.Reflection;
using Rock.Reflection.UnitTests.TypeBuilder;

namespace Rock.Reflection.UnitTests
{
    public class UniversalMemberAccessorTests
    {
        [Test]
        public void CannotCallGetStaticWithNullType()
        {
            Assert.That(() => UniversalMemberAccessor.GetStatic((Type)null), Throws.InstanceOf<ArgumentNullException>());
        }

        [Test]
        public void CanGetBackingInstanceWithInstance()
        {
            var foo = new Foo(123).Unlock();

            var backingFoo = foo.Instance;

            Assert.That(foo, Is.InstanceOf<UniversalMemberAccessor>());
            Assert.That(backingFoo, Is.InstanceOf<Foo>());
        }

        [Test]
        public void CanGetBackingInstanceWithObject()
        {
            var foo = new Foo(123).Unlock();

            var backingFoo = foo.Object;

            Assert.That(foo, Is.InstanceOf<UniversalMemberAccessor>());<commit_msg>Add test for GetDynamicMemberNames<commit_after>﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Microsoft.CSharp.RuntimeBinder;
using NUnit.Framework;
using System.Reflection;
using Rock.Reflection.UnitTests.TypeBuilder;

namespace Rock.Reflection.UnitTests
{
    public class UniversalMemberAccessorTests
    {
        [Test]
        public void GetDynamicMemberNamesReturnsAllTheMemberNamesOfTheType()
        {
            var type = Create.Class();

            var instance = type.New();

            var allMemberNames = type.GetMembers(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
                .Where(m => !(m is ConstructorInfo))
                .Select(m => m.Name);

            var dynamicMemberNames = instance.GetDynamicMemberNames();

            Assert.That(dynamicMemberNames, Is.EqualTo(allMemberNames));
        }

        [Test]
        public void CannotCallGetStaticWithNullType()
        {
            Assert.That(() => UniversalMemberAccessor.GetStatic((Type)null), Throws.InstanceOf<ArgumentNullException>());
        }

        [Test]
        public void CanGetBackingInstanceWithInstance()
        {
            var foo = new Foo(123).Unlock();

            var backingFoo = foo.Instance;

            Assert.That(foo, Is.InstanceOf<UniversalMemberAccessor>());
            Assert.That(backingFoo, Is.InstanceOf<Foo>());
        }

        [Test]
        public void CanGetBackingInstanceWithObject()
        {
            var foo = new Foo(123).Unlock();

            var backingFoo = foo.Object;

            Assert.That(foo, Is.InstanceOf<UniversalMemberAccessor>());
{'fraction_non_alphanumeric': 0.10021398002853067, 'fraction_numerical': 0.0042796005706134095, 'mean_word_length': 2.65234375, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4827119', 'n_tokens_mistral': 759, 'n_tokens_neox': 712, 'n_words': 141}