Beispiel #1
0
        /// <summary>
        /// Create an entity. Not added to database.
        /// </summary>
        /// <returns>Return created entity.</returns>
        public virtual TEntity Create()
        {
            TEntity item = DbSet.Create();

            item.CreateDate = DateTime.Now;
            item.OnCreateCompleted();
            return(item);
        }
            public void With_derived_type_returns_non_null_object()
            {
                var internalContextMock = new Mock <InternalContextForMock>
                {
                    CallBase = true
                };

                internalContextMock.Setup(m => m.CreateObject <FakeDerivedEntity>()).Returns(new FakeDerivedEntity());

                var internalSetMock = new Mock <InternalSet <FakeEntity> >(internalContextMock.Object);

                internalSetMock.Setup(m => m.InternalContext).Returns(internalContextMock.Object);

                var set = new DbSet <FakeEntity>(internalSetMock.Object);

                Assert.IsType <FakeDerivedEntity>(set.Create <FakeDerivedEntity>());
            }
 public TEntity Create()
 {
     return(DbSet.Create());
 }