Пример #1
0
        /// <summary>
        ///   Build database with a name based on the calling Method.
        /// </summary>
        /// <param name="testFile">
        /// The path to the test class.
        /// Used to make the database name unique per test type.
        /// </param>
        /// <param name="databaseSuffix">
        /// For Xunit theories add some text based on the inline data
        /// to make the db name unique.
        /// </param>
        /// <param name="memberName">
        /// Used to make the db name unique per method.
        /// Will default to the caller method name is used.
        /// </param>
        public Task <SqlDatabase> Build(
            [CallerFilePath] string testFile     = "",
            string?databaseSuffix                = null,
            [CallerMemberName] string memberName = "")
        #endregion
        {
            Guard.AgainstNullWhiteSpace(nameof(testFile), testFile);
            Guard.AgainstNullWhiteSpace(nameof(memberName), memberName);
            Guard.AgainstWhiteSpace(nameof(databaseSuffix), databaseSuffix);

            var testClass = Path.GetFileNameWithoutExtension(testFile);

            var name = DbNamer.DeriveDbName(databaseSuffix, memberName, testClass);

            return(Build(name));
        }
Пример #2
0
        /// <summary>
        ///   Build DB with a name based on the calling Method.
        /// </summary>
        /// <param name="data">The seed data.</param>
        /// <param name="testFile">The path to the test class. Used to make the db name unique per test type.</param>
        /// <param name="databaseSuffix">For Xunit theories add some text based on the inline data to make the db name unique.</param>
        /// <param name="memberName">Used to make the db name unique per method. Will default to the caller method name is used.</param>
        public Task <SqlDatabase <TDbContext> > Build(
            IEnumerable <object>?data,
            [CallerFilePath] string testFile     = "",
            string?databaseSuffix                = null,
            [CallerMemberName] string memberName = "")
        {
            Guard.AgainstNullWhiteSpace(nameof(testFile), testFile);
            Guard.AgainstNullWhiteSpace(nameof(memberName), memberName);
            Guard.AgainstWhiteSpace(nameof(databaseSuffix), databaseSuffix);

            var testClass = Path.GetFileNameWithoutExtension(testFile);

            var dbName = DbNamer.DeriveDbName(databaseSuffix, memberName, testClass);

            return(Build(dbName, data));
        }