Headless CMS and Content Managment Hub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

42 lines
1.0 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Autofac;
using PinkParrot.Infrastructure.CQRS.Events;
using Xunit;
namespace PinkParrot.Infrastructure.CQRS.Autofac
{
public class AutofacDomainObjectFactoryTests
{
private sealed class DO : DomainObject
{
public DO(Guid id, int version) : base(id, version)
{
}
protected override void DispatchEvent(Envelope<IEvent> @event)
{
}
}
[Fact]
public void Should_create_domain_object_with_autofac()
{
var containerBuilder = new ContainerBuilder();
containerBuilder.RegisterType<DO>()
.AsSelf();
var factory = new AutofacDomainObjectFactory(containerBuilder.Build());
var id = Guid.NewGuid();
var domainObject = factory.CreateNew(typeof(DO), id);
Assert.Equal(id, domainObject.Id);
Assert.Equal(0, domainObject.Version);
}
}
}