Beispiel #1
0
        public void UserCanPostToSubscribedGroup()
        {
            //            Mock<Group> mockGroup = new Mock<Group>();
            Post post = new Post() {Content = "Some stupid content", PostedDateTime = new DateTime(2010, 01, 01)};

            //            Group group = mockGroup.Object;
            Group group = new Group("test");

            //            mockGroup.Setup(foo => foo.post(post));
            //            mockGroup.Setup(foo => foo.Equals(It.IsAny<Group>())).Returns(true);

            LoginId loginid = new LoginId("*****@*****.**");
            string firstname = "firstName";
            string lastname = "lastName";
            Name name = new Name(firstname, lastname);

            User footballFan = new User(loginid, name);

            footballFan.Groups.Add(group);

            try
            {
                footballFan.PostToGroup(group, post);
            }
            catch (Exception ex)
            {
                Assert.Fail("Failed");
            }
        }
Beispiel #2
0
        public void UserCannotPostToUnsubscribedGroup()
        {
            Mock<Group> mockGroup = new Mock<Group>();
            Post post = new Post() {Content = "Some stupid content", PostedDateTime = new DateTime(2010, 01, 01)};

            Group group = mockGroup.Object;
            mockGroup.Setup(foo => foo.post(post));

            LoginId loginid = new LoginId("*****@*****.**");
            string firstname = "firstName";
            string lastname = "lastName";
            Name name = new Name(firstname, lastname);

            User footballFan = new User(loginid, name);

            try
            {
                footballFan.PostToGroup(group, post);
                Assert.Fail("Failed");
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #3
0
 public virtual void post(Post post1)
 {
     // throw new NotImplementedException();
 }
Beispiel #4
0
        public void InboxShouldShowBothCommentsAndMessagesInDescindingOrderOfDate()
        {
            var suchit = new User(new LoginId("*****@*****.**"), new Name("firstName1", "lastName1"));
            var vivek = new User(new LoginId("*****@*****.**"), new Name("firstName2", "lastName2"))
            {
                Profile = new Profile("This is the profile on which user1 will comment")
            };

            var commentOn5Oct = new Comment(suchit, vivek, "This is what I am going to comment", new GetInDate(new DateTime(2010,10,5)));
            var commentOn15Oct = new Comment(suchit, vivek, "This is a second comment", new GetInDate(new DateTime(2010,10,15)));

            var group = new Group("group1");
            var postOn8Oct = new Post { Content = "content 1 for group1", PostedDateTime = new DateTime(2010, 10, 8) };
            var postOn10Oct = new Post { Content = "content 2 for group1", PostedDateTime = new DateTime(2010, 10, 10) };
            var groupPosts = new GroupPosts
                                 {
                                     groupPostList = new List<Post>() {postOn8Oct, postOn10Oct}
                                 };
            group.MessageList = groupPosts;

            vivek.Groups.Add(group);
            vivek.PostToGroup(group,postOn8Oct);
            vivek.PostToGroup(group,postOn10Oct);

            Inbox inbox = vivek.GetInbox();
            Assert.AreEqual(4, inbox.TotalMessageCount());
            Assert.AreEqual(commentOn15Oct.Content, inbox.nextMessage().MessageContent);
            Assert.AreEqual(postOn10Oct.Content, inbox.nextMessage().MessageContent);
            Assert.AreEqual(postOn8Oct.Content, inbox.nextMessage().MessageContent);
            Assert.AreEqual(commentOn5Oct.Content, inbox.nextMessage().MessageContent);
        }
Beispiel #5
0
 public virtual void PostToGroup(Group group, Post post)
 {
     if (belongsToGroup(group)){
         group.post(post);
     }
     else{
         throw new UserHasNotSubscribedException();
     }
 }
Beispiel #6
0
 public Message(Post post)
 {
     MessageContent = post.Content;
     Type = "Post";
     Sender = null;
     SentOn = post.PostedDateTime;
 }