// ========================================================================== // AutofacDomainObjectFactoryTests.cs // Squidex Headless CMS // ========================================================================== // Copyright (c) Squidex Group // All rights reserved. // ========================================================================== using System; using Autofac; using Squidex.Infrastructure.CQRS.Events; using Xunit; namespace Squidex.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 @event) { } } [Fact] public void Should_create_domain_object_with_autofac() { var containerBuilder = new ContainerBuilder(); containerBuilder.RegisterType() .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); } } }