PageRenderTime 44ms CodeModel.GetById 18ms 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
Possible License(s): CC-BY-SA-3.0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Bifrost.Samples.Blog.Views.Posts;
  5. using Machine.Specifications;
  6. namespace Bifrost.Samples.Blog.Views.Specs.Posts.for_PostStatisticsService.given
  7. {
  8. public class five_posts_for_january_2011 : a_post_statistics_service
  9. {
  10. protected static List<Post> posts;
  11. protected static PostsByYear posts_by_year;
  12. protected static int year = 2011;
  13. protected static int month = 1;
  14. Establish context = () =>
  15. {
  16. posts = new List<Post>()
  17. {
  18. new Post() {Id = Guid.NewGuid(), PublishDate = new DateTime(year,1,1)},
  19. new Post() {Id = Guid.NewGuid(), PublishDate = new DateTime(year,1,1)},
  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. };
  24. posts_by_year = new PostsByYear() { January = posts.Where(p => p.PublishDate.Month == 1).Count(), Year = year};
  25. posts_by_year_entity_context.Populate(new[] {posts_by_year});
  26. posts_entity_context.Populate(posts);
  27. };
  28. }
  29. }