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.
 
 
 
 
 

47 lines
1.3 KiB

// ==========================================================================
// 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<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);
}
}
}