PageRenderTime 50ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/Source/Samples/Blog/Bifrost.Samples.Blog.Views.Specs/Posts/for_PostStatisticsService/when_updating_the_statistics_with_an_existing_post.cs

#
C# | 31 lines | 28 code | 3 blank | 0 comment | 1 complexity | 08b42aad6d6352cb266ccb1be6c9eb65 MD5 | raw file
Possible License(s): CC-BY-SA-3.0
  1. using System;
  2. using System.Linq;
  3. using Bifrost.Samples.Blog.Views.Posts;
  4. using Bifrost.Time;
  5. using Machine.Specifications;
  6. namespace Bifrost.Samples.Blog.Views.Specs.Posts.for_PostStatisticsService
  7. {
  8. public class when_updating_the_statistics_with_an_existing_post : given.five_posts_for_january_2011
  9. {
  10. static PostsByYear postsByYear;
  11. static Guid IdOfExistingPost;
  12. Because of = () =>
  13. {
  14. IdOfExistingPost = posts_entity_context.Entities.First().Id;
  15. post_statistics_service.AggregateForMonth(year, month, IdOfExistingPost);
  16. postsByYear = posts_by_year_entity_context.Entities.First();
  17. };
  18. It should_update_the_posts_in_january_2011_to_5 = () =>
  19. {
  20. posts_by_year_entity_context.Entities.Count().ShouldEqual(1);
  21. postsByYear.January.ShouldEqual(5);
  22. foreach (var post in postsByYear.Counts.Where(c => c.Key != Month.January))
  23. {
  24. post.Value.ShouldEqual(0);
  25. }
  26. };
  27. }
  28. }