本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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();
}