public void Save_EventSummary_ValuesIncrement()
{
EventMapper eventMapper = new EventMapper(this.client, this.database);
Guid applicationId = Guid.NewGuid();
Guid deviceId = Guid.NewGuid();
EventSummary expected = new EventSummary()
{
ApplicationId = applicationId,
Count = 2,
Date = date,
PlatformId = platform,
Version = version,
ScreenEvents = new List<EventAggregate>()
{
new EventAggregate("someScreen", "someEvent")
{
Count = 2
}
}
};
Event eventItem = new Event()
{
ApplicationId = applicationId,
Date = date,
Version = version,
PlatformId = platform,
DateCreatedOnDevice = dateCreatedOnDevice,
ScreenName = "someScreen",
EventName = "someEvent",
DeviceId = deviceId,
DateCreated = date
};
EventSummary summary = new EventSummary(eventItem);
eventMapper.Save(summary);
eventMapper.Save(summary);
IMongoQuery query = Query.And
(
Query<AppUsageSummary>.EQ<DateTime>(mem => mem.Date, date),
Query<AppUsageSummary>.EQ<Guid>(mem => mem.ApplicationId, applicationId),
Query<AppUsageSummary>.EQ<string>(mem => mem.Version, version),
Query<AppUsageSummary>.EQ<PlatformType>(mem => mem.PlatformId, platform)
);
EventSummary actual = this.GetCollection<EventSummary>().FindOne(query);
actual.ShouldHave().AllPropertiesBut(x => x.Id)
.IncludingNestedObjects().EqualTo(expected);
}