Beispiel #1
0
 public void AddTagTest()
 {
     Tag tag = new Tag();
     tag.TagName = "TestTag";
     tag.DisplayName = "测试";
     tag.NeedMoney = 100;
     tag.ConnString = "mongodb://localhost";
     tagService.AddTag(tag);
 }
Beispiel #2
0
        public void Can_Add_Tag()
        {
            // Arrange ..
            Tag tag = new Tag();
            tag.Title = "asp.net-mvc";
            tag.CreatedDate = DateTime.Now;
            tag.LastModifiedDate = DateTime.Now;

            // Act ..
            _tagRepository.Add(tag);

            // Assert ..
            Assert.Greater(tag.Id, 0);
        }
        /// <summary>
        /// Executes the default install.
        /// </summary>
        public void Execute()
        {
            if (isInitialized)
            {
                return;
            }

            var blog = blogRepository.GetBlog();
            if (blog != null)
            {
                isInitialized = true;
                return;
            }

            var user = new User
                       	{
                       		UserName = "******",
                       		Password = "******",
                       		Email = "*****@*****.**",
                       		ID = 1
                       	};

            blog = new Blog
                   	{
                   		ID = 1,
                   		Title = "BlogSharp Blogs",
                   		Writers = new List<User> {user},
                   		Founder = user,
                   		Configuration = new BlogConfiguration {PageSize = 10},
                   		Host = "localhost",
                   		Name = "BlogSharp",
                   	};

            var tag = new Tag {ID = 1, Name = "Welcome", FriendlyName = "welcome"};
            var title = "Welcome to BlogSharp!";
            var post = new Post
                       	{
                       		ID = 1,
                       		Blog = blog,
                       		Publisher = user,
                       		Tags = new List<Tag> {tag},
                       		Title = title,
                       		Content = "Great blog post is here you are.",
                       		FriendlyTitle = generator.GenerateUrl("{0}", title),
                       		DateCreated = DateTime.Now,
                       		DatePublished = DateTime.Now
                       	};
            tag.Posts.Add(post);
            blog.Configuration = new BlogConfiguration {PageSize = 10};
            blog.Posts.Add(post);
            userRepository.SaveUser(user);
            blogRepository.SaveBlog(blog);
            postRepository.SavePost(post);
            isInitialized = true;
        }
Beispiel #4
0
 public void AddTag(Tag tag)
 {
     tagConn.Insert(tag);
 }
        public void CanSaveAllEntities()
        {
            using (var session = factory.OpenSession())
            {
                using (var tran = session.BeginTransaction())
                {
                    var blog = new Blog();
                    var user = new User();
                    var post = new Post();
                    var tag = new Tag();
                    var postComment = new PostComment();

                    var configuration = new BlogConfiguration();
                    configuration.PageSize = 3;
                    configuration["osman"] = "mahmut";

                    user.UserName = "******";
                    user.Password = "******";
                    user.Email = "*****@*****.**";
                    user.Blogs.Add(blog);

                    blog.Configuration = configuration;
                    blog.Writers.Add(user);
                    blog.Title = "my blog";
                    blog.Name = "My Blog";
                    blog.Founder = user;
                    blog.Posts.Add(post);
                    blog.Host = "localhost";

                    post.Blog = blog;
                    post.Content = "hello";
                    post.Publisher = user;
                    post.DateCreated = DateTime.Now;
                    post.DatePublished = DateTime.Now.AddMinutes(3);
                    post.Title = "post title";
                    post.FriendlyTitle = post.Title.Replace(' ', '_').ToLower();
                    post.AddComment(postComment, null);

                    postComment.Post = post;
                    postComment.Date = DateTime.Now.AddMinutes(6);
                    postComment.Email = "*****@*****.**";
                    postComment.Name = "Some One";
                    postComment.Comment = "Some One wrote here!!";

                    tag.Name = "Tag";
                    tag.FriendlyName = "Tagged";
                    tag.Posts.Add(post);
                    post.Tags.Add(tag);

                    var blogVal = new BlogValidator();
                    blogVal.ValidateAndThrowException(blog);

                    var postVal = new PostValidator();
                    postVal.ValidateAndThrowException(post);

                    var postCommVal = new PostCommentValidator();
                    postCommVal.ValidateAndThrowException(postComment);

                    var userVal = new UserValidator();
                    userVal.ValidateAndThrowException(user);

                    var tagVal = new TagValidator();
                    tagVal.ValidateAndThrowException(tag);

                    session.Save(user);
                    session.Save(blog);
                    session.Save(post);
                    session.Save(postComment);
                    session.Save(tag);

                    tran.Commit();
                }
            }

            using (var session = factory.OpenSession())
            {
                var item = session.CreateCriteria(typeof (Blog)).UniqueResult<Blog>();
                var pageSize = item.Configuration.PageSize;
                Assert.That(pageSize, Is.EqualTo(3));
            }
        }