Commits

Anonymous committed ba43a29

adding more mock objects to the testing context for future unit tests

Comments (0)

Files changed (1)

development/src/Tests/PostLogicTest.cs

         {
             _context = DataContextFactory.CreateContentContext(_isMock) as ContentModelContainerMock;
 
-            var myType = new PostType() { NumericCode = (short)PostTypes.Question };
+            #region User Profiles
 
-            _context.PostTypes.AddObject(myType);
+            //let's create some user profiles
+            var firstUser = new UserProfile() { Id = Guid.NewGuid(), DisplayName = "Test User", Reputation = 50 };
+            var secondUser = new UserProfile() { Id = Guid.NewGuid(), DisplayName = "Test User2", Reputation = 12345 };
+            _context.UserProfiles.AddObject(firstUser);
+            _context.UserProfiles.AddObject(secondUser);
 
-            var mypost = new Post() { Type = myType };
+            #endregion //User Profiles
 
-            _context.Posts.AddObject(mypost);
+            #region Post Types
+
+            //let's add the post types
+            var questionType = new PostType()
+            {
+                Id = Guid.NewGuid(),
+                NumericCode = (short)PostTypes.Question,
+            };
+
+            var answerType = new PostType()
+            {
+                Id = Guid.NewGuid(),
+                NumericCode = (short)PostTypes.Answer,
+            };
+
+            var commentType = new PostType()
+            {
+                Id = Guid.NewGuid(),
+                NumericCode = (short)PostTypes.Comment,
+            };
+
+            _context.PostTypes.AddObject(questionType);
+            _context.PostTypes.AddObject(answerType);
+            _context.PostTypes.AddObject(commentType);
+
+            #endregion //Post Types
+
+            #region Posts
+            //now let's create some posts by the user profiles
+            var firstPost = new Post()
+            {
+                Id = Guid.NewGuid(),
+                Author = firstUser,
+                Content = "test content in the first post",
+                Heading = "Why is this the first question?",
+                CreateDate = DateTime.Now,
+                Type = questionType,
+            };
+
+            var firstAnswer = new Post()
+            {
+                Id = Guid.NewGuid(),
+                Author = secondUser,
+                Content = "test content of the first answer to the first question",
+                Heading = "First!",
+                CreateDate = DateTime.Now,
+                Type = answerType,
+            };
+
+            _context.Posts.AddObject(firstPost);
+            _context.Posts.AddObject(firstAnswer);
+
+            #endregion //Posts
             
         }