예제 #1
0
        /// <summary>
        /// Checks if a dynamic type can be set in a new SurrogateList and if the returned SurrogateList is the same (so it can be used in subsequent fluent calls).
        /// </summary>
        public void SetDynamicTypeOfSurrogateList()
        {
            String personData = String.Format("{0}Data", typeof(Person).FullName);

            IQueryableList<Person> queryableList = new SurrogateList<Person>();
            IQueryableList<Person> fluentList = queryableList.OfDynamicType(personData);

            Assert.True(ReferenceEquals(queryableList, fluentList), "The returned object isn't the same after assigning the dynamic type.");
            Assert.True(fluentList.GetType().GetTypeInfo().BaseType.GetTypeInfo().GetDeclaredField("dynamicType").GetValue(fluentList).ToString() == personData, "The returned object doesn't contain the correct dynamic type.");
        }
예제 #2
0
        /// <summary>
        /// Checks if the paths can be included in a new SurrogateList and if the returned SurrogateList is the same (so it can be used in subsequent fluent calls).
        /// </summary>
        public void SetIncludeInSurrogateList()
        {
            QueryableList<Person> queryableList = new SurrogateList<Person>();
            IQueryableList<Person> fluentList = queryableList.Include("LastName");
            IQueryableList<Person> secondFluentList = fluentList.Include("FirstName").Include("Birthday");
            IQueryableList<Person> thirdFluentList = fluentList.Include(new List<String>() { "Salutation", "Gender" });

            Assert.True(ReferenceEquals(queryableList, fluentList), "The returned object isn't the same after assigning the dynamic type.");
            Assert.True(ReferenceEquals(queryableList, secondFluentList), "The returned object isn't the same after assigning the dynamic type.");

            ICollection<String> paths = (ICollection<String>)secondFluentList.GetType().GetTypeInfo().BaseType.GetTypeInfo().GetDeclaredField("paths").GetValue(secondFluentList);

            Assert.True(paths.Contains("FirstName"), "The returned object doesn't include the added path.");
            Assert.True(paths.Contains("LastName"), "The returned object doesn't include the added path.");
            Assert.True(paths.Contains("Birthday"), "The returned object doesn't include the added path.");
            Assert.True(paths.Contains("Salutation"), "The returned object doesn't include the added path.");
            Assert.True(paths.Contains("Gender"), "The returned object doesn't include the added path.");
        }