/// <summary>
        /// Delete the User-Defined type if exists.
        /// If the UDT doesn't exists, the method skips the deletion.
        ///
        /// <para>Note: If the User-Defined type name is [Null || Empty] the method will take the generic type {TEntity} name.</para>
        /// </summary>
        ///
        /// <typeparam name="TEntity">The calss where the method should look for the properties and their types.</typeparam>
        /// <param name="self">The Cassandra Fluent Migrator.</param>
        /// <param name="name">The name of the udt (Optional).</param>
        /// <returns>The Cassandra Fluent Migrator helper.</returns>
        ///
        /// <exception cref="NullReferenceException">Thrown when one or all the specified arguments are invalid or null.</exception>
        public static async Task <ICassandraFluentMigrator> DeleteUserDefinedTypeAsync <TEntity>([NotNull] this ICassandraFluentMigrator self, [NotNull] string name = default)
            where TEntity : class
        {
            Check.NotNull(self, $"The argument [cassandra fluent migrator]");

            name = string.IsNullOrWhiteSpace(name) ? typeof(TEntity).Name.NormalizeString() : name.NormalizeString();

            if (!self.DoesUdtExists(name))
            {
                return(self);
            }

            return(await self.ExecuteDeleteUdtAsync <TEntity>(name));
        }
Ejemplo n.º 2
0
        public void DoesUdtExists_InvalidArguments_Faield()
        {
            try
            {
                this.cfmHelper.DoesUdtExists(null);
            }
            catch (NullReferenceException ex)
            {
                var expected = string.Format(INVALID_OR_EMPTY_ARGUMENT, "udt").ToLower();
                Assert.Contains(expected, ex.Message.ToLower());
            }

            try
            {
                ICassandraFluentMigrator tempHelper = null;
                tempHelper.DoesUdtExists(null);
            }
            catch (NullReferenceException ex)
            {
                Assert.Contains("Object reference not set to an instance of an object.".ToLower(), ex.Message.ToLower());
            }
        }