Beispiel #1
0
        public bool AddContent(PagesModel pagecontent)
        {
            var objpages = new Page
            {
                MetaKeywords = pagecontent.MetaKeywords,
                ModifiedDate = DateTime.Now,
                CreateDate   = DateTime.Now,
                Tittle       = pagecontent.Tittle,
                Description  = pagecontent.Description,
                PageCotent   = pagecontent.PageCotent,
                IsActive     = true
            };

            if (pagecontent.Id != 0)
            {
                objpages.Id = pagecontent.Id;
                return(_objRepository.UpdateContent(objpages));
            }

            return(_objRepository.AddContent(objpages));
        }
        public async Task TestFor_AddContent()
        {
            //Arrange
            //mocking
            _ContentMockCollection.Setup(op => op.InsertOneAsync(_content, null,
                                                                 default(CancellationToken))).Returns(Task.CompletedTask);
            _mockContext.Setup(c => c.GetCollection <Content>(typeof(Content).Name)).Returns(_ContentMockCollection.Object);

            //Craetion of new Db
            _mockOptions.Setup(s => s.Value).Returns(settings);
            var context  = new MongoUserDBContext(_mockOptions.Object);
            var userRepo = new UserRepository(context);
            //mocking


            //Act
            var updated = userRepo.AddContent(contentslist, _user.Id);
            var result  = await userRepo.GetAllContent(_user.Id, contentslist);

            //Assert
            Assert.NotNull(result);
        }