Ejemplo n.º 1
0
        public void CreateDiscussionThreadInvalidChild()
        {
            ManagedAccount        a  = new ManagedAccount(Session);
            ManagedDiscussion     d1 = new ManagedDiscussion(Session);
            ManagedDiscussion     d2 = new ManagedDiscussion(Session);
            ManagedDiscussionPost p  = new ManagedDiscussionPost(Session);

            try
            {
                a.Create("Test User", "testpassword", "*****@*****.**", DateTime.UtcNow, AdminSecurityContext);
                a.VerifyAllEmails();
                a.AddDefaultPicture();

                TransitDiscussion t_d = new TransitDiscussion();
                t_d.Description = GetNewString();
                t_d.Name        = GetNewString();
                t_d.Personal    = false;
                d1.CreateOrUpdate(t_d, a.GetSecurityContext());

                t_d.Name = GetNewString();
                d2.CreateOrUpdate(t_d, a.GetSecurityContext());

                TransitDiscussionPost t_p = new TransitDiscussionPost();
                t_p.Subject      = GetNewString();
                t_p.Body         = GetNewString();
                t_p.DiscussionId = d1.Id;

                int id1 = p.CreateOrUpdate(t_p, a.GetSecurityContext());
                Assert.AreNotEqual(0, id1);

                t_p.DiscussionId = d2.Id;
                int id2 = p.CreateOrUpdate(t_p, a.GetSecurityContext());
                Assert.AreNotEqual(0, id2);

                // can't create child of other discussion
                t_p.DiscussionId           = d1.Id;
                t_p.DiscussionPostParentId = id2;
                int id3 = p.CreateOrUpdate(t_p, a.GetSecurityContext());

                Session.Flush();
            }
            finally
            {
                d1.Delete(AdminSecurityContext);
                d2.Delete(AdminSecurityContext);
                a.Delete(AdminSecurityContext);
            }
        }
Ejemplo n.º 2
0
        public void CreateDiscussionThread()
        {
            ManagedAccount        a = new ManagedAccount(Session);
            ManagedDiscussion     d = new ManagedDiscussion(Session);
            ManagedDiscussionPost p = new ManagedDiscussionPost(Session);

            try
            {
                a.Create("Test User", "testpassword", "*****@*****.**", DateTime.UtcNow, AdminSecurityContext);
                a.VerifyAllEmails();
                a.AddDefaultPicture();

                TransitDiscussion t_d = new TransitDiscussion();
                t_d.Description = GetNewString();
                t_d.Name        = GetNewString();
                t_d.Personal    = false;
                d.CreateOrUpdate(t_d, a.GetSecurityContext());

                TransitDiscussionPost t_p = new TransitDiscussionPost();
                t_p.Subject      = GetNewString();
                t_p.Body         = GetNewString();
                t_p.DiscussionId = d.Id;
                p.CreateOrUpdate(t_p, a.GetSecurityContext());

                Session.Flush();
            }
            finally
            {
                p.Delete(a.GetSecurityContext());
                d.Delete(a.GetSecurityContext());
                a.Delete(a.GetSecurityContext());
            }
        }