Пример #1
0
        public void ApplicationCanCreateRuntimeTypeForValidType()
        {
            // arrange
            var type = typeof(Aggregate);

            var typeAnalyzerService = A.Fake<ITypeAnalyzerService>(o => o.Strict());
            A.CallTo(() => typeAnalyzerService.IsValidAggregateRoot(type)).Returns(true);
            A.CallTo(() => typeAnalyzerService.IsValidEntity(type)).Returns(true);
            A.CallTo(() => typeAnalyzerService.GetNaturalKey(type)).Returns(null);
            A.CallTo(() => typeAnalyzerService.IsValidAggregateRoot(typeof(AggregateRoot))).Returns(true);
            A.CallTo(() => typeAnalyzerService.IsValidEntity(typeof(AggregateRoot))).Returns(true);
            A.CallTo(() => typeAnalyzerService.GetNaturalKey(typeof(AggregateRoot))).Returns(null);
            A.CallTo(() => typeAnalyzerService.IsValidEntity(typeof(Entity))).Returns(true);
            A.CallTo(() => typeAnalyzerService.GetNaturalKey(typeof(Entity))).Returns(null);
            var entityType = new EntityType(typeof(Entity), typeAnalyzerService);
            var aggregateType = new AggregateRootType(typeof(AggregateRoot), typeAnalyzerService, entityType);
            var expectedType = new AggregateRootType(type, typeAnalyzerService, aggregateType);
            var factory = A.Fake<Func<Type, AggregateRootType>>(o => o.Strict());
            A.CallTo(() => factory.Invoke(type)).Returns(expectedType);

            using (new Application(factory, t => null, t => null))
            {
                // act
                var actualType = Application.Current.GetAggregateRootType(type);

                // assert
                actualType.Should().Be(expectedType);
            }
        }
            public TypeInformation(AggregateRootType aggregateRootType)
            {
                Guard.Against.Null(() => aggregateRootType);

                this.EventDispatcher = aggregateRootType.EventDispatcher;
                this.PersistEvents = aggregateRootType.PersistEvents;
            }