本文整理汇总了C#中Fixture.AddManyTo方法的典型用法代码示例。如果您正苦于以下问题:C# Fixture.AddManyTo方法的具体用法?C# Fixture.AddManyTo怎么用?C# Fixture.AddManyTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fixture
的用法示例。
在下文中一共展示了Fixture.AddManyTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Should_use_messagechannel_from_modulecatalog_when_started
public void Should_use_messagechannel_from_modulecatalog_when_started()
{
var fixture = new Fixture().Customize(new TestConventions());
var catalog = fixture.Freeze<DriverCatalog>();
fixture.AddManyTo(catalog.MessageStores, 1);
fixture.AddManyTo(catalog.MessageChannels, 1);
var sut = fixture.CreateAnonymous<HaywireServer>();
sut.Start();
Assert.AreEqual(catalog.MessageChannels.Single(), sut.MessageChannel);
}
示例2: Should_have_same_messagequeue_as_messagestore_when_started
public void Should_have_same_messagequeue_as_messagestore_when_started()
{
var fixture = new Fixture().Customize(new TestConventions());
var catalog = fixture.Freeze<DriverCatalog>();
fixture.AddManyTo(catalog.MessageStores, 1);
fixture.AddManyTo(catalog.MessageChannels, 1);
List<string> ids = fixture.CreateMany<string>(1).ToList();
A.CallTo(() => catalog.MessageStores.Single().GetQueues()).Returns(ids);
var sut = fixture.CreateAnonymous<HaywireServer>();
sut.Start();
Assert.AreEqual(ids.First(), sut.MessageQueues[0].Id);
}
示例3: PopulateListAfterCreation
public void PopulateListAfterCreation()
{
var fixture = new Fixture();
var list = fixture.CreateAnonymous<List<int>>();
fixture.AddManyTo(list);
Assert.True(list.Any());
}
示例4: AddManyInstancesToList
public void AddManyInstancesToList()
{
Fixture fixture = new Fixture();
var list = new List<MyClass>();
fixture.AddManyTo(list);
Assert.True(list.Count > 1, "Multiple instances");
}
示例5: AddManyInstancesUsingCustomCreator
public void AddManyInstancesUsingCustomCreator()
{
Fixture fixture = new Fixture();
var list = new List<int>();
var r = new Random();
fixture.AddManyTo(list, () => r.Next());
Assert.True(list.Count > 1, "Multiple instances");
}
示例6: AddAnExplicitNumberOfInstancesToList
public void AddAnExplicitNumberOfInstancesToList()
{
Fixture fixture = new Fixture();
var list = new List<MyClass>();
fixture.RepeatCount = 7;
fixture.AddManyTo(list);
Assert.Equal<int>(fixture.RepeatCount, list.Count);
}
示例7: CreateAnonymousOrderAndThenAddOrderLines
public void CreateAnonymousOrderAndThenAddOrderLines()
{
// Fixture setup
var fixture = new Fixture();
// Exercise system
var order = fixture.CreateAnonymous<Order>();
fixture.AddManyTo(order.OrderLines);
Assert.Equal<int>(fixture.RepeatCount, order.OrderLines.Count);
// Teardown
}
示例8: AddManyWillAddItemsToCollection
public void AddManyWillAddItemsToCollection()
{
// Fixture setup
Fixture sut = new Fixture();
int expectedCount = sut.RepeatCount;
ICollection<int> collection = new LinkedList<int>();
// Exercise system
sut.AddManyTo(collection);
// Verify outcome
Assert.Equal<int>(expectedCount, collection.Count);
// Teardown
}
示例9: BuildOrderWithManyOrderLines
public void BuildOrderWithManyOrderLines()
{
// Fixture setup
var fixture = new Fixture();
// Exercise system
var order = fixture.Build<Order>()
.Do(o => fixture.AddManyTo(o.OrderLines))
.CreateAnonymous();
// Verify outcome
Assert.Equal<int>(fixture.RepeatCount, order.OrderLines.Count);
// Teardown
}
示例10: AddManyWillAddItemsToListUsingCreator
public void AddManyWillAddItemsToListUsingCreator()
{
// Fixture setup
Fixture sut = new Fixture();
IEnumerable<int> expectedList = Enumerable.Range(1, sut.RepeatCount);
List<int> list = new List<int>();
// Exercise system
int i = 0;
sut.AddManyTo(list, () => ++i);
// Verify outcome
Assert.True(expectedList.SequenceEqual(list));
// Teardown
}
示例11: AddManyWillAddItemsToListUsingAnonymousCreator
public void AddManyWillAddItemsToListUsingAnonymousCreator()
{
// Fixture setup
Fixture sut = new Fixture();
int expectedItemCount = sut.RepeatCount;
List<string> list = new List<string>();
// Exercise system
sut.AddManyTo(list);
// Verify outcome
int result = (from s in list
where !string.IsNullOrEmpty(s)
select s).Count();
Assert.Equal<int>(expectedItemCount, result);
// Teardown
}
示例12: TotalIsCorrect
public void TotalIsCorrect()
{
// Fixture setup
var fixture = new Fixture().Customize(new AutoMoqCustomization());
var basket = fixture.Freeze<Basket>();
fixture.AddManyTo(basket.Contents);
var sut = fixture.Build<BasketView>().OmitAutoProperties().CreateAnonymous();
// Exercise system
decimal result = sut.Total;
// Verify outcome
var expectedResult = (from e in basket.Contents
select e.Total.Amount).Sum();
Assert.Equal(expectedResult, result);
// Teardown
}
示例13: Main
static void Main(string[] args)
{
// 01. Pierwszy fixture
Fixture fixture = new Fixture();
var person = fixture.Create<Person>();
Console.WriteLine(person);
// 02. Wygenerowanie listy obiektów
List<Person> list = new List<Person>(50);
for (int i = 0; i < 50; i++)
{
list.Add(fixture.Create<Person>());
}
// 03. Automatyczne wygenerowanie listy obiektów przez AutoFixture
int count = 50;
fixture.RepeatCount = 50;
List<Person> list2 = new List<Person>(count);
fixture.AddManyTo(list2);
Console.ReadKey(true);
}
示例14: UpdatedIsCorrect
public void UpdatedIsCorrect()
{
// Fixture setup
var fixture = new Fixture().Customize(new AutoMoqCustomization());
var sut = fixture.CreateAnonymous<Basket>();
fixture.AddManyTo(sut.Contents);
// Exercise system
DateTimeOffset result = sut.Updated;
// Verify outcome
var expectedUpdate = (from e in sut.Contents
select e.Updated).Max();
Assert.Equal(expectedUpdate, result);
// Teardown
}
示例15: AutoFixture_CreateMany
public void AutoFixture_CreateMany()
{
Fixture fixture = new Fixture();
List<FileParameterDescriptor> list1 = new List<FileParameterDescriptor>();
fixture.AddManyTo(list1, 10);
//DEMO show list of items by OzCode
Assert.That(list1.Count, Is.EqualTo(10));
List<IParameterDescriptor> list2 = new List<IParameterDescriptor>();
//DEMO fixture.Register<IParameterDescriptor>(fixture.Create<FileParameterDescriptor>);
fixture.AddManyTo(list2, 10);
Assert.That(list2.Count, Is.EqualTo(10));
}