本文整理汇总了C#中Fixture.First方法的典型用法代码示例。如果您正苦于以下问题:C# Fixture.First方法的具体用法?C# Fixture.First怎么用?C# Fixture.First使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fixture
的用法示例。
在下文中一共展示了Fixture.First方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShallRemoveDevicesWithFilter
public async Task ShallRemoveDevicesWithFilter()
{
//arrange
var devicesGenerator = new Fixture().Create<Generator<Device>>();
fixture.Customize<Device>(c => c.Without(x => x.State));
fixture.Customize<IEnumerable<Device>>(
c =>
c.FromFactory(
() => Enum.GetValues(typeof(DeviceState)).Cast<DeviceState>()
.Select(s => devicesGenerator.First(u => u.State == s))));
var devices = fixture.Create<IEnumerable<Device>>(); // returns devices with all supported states
Expression<Func<Device, bool>> disabledDevicesFilter
= x => x.State == DeviceState.Disabled;
using (var db = this.dbFactory.Open())
{
foreach (var device in devices)
{
db.Insert(device);
}
var totalCount = await db.CountAsync<Device>();
Assert.AreEqual(devices.Count(), totalCount);
//act
var removedCount = await this.cut.DeleteAsync(disabledDevicesFilter);
//assert
Assert.AreEqual(1, removedCount);
var remainingDevices = db.Select<Device>();
Assert.IsFalse(remainingDevices
.Any(x => x.State == DeviceState.Disabled));
}
}