public static DoctrinaDbContext Create()
        {
            var options = new DbContextOptionsBuilder <DoctrinaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var context = new DoctrinaDbContext(options);

            context.Database.EnsureCreated();

            var activityId = new Iri("http://www.example.com/activityId/hashset");

            context.Activities.Add(new ActivityEntity()
            {
                Id   = activityId.ToString(),
                Hash = activityId.ComputeHash()
            });

            context.Agents.AddRange(new AgentEntity[] {
                AgentsTestFixture.JamesCampbell(),
                AgentsTestFixture.JosephinaCampbell()
            });

            context.SaveChanges();

            return(context);
        }
Пример #2
0
        private async Task <ActivityProfileEntity> GetProfile(Iri activityId, string profileId, Guid?registration, CancellationToken cancellationToken)
        {
            string activityHash           = activityId.ComputeHash();
            ActivityProfileEntity profile = await _context.ActivityProfiles.FirstOrDefaultAsync(x =>
                                                                                                x.Activity.Hash == activityHash &&
                                                                                                x.ProfileId == profileId &&
                                                                                                x.RegistrationId == registration,
                                                                                                cancellationToken);

            return(profile);
        }