当前位置: 首页>>代码示例>>C#>>正文


C# NUnit.Framework.AsQueryable方法代码示例

本文整理汇总了C#中NUnit.Framework.AsQueryable方法的典型用法代码示例。如果您正苦于以下问题:C# NUnit.Framework.AsQueryable方法的具体用法?C# NUnit.Framework.AsQueryable怎么用?C# NUnit.Framework.AsQueryable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NUnit.Framework的用法示例。


在下文中一共展示了NUnit.Framework.AsQueryable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoginTest

        public void LoginTest()
        {

            const string userName = "user1";
            const string password = "password1";

            var dataAccess = Mock.Interface<IDataAccess>();

            var expectedUser = new User
            {
                    Email = userName,
                    Password = PasswordHash.HashPassword (password),
                    PhoneNumber = "000-000-0000",
            };

            var users = new [] { expectedUser };
            Expect.MethodCall( () => dataAccess.All<User>() ).Returns( users.AsQueryable() );

            var userService = new UserService(dataAccess);

            User actualUser;
            userService.Login(userName, password, out actualUser);

            Assert.IsTrue(actualUser == expectedUser);

        }
开发者ID:peymanmortazavi,项目名称:Hangout,代码行数:26,代码来源:UserServiceTests.cs

示例2: Can_map_custom_mapped_properties

        public void Can_map_custom_mapped_properties()
        {
            Mapper.Initialize(cfg => cfg.CreateMap<Source, Dest>().ForMember(d => d.Bar, opt => opt.MapFrom(src => src.Foo)));

            Expression<Func<Dest, bool>> expr = d => d.Bar == 10;

            var mapped = Mapper.Map<Expression<Func<Dest, bool>>, Expression<Func<Source, bool>>>(expr);

            var items = new[]
            {
                new Source {Foo = 10},
                new Source {Foo = 10},
                new Source {Foo = 15}
            };

            items.AsQueryable().Where(mapped).Count().ShouldBe(2);
        }
开发者ID:ouyh18,项目名称:LtePlatform,代码行数:17,代码来源:ExpressionConversion.cs

示例3: Can_map_flattened_properties

        public void Can_map_flattened_properties()
        {
            Mapper.Initialize(cfg => cfg.CreateMap<Source, Dest>());

            Expression<Func<Dest, bool>> expr = d => d.ChildValue == 10;

            var mapped = Mapper.Map<Expression<Func<Dest, bool>>, Expression<Func<Source, bool>>>(expr);

            var items = new[]
            {
                new Source {Child = new ChildSrc {Value = 10}},
                new Source {Child = new ChildSrc {Value = 10}},
                new Source {Child = new ChildSrc {Value = 15}}
            };

            items.AsQueryable().Where(mapped).Count().ShouldBe(2);
        }
开发者ID:ouyh18,项目名称:LtePlatform,代码行数:17,代码来源:ExpressionConversion.cs

示例4: DataContractJsonSerializerSerializesAggregates

        public void DataContractJsonSerializerSerializesAggregates()
        {
            using (var stream = new MemoryStream())
            {
                var serializer = new DataContractJsonSerializer(typeof(DataSourceResult), new [] { typeof (Person) });

                var people = new[] { new Person { Age = 30 }, new Person { Age = 30 } };

                serializer.WriteObject(stream, people.AsQueryable().ToDataSourceResult(1, 2, null, null, new [] { new Aggregator { 
                    Aggregate = "sum",
                    Field = "Age"
                } }));

                var json = Encoding.UTF8.GetString(stream.ToArray()).Replace("\"__type\":\"DynamicClass2:#\",", "");

                Assert.AreEqual("{\"Aggregates\":{\"Age\":{\"sum\":60}},\"Data\":[],\"Total\":2}", json);
            }
        }
开发者ID:UniticTelecom,项目名称:dlinq-helpers,代码行数:18,代码来源:SerializationTests.cs

示例5: Can_map_with_different_destination_types

        public void Can_map_with_different_destination_types()
        {
            Mapper.Initialize(cfg => cfg.CreateMap<Source, Dest>().ForMember(d => d.Bar, opt => opt.MapFrom(src => src.Foo)));

            Expression<Func<Dest, Dest>> expr = d => d;

            var mapped = Mapper.Map<Expression<Func<Dest, Dest>>, Expression<Func<Source, Source>>>(expr);

            var items = new[]
            {
                new Source {Foo = 10},
                new Source {Foo = 10},
                new Source {Foo = 15}
            };

            var items2 = items.AsQueryable().Select(mapped).ToList();
        }
开发者ID:ouyh18,项目名称:LtePlatform,代码行数:17,代码来源:ExpressionConversion.cs


注:本文中的NUnit.Framework.AsQueryable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。