Пример #1
0
        public void dictionary_should_be_detected()
        {
            Dictionary <int, int>         someDictionary = new Dictionary <int, int>();
            ObjectCrawler                 crawler        = new ObjectCrawler();
            ObjectGraphVisitorVisitorStub visitor        = new ObjectGraphVisitorVisitorStub();

            crawler.AddVisitor(visitor);

            crawler.Crawl(someDictionary);

            visitor.Enumerable?.Type.Should().NotBeNull().And.Be <Dictionary <int, int> >();
        }
Пример #2
0
        public void string_should_be_detected_as_value()
        {
            string        value   = "some string";
            ObjectCrawler crawler = new ObjectCrawler();
            ObjectGraphVisitorVisitorStub visitor = new ObjectGraphVisitorVisitorStub();

            crawler.AddVisitor(visitor);

            crawler.Crawl(value);

            visitor.Value?.Type.Should().Be <string>();
        }
Пример #3
0
        public void enumerable_should_be_detected()
        {
            List <int>    someList = new List <int>();
            ObjectCrawler crawler  = new ObjectCrawler();
            ObjectGraphVisitorVisitorStub visitor = new ObjectGraphVisitorVisitorStub();

            crawler.AddVisitor(visitor);

            crawler.Crawl(someList);

            visitor.Enumerable?.Type.Should().NotBeNull().And.Be <List <int> >();
        }
Пример #4
0
        public void structures_should_be_detected_as_value()
        {
            DateTime      dateTime = DateTime.Now;
            ObjectCrawler crawler  = new ObjectCrawler();
            ObjectGraphVisitorVisitorStub visitor = new ObjectGraphVisitorVisitorStub();

            crawler.AddVisitor(visitor);

            crawler.Crawl(dateTime);

            visitor.Value?.Type.Should().Be <DateTime>();
        }
Пример #5
0
        public void a_simple_object_should_be_detected_as_reference()
        {
            object        o       = new object();
            ObjectCrawler crawler = new ObjectCrawler();
            ObjectGraphVisitorVisitorStub visitor = new ObjectGraphVisitorVisitorStub();

            crawler.AddVisitor(visitor);

            crawler.Crawl(o);

            visitor.Reference?.Type.Should().NotBeNull().And.Be <object>();
        }
Пример #6
0
        public void field_should_be_detected_on_reference()
        {
            AClassWithSingleField         classWithSingleField = new AClassWithSingleField();
            ObjectCrawler                 crawler = new ObjectCrawler();
            ObjectGraphVisitorVisitorStub visitor = new ObjectGraphVisitorVisitorStub();

            crawler.AddVisitor(visitor);

            crawler.Crawl(classWithSingleField);

            visitor.Reference?.Type.Should().Be <AClassWithSingleField>();
            visitor.Field.Should().NotBeNull();
            visitor.Field.Field.Name.Should().Be("_singleField");
        }
Пример #7
0
        public void property_should_be_detected_on_reference()
        {
            AClassWithSingleProperty      classWithSingleProperty = new AClassWithSingleProperty();
            ObjectCrawler                 crawler = new ObjectCrawler();
            ObjectGraphVisitorVisitorStub visitor = new ObjectGraphVisitorVisitorStub();

            crawler.AddVisitor(visitor);

            crawler.Crawl(classWithSingleProperty);

            visitor.Reference?.Type.Should().Be <AClassWithSingleProperty>();
            visitor.Property.Should().NotBeNull();
            visitor.Property.Property.Name.Should().Be(nameof(AClassWithSingleProperty.SingleProperty));
        }
Пример #8
0
        public void self_reference_should_not_cause_stack_overflow()
        {
            AClassWithSelfReference classWithSelfReference = new AClassWithSelfReference();

            classWithSelfReference.Self = classWithSelfReference;
            ObjectCrawler crawler = new ObjectCrawler();
            ObjectGraphVisitorVisitorStub visitor = new ObjectGraphVisitorVisitorStub();

            crawler.AddVisitor(visitor);

            crawler.Crawl(classWithSelfReference);

            visitor.Reference?.Type.Should().Be <AClassWithSelfReference>();
            visitor.Property.Should().NotBeNull();
            visitor.Property.Property.Name.Should().Be(nameof(AClassWithSelfReference.Self));
        }