PageRenderTime 8ms CodeModel.GetById 2ms app.highlight 3ms 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
 1using System;
 2using System.Linq;
 3using Bifrost.Samples.Blog.Views.Posts;
 4using Bifrost.Time;
 5using Machine.Specifications;
 6
 7namespace Bifrost.Samples.Blog.Views.Specs.Posts.for_PostStatisticsService
 8{
 9    public class when_updating_the_statistics_with_an_existing_post : given.five_posts_for_january_2011
10    {
11        static PostsByYear postsByYear;
12        static Guid IdOfExistingPost;
13
14        Because of = () =>
15                         {
16                             IdOfExistingPost = posts_entity_context.Entities.First().Id;
17                             post_statistics_service.AggregateForMonth(year, month, IdOfExistingPost);
18                             postsByYear = posts_by_year_entity_context.Entities.First();
19                         };
20
21        It should_update_the_posts_in_january_2011_to_5 = () =>
22                                                              {
23                                                                  posts_by_year_entity_context.Entities.Count().ShouldEqual(1);
24                                                                  postsByYear.January.ShouldEqual(5);
25                                                                  foreach (var post in postsByYear.Counts.Where(c => c.Key != Month.January))
26                                                                  {
27                                                                      post.Value.ShouldEqual(0);
28                                                                  }
29                                                              };
30    }
31}