예제 #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");
            }
        }
예제 #2
0
 public void ShouldBeAbleToCreateGroup()
 {
     var group = new Group("test");
     groupRepository.Create(group);
     session.Evict(group);
     Assert.True(group.Id > 0);
     Assert.True(groupRepository.Exists(group));
 }
예제 #3
0
파일: Group.cs 프로젝트: bagheera/getin
 public GroupAlreadyExistsException(Group group)
     : base(string.Format("Group {0} already exists.", group.Name))
 {
 }
예제 #4
0
파일: Group.cs 프로젝트: bagheera/getin
 public virtual bool Equals(Group other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return other.Id == Id;
 }
예제 #5
0
 public void MembershipIsUpdatedWhenUserJoinsGroup()
 {
     int before = session.CreateSQLQuery("select * from GroupMembershipTable").List().Count;
     Group group = new Group("test");
     user1.CreateGroup(group);
     session.Flush();
     session.Evict(group);
     int after = session.CreateSQLQuery("select * from GroupMembershipTable").List().Count;
     Assert.AreEqual(before + 1, after);
 }
예제 #6
0
파일: UserTest.cs 프로젝트: bagheera/getin
 public void UserShouldBeAbleToJoinGroup()
 {
     User user = new User(new LoginId("123"), null);
     Group group = new Group("Nature-Lovers");
     user.Join(group);
     Assert.AreEqual(1, user.Groups.Count());
     Assert.True(user.Groups.Contains(group));
 }
예제 #7
0
파일: UserTest.cs 프로젝트: bagheera/getin
        public void ShouldNotBeAbleToCreateGroupIfAlreadyExists()
        {
            User user = new User(new LoginId("123"), null);
            Group group = new Group() {Name = "Nature-Lovers"};
            var repositoryMock = new Moq.Mock<IGroupRepository>();
            user.GroupRepository = repositoryMock.Object;
            repositoryMock.Setup(p => p.Exists(group)).Returns(true);

            try{
                user.CreateGroup(group);
                Assert.Fail("exception expected");
            }
            catch (GroupAlreadyExistsException){
            }

            repositoryMock.VerifyAll();
        }
예제 #8
0
파일: UserTest.cs 프로젝트: bagheera/getin
 public void ShouldBeAbleToCreateAGroup()
 {
     User user = new User(new LoginId("123"), null);
     Group group = new Group {Name = "Nature-Lovers"};
     var repositoryMock = new Mock<IGroupRepository>();
     repositoryMock.Setup(rep => rep.Exists(group)).Returns(false);
     repositoryMock.Setup(rep => rep.Create(group));
     user.GroupRepository = repositoryMock.Object;
     user.CreateGroup(group);
     repositoryMock.VerifyAll();
 }
예제 #9
0
파일: UserTest.cs 프로젝트: bagheera/getin
 public void ShouldAutomaticallyJoinAGroupUponCreatingIt()
 {
     User user = new User(new LoginId("123"), null);
     Group group = new Group { Name = "Nature-Lovers" };
     var repositoryMock = new Mock<IGroupRepository>();
     repositoryMock.Setup(rep => rep.Exists(It.IsAny<Group>())).Returns(false);
     repositoryMock.Setup(rep => rep.Create(group));
     user.GroupRepository = repositoryMock.Object;
     user.CreateGroup(group);
     Assert.AreEqual(group, user.Groups.First());
     repositoryMock.VerifyAll();
 }
예제 #10
0
파일: UserTest.cs 프로젝트: bagheera/getin
        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);
        }
예제 #11
0
 public bool Exists(Group group)
 {
     ICriteria criteria = Session.CreateCriteria(typeof (Group));
     criteria.Add(Restrictions.Eq("Name", group.Name));
     return criteria.List<Group>().Count != 0;
 }
예제 #12
0
 public void Create(Group group)
 {
     Session.Save(group);
 }
예제 #13
0
파일: User.cs 프로젝트: bagheera/getin
 public virtual void PostToGroup(Group group, Post post)
 {
     if (belongsToGroup(group)){
         group.post(post);
     }
     else{
         throw new UserHasNotSubscribedException();
     }
 }
예제 #14
0
파일: User.cs 프로젝트: bagheera/getin
 public virtual void Join(Group group)
 {
     if (!Groups.Contains(group)){
         Groups.Add(group);
     }
 }
예제 #15
0
파일: User.cs 프로젝트: bagheera/getin
 public virtual void CreateGroup(Group group)
 {
     var groupExists = GroupRepository.Exists(group);
     if (groupExists){
         throw new GroupAlreadyExistsException(group);
     }
     GroupRepository.Create(group);
     Join(group);
 }
예제 #16
0
파일: User.cs 프로젝트: bagheera/getin
 public virtual bool belongsToGroup(Group group)
 {
     return this.Groups.Contains(group);
 }