public void AnonymousTypesTest()
        {
            var v = new { Amount = 108, Message = "Hello" };

            // read only!
            // v.Amount = 110;

            Assert.AreEqual("<>f__AnonymousType0`2", v.GetType().Name, "2는 패러매터 숫자를 가리킨다");
            Assert.AreEqual("System.Object", v.GetType().BaseType.FullName, "object 상속");
        }
        public void ImplicitArrayAssignmentWithSameTypes()
        {
            //Even though we don't specify types explicitly, the compiler
            //will pick one for us
            var names = new[] { "John", "Smith" };
            Assert.AreEqual(typeof(FILL_ME_IN), names.GetType(), "Determine the type of the array elements to improve your Karma.");

            //but only if it can. So this doesn't work
            // (Try uncommenting the line below to see how the compiler reacts)
            //var array = new[] { "John", 1 };
        }
        public void GetMemberNames_AnonymousType_ReturnsMemberNamesInOrderDefined()
        {
            var anonymous = new { prop1 = "value1", prop2 = "value2" };
            var memberNames = FormatterUtils.GetMemberNames(anonymous.GetType());

            Assert.IsNotNull(memberNames);
            Assert.AreEqual(2, memberNames.Count);
            Assert.AreEqual("prop1", memberNames[0]);
            Assert.AreEqual("prop2", memberNames[1]);
        }
        public void IsSimpleType_ComplexTypes_ReturnsFalse()
        {
            var anonymous = new { prop = "val" };

            Assert.IsFalse(FormatterUtils.IsSimpleType(anonymous.GetType()));
            Assert.IsFalse(FormatterUtils.IsSimpleType(typeof(Array)));
            Assert.IsFalse(FormatterUtils.IsSimpleType(typeof(IEnumerable<>)));
            Assert.IsFalse(FormatterUtils.IsSimpleType(typeof(object)));
            Assert.IsFalse(FormatterUtils.IsSimpleType(typeof(SimpleTestItem)));
        }
        public void GetEnumerableItemType_ListOfAnonymousObject_ReturnsTestItemType()
        {
            var anonymous = new { prop1 = "value1", prop2 = "value2" };
            var anonymousList = new[] { anonymous }.ToList();

            var itemType = FormatterUtils.GetEnumerableItemType(anonymousList.GetType());

            Assert.IsNotNull(itemType);
            Assert.AreEqual(anonymous.GetType(), itemType);
        }
        public void GetMemberInfo_AnonymousType_ReturnsMemberInfoList()
        {
            var anonymous = new { prop1 = "value1", prop2 = "value2" };
            var memberInfo = FormatterUtils.GetMemberInfo(anonymous.GetType());

            Assert.IsNotNull(memberInfo);
            Assert.AreEqual(2, memberInfo.Count);
        }
        public void SortAndPaginateKeepsOriginalQueryableType()
        {
            var readCommand = new ReadCommandInfo
            {
                OrderByProperties = new[] { new OrderByProperty { Property = "Name", Descending = true } },
                Skip = 1,
                Top = 2,
            };

            IQueryable<object> query = new[] { "a", "b", "c", "d" }.AsQueryable().Select(name => new C { Name = name });
            Console.WriteLine(query.GetType());
            Assert.IsTrue(query is IQueryable<C>);

            var result = GenericFilterHelper.SortAndPaginate<object>(query, readCommand);
            Assert.AreEqual("c, b", TestUtility.Dump(result, item => ((C)item).Name));
            Console.WriteLine(result.GetType());
            Assert.IsTrue(result is IQueryable<C>);
        }