コード例 #1
0
        /// <summary>
        ///     Maps the domain entity to the event store entity.
        /// </summary>
        /// <remarks>
        ///     This method should map the entity keys only. The events are handled automatically.
        /// </remarks>
        /// <param name="domainEntity">
        ///     The domain entity to be mapped.
        /// </param>
        /// <param name="eventStoreEntity">
        ///     The event store entity to be initialized after the domain entity.
        /// </param>
        protected virtual void MapEventStoreEntity(TDomainEntity domainEntity, TEventStoreEntity eventStoreEntity)
        {
            Check.NotNull(domainEntity, nameof(domainEntity));
            Check.NotNull(eventStoreEntity, nameof(eventStoreEntity));

            PropertiesMapper.Map(domainEntity, eventStoreEntity);
        }
コード例 #2
0
        public void Map_NonMatchingNames_PropertiesValuesNotCopied()
        {
            var source = new { Key = 123, Price = 13.5 };
            var dest   = new Book();

            Action act = () => PropertiesMapper.Map(source, dest);

            act.Should().NotThrow();
        }
コード例 #3
0
        public void Map_PrefixedNames_PropertiesValuesCopied()
        {
            var source = new { EntityId = 123, BookTitle = "Silverback for Dummies" };
            var dest   = new Book();

            PropertiesMapper.Map(source, dest);

            dest.Id.Should().Be(123);
            dest.Title.Should().Be("Silverback for Dummies");
        }
コード例 #4
0
        public void Map_MatchingNames_PropertiesValuesCopied()
        {
            var source = new { Id = 123, Title = "Silverback for Dummies", Published = DateTime.Today, Pages = 13 };
            var dest   = new Book();

            PropertiesMapper.Map(source, dest);

            dest.Id.Should().Be(123);
            dest.Title.Should().Be("Silverback for Dummies");
            dest.Published.Should().Be(DateTime.Today);
            dest.Pages.Should().Be(13);
        }