public void Check_ProjectionGetActivitiesByProject() { //given var descriptionText = "Given Description"; var projectId1 = 1u; var projectId2 = 2u; var activity1 = new ActivityProjection("created", string.Concat(descriptionText, " 01"), 1u, projectId1); var activity2 = new ActivityProjection("created", string.Concat(descriptionText, " 02"), 1u, projectId1); var activity3 = new ActivityProjection("created", descriptionText, 1u, projectId2); var connString = "Filename=:temp:;"; var activityDbContext = new ActivityProjectionDbContext(connString, BsonMapper.Global); var repActivity = new ActivityProjectionRepository(activityDbContext); using var acDbSession = new ProjectionDbSession <IActivityProjectionRepository>(activityDbContext, repActivity); acDbSession.Repository.Add(activity1); acDbSession.Repository.Add(activity2); acDbSession.Repository.Add(activity3); acDbSession.SaveChanges(); //when var handler = new GetActivitiesQueryHandler(acDbSession); var filter = GetActivitiesFilter.For(projectId2); var activities = handler.Execute(filter); //then Assert.True(activities.Items.AsQueryable().Count(i => i.ProjectId == projectId2) == 1); }
public void Check_ActivityProjection_Create() { //given var descriptionText = "Given Description"; var projectId = EntityId.From(1u); var activity = new ActivityProjection("created", descriptionText, 1u, 1u); var connString = "Filename=todoagility_projection.db;Connection=shared"; var activityDbContext = new ActivityProjectionDbContext(connString, BsonMapper.Global); var repActivity = new ActivityProjectionRepository(activityDbContext); using var pDbSession = new ProjectionDbSession <IActivityProjectionRepository>(activityDbContext, repActivity); pDbSession.Repository.Add(activity); pDbSession.SaveChanges(); //when var found = pDbSession.Repository.Get(projectId); //then Assert.Equal(activity.ActivityId, found.ActivityId); }