本文整理汇总了C#中Product.Load方法的典型用法代码示例。如果您正苦于以下问题:C# Product.Load方法的具体用法?C# Product.Load怎么用?C# Product.Load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Product
的用法示例。
在下文中一共展示了Product.Load方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WhenLoadingFromEventsForAggregateAndId_ThenStateIsUpdated
public void WhenLoadingFromEventsForAggregateAndId_ThenStateIsUpdated()
{
var product = new Product();
product.Load(store.Query().For<Product>(6));
Assert.Equal(6, product.Id);
Assert.Equal("WoVS", product.Title);
Assert.Equal(2, product.Version);
}
示例2: WhenFilteringByDateSince_ThenSucceeds
public void WhenFilteringByDateSince_ThenSucceeds()
{
var product = new Product();
product.Load(store.Query().For<Product>(6));
store.Save(product, new DeactivatedEvent(DateTime.Today.Subtract(TimeSpan.FromDays(7))));
store.Save(product, new DeactivatedEvent(DateTime.Today.Subtract(TimeSpan.FromDays(6))));
store.Save(product, new DeactivatedEvent(DateTime.Today.Subtract(TimeSpan.FromDays(5))));
store.Save(product, new DeactivatedEvent(DateTime.Today.Subtract(TimeSpan.FromDays(4))));
var events = store.Query().OfType<DeactivatedEvent>().Since(DateTime.Today.Subtract(TimeSpan.FromDays(5)));
Assert.Equal(2, events.Count());
}
示例3: WhenEventPersisted_ThenCanObserveIt
public void WhenEventPersisted_ThenCanObserveIt()
{
var store = new MemoryEventStore<int>();
var product = new Product(5, "DevStore");
product.Publish(1);
product.Publish(2);
product.Publish(3);
product.GetChanges().ToList()
.ForEach(e => store.Save(product, e));
product = new Product(6, "WoVS");
product.Publish(1);
product.Publish(2);
product.GetChanges().ToList()
.ForEach(e => store.Save(product, e));
var product2 = new Product();
product2.Load(store.Query().For<Product>(6));
Assert.Equal(product.Id, product2.Id);
Assert.Equal(product.Version, product2.Version);
var events = store.Query().For<Product>(5).OfType<Product.PublishedEvent>();
Assert.Equal(3, events.Count());
Console.WriteLine("For product 5, of type published:");
foreach (var e in events)
{
Console.WriteLine("\t" + e);
}
events = store.Query().For<Product>().OfType<Product.PublishedEvent>();
Assert.Equal(5, events.Count());
Console.WriteLine();
Console.WriteLine("For all products, of type published:");
foreach (var e in events)
{
Console.WriteLine("\t" + e);
}
events = store.Query().For<Product>();
Assert.Equal(7, events.Count());
Console.WriteLine();
Console.WriteLine("For all products, all event types:");
foreach (var e in events)
{
Console.WriteLine("\t" + e);
}
events = store.Query().OfType<Product.CreatedEvent>();
Assert.Equal(2, events.Count());
Console.WriteLine();
Console.WriteLine("Products created events:");
foreach (var e in events)
{
Console.WriteLine("\t" + e);
}
//product.Load(store.Events.For<Product>(23));
//var player = new DomainEventPlayer(store);
//player.Observe<ProductPublishedEvent>();
//player.Replay(from: null, to: null);
//store.Events.Where(
//store.Events.Where(x => x.AggregateType == "Product" &&
// x.EventType == "Published");
}