public void VisitAssemblyElementCollectsCorrectName()
        {
            var sut = new DisplayNameCollector();
            var assembly = typeof(object).Assembly;
            var expected = assembly.ToElement().ToString();

            var actual = sut.Visit(assembly.ToElement());

            Assert.Equal(expected, actual.Value.Single());
        }
        public void VisitFieldInfoElementCollectsCorrectName()
        {
            var sut = new DisplayNameCollector();
            var fieldInfo = typeof(ClassWithMembers).GetFields().First();
            var expected = string.Format(
                "[[{0}][{1}]] (field)",
                fieldInfo.ReflectedType,
                fieldInfo);

            var actual = sut.Visit(fieldInfo.ToElement());

            Assert.Equal(expected, actual.Value.Single());
        }
        public void VisitConstructorInfoElementCollectsCorrectName()
        {
            var sut = new DisplayNameCollector();
            var constructorInfo = typeof(string).GetConstructors().First();
            var expected = string.Format(
                "[[{0}][{1}]] (constructor)",
                constructorInfo.ReflectedType,
                constructorInfo);

            var actual = sut.Visit(constructorInfo.ToElement());

            Assert.Equal(expected, actual.Value.Single());
        }
        public void VisitManyConstructorInfoElementsCollectsCorrectNames()
        {
            var sut = new DisplayNameCollector();
            var constructorInfo = typeof(string).GetConstructors().First();

            var actual1 = sut.Visit(constructorInfo.ToElement());
            var actual2 = actual1.Visit(constructorInfo.ToElement());

            Assert.Equal(2, actual2.Value.Count());
        }
        public void VisitManyAssemblyElementsCollectsCorrectNames()
        {
            var sut = new DisplayNameCollector();
            var assembly = typeof(object).Assembly;

            var actual1 = sut.Visit(assembly.ToElement());
            var actual2 = actual1.Visit(assembly.ToElement());

            Assert.Equal(2, actual2.Value.Count());
        }
        public void VisitTypeElementCollectsCorrectName()
        {
            var sut = new DisplayNameCollector();
            var type = typeof(string);
            var expected = type.ToElement().ToString();

            var actual = sut.Visit(type.ToElement());

            Assert.Equal(expected, actual.Value.Single());
        }
 public void VisitNullTypeElementThrows()
 {
     var sut = new DisplayNameCollector();
     Assert.Throws<ArgumentNullException>(() => sut.Visit((TypeElement)null));
 }
 public void ValueIsCorrect()
 {
     var sut = new DisplayNameCollector();
     var actual = sut.Value;
     Assert.Empty(actual);
 }
        public void VisitManyTypeElementsCollectsCorrectNames()
        {
            var sut = new DisplayNameCollector();
            var type = typeof(object);

            var actual1 = sut.Visit(type.ToElement());
            var actual2 = actual1.Visit(type.ToElement());

            Assert.Equal(2, actual2.Value.Count());
        }
 public void SutIsReflectionVisitor()
 {
     var sut = new DisplayNameCollector();
     Assert.IsAssignableFrom<IReflectionVisitor<IEnumerable<string>>>(sut);
 }
        public void VisitManyPropertyInfoElementsCollectsCorrectNames()
        {
            var sut = new DisplayNameCollector();
            var propertyInfo = typeof(ClassWithMembers).GetProperties().First();

            var actual1 = sut.Visit(propertyInfo.ToElement());
            var actual2 = actual1.Visit(propertyInfo.ToElement());

            Assert.Equal(2, actual2.Value.Count());
        }