public void EnsureNotNull_WithNullObject_ShouldReturnExceptionMessage()
        {
            // Arrange && Act && Assert
            var exception = Assert.Throws <ArgumentNullException>(() => CoreValidator.EnsureNotNull(null, "Null message"));

            Assert.Contains("Null message", exception.Message);
        }
        /// <summary>
        /// Add new course to the database.
        /// </summary>
        /// <typeparam name="TModel">Course model.</typeparam>
        /// <param name="model">Course for adding.</param>
        /// <returns>Return the mapped course.</returns>
        public async Task <Course> AddCourseAsync <TModel>(TModel model)
        {
            CoreValidator.EnsureNotNull(model, AdminConstants.NullCourse);
            var course = this.mapper.Map <Course>(model);

            await this.context.AddAsync(course);

            return(course);
        }
Beispiel #3
0
        public async Task CreateArticleAsync <TModel>(TModel model, string authorId)
        {
            CoreValidator.EnsureNotNull(model, "The article is null");
            var article = this.mapper.Map <Article>(model);

            article.AuthorId    = authorId;
            article.PublishDate = DateTime.UtcNow;

            await this.repository.AddAsync(article);
        }
 public void EnsureNotNull_WithNullObject_ShouldReturnException()
 {
     // Arrange && Act && Assert
     Assert.Throws <ArgumentNullException>(() => CoreValidator.EnsureNotNull(null));
 }