コード例 #1
0
        public void AssertEntityUpdated <TEntity>(TEntity entity) where TEntity : Entity
        {
            // When are we running the assert - required to assert the times on
            // meta fields
            var when = DateTime.Now;

            Assert.IsNotNull(entity.DateModified, "The DateModified field on the entity must be set when updating entities");
            Assert.IsTrue(DateCompareUtilities.CompareWithinRange(when, entity.DateModified.Value), "The DateModified field must be set within a range of the current time when the test has run");
        }
コード例 #2
0
        /// <summary>
        /// Will run asserts on properties related to creation of entities
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="entity"></param>
        /// <param name="assertCreatedBy"></param>
        /// <param name="assertExactTimeCreated">Flag indicating if we want to assert the time created within a time range or just that the time created date is set</param>
        public void AssertEntityCreated <TEntity>(TEntity entity, bool assertCreatedBy = false, bool assertExactTimeCreated = true) where TEntity : Entity
        {
            // get the current date time used to run comparisons on date related meta fields
            var when = DateTime.Now;

            Assert.IsNotNull(entity.DateCreated, "The DateCreated Field on the entitiy must be set when creating entities");

            if (assertExactTimeCreated)
            {
                Assert.IsTrue(DateCompareUtilities.CompareWithinRange(when, entity.DateCreated.Value), "The DateCreated field must be set within a range of the current time when the test was run");
            }

            if (assertCreatedBy)
            {
                Assert.IsTrue(!string.IsNullOrWhiteSpace(entity.CreatedBy), "The CreatedBy field for the entitiy must be set");
            }

            Assert.IsNotNull(entity.Status, "The Status field for entities must be set when creating new entities");
            Assert.IsTrue(entity.Status.Value, "The Status field for newly created entities must be set to True");
        }