public void Collection_Adds_Are_Overwritten()
        {
            // Add all properties of type int
            _intsAndString.IncludeAll <int>();

            // Properties exists, and should be overwritten
            _intsAndString.IncludeAll <int>();

            // Total should be 2
            Assert.AreEqual(_intsAndString.Names.Count(), 2,
                            "Expected the set have a size of 2");
        }
        public void Throws_Collection_Add_If_Bool_Set()
        {
            try
            {
                _intsAndString.IncludeAll <float>(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, true);
            }
            catch (NoSuchPropertyException)
            {
                return;
            }

            Assert.Fail("Expected an exception to be thrown");
        }
예제 #3
0
        public void Static_Included()
        {
            // Add all int properties
            _intsOneStatic.IncludeAll <int>(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);

            // Verify
            var expectedMembers = new[] { "Int1", "Int2" };

            foreach (var s in expectedMembers)
            {
                Assert.IsTrue(_intsOneStatic.Names.Any(x => x.Equals(s)),
                              "Did not contain " + s);
            }
        }
        public void IncludeAll()
        {
            // Add all properties
            _intsAndString.IncludeAll();

            // Verify
            var expectedMembers = new[] { "Int1", "Int2", "StringProp" };

            foreach (var s in expectedMembers)
            {
                Assert.IsTrue(_intsAndString.Names.Any(x => x.Equals(s)),
                              "Did not contain " + s);
            }
        }
        public void IncludeAll()
        {
            // Add all
            _manyProperties.IncludeAll(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);

            // Should now include all properties available
            Assert.IsTrue(this.SetIncludes(this.AllPropertyNames()));
        }
예제 #6
0
        public void IncludeAll_IncludesAllProperties()
        {
            // arrange
            var filter = new PropertyFilter <FakeClass>("foo");

            // act
            filter.IncludeAll();

            // assert
            Assert.Equal(2, filter.IncludedProperties.Count);
        }
예제 #7
0
        public void Apply_NullQuery_ReturnsSource()
        {
            // arrange
            var filter = new PropertyFilter <FakeClass>(null);

            filter.IncludeAll();
            var coll = GetSampleList().AsQueryable();

            // act
            var result = filter.Apply(coll);

            // assert
            Assert.Equal(coll, result);
        }
예제 #8
0
        public void AddToExisting()
        {
            // Start with a collection, ints only
            _intsAndString.IncludeAll <int>();

            // String shouldnt be included yet
            Assert.IsFalse(_intsAndString.Names.Any(x => x.Equals("StringProp")),
                           "Contained StringProp when only ints were expected");

            _intsAndString.Include(x => x.StringProp);

            // String should now be included
            Assert.IsTrue(_intsAndString.Names.Any(x => x.Equals("StringProp")),
                          "Did not contain StringProp");
        }
예제 #9
0
        public void Apply_Enumerable_ReturnsEnumerable()
        {
            // arrange
            var term   = "foo";
            var coll   = GetSampleList();
            var filter = new PropertyFilter <FakeClass>(term);

            filter.IncludeAll();

            // act
            var result = filter.Apply(coll).ToList();

            // assert
            Assert.True(result.Count(t => t.Property1.Equals(term, StringComparison.OrdinalIgnoreCase)) == 1);
        }