PageRenderTime 5ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/Source/Samples/Blog/Bifrost.Samples.Blog.Views.Specs/Posts/for_PostStatisticsService/given/five_posts_for_january_2011.cs

#
C# | 33 lines | 29 code | 4 blank | 0 comment | 1 complexity | 04e2137184c59a9a7e93b22127e41be0 MD5 | raw file
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4using Bifrost.Samples.Blog.Views.Posts;
 5using Machine.Specifications;
 6
 7namespace Bifrost.Samples.Blog.Views.Specs.Posts.for_PostStatisticsService.given
 8{
 9    public class five_posts_for_january_2011 : a_post_statistics_service
10    {
11        protected static List<Post> posts;
12        protected static PostsByYear posts_by_year;
13        protected static int year = 2011;
14        protected static int month = 1;
15
16        Establish context = () =>
17                                        {
18                                            posts = new List<Post>()
19                                                        {
20                                                            new Post() {Id = Guid.NewGuid(), PublishDate = new DateTime(year,1,1)},
21                                                            new Post() {Id = Guid.NewGuid(), PublishDate = new DateTime(year,1,1)},
22                                                            new Post() {Id = Guid.NewGuid(), PublishDate = new DateTime(year,1,1)},
23                                                            new Post() {Id = Guid.NewGuid(), PublishDate = new DateTime(year,1,1)},
24                                                            new Post() {Id = Guid.NewGuid(), PublishDate = new DateTime(year,1,1)}
25                                                        };
26
27                                            posts_by_year = new PostsByYear() { January = posts.Where(p => p.PublishDate.Month == 1).Count(), Year = year};
28
29                                            posts_by_year_entity_context.Populate(new[] {posts_by_year});
30                                            posts_entity_context.Populate(posts);
31                                        };
32    }
33}