Example #1
0
    public SpeakerMeetRepositoryTestBase(ContextFixture fixture)
    {
        Context = fixture.Context;
        Context.Speakers.Add(new Speaker
        {
            Id          = Guid.NewGuid(),
            Name        = "Test Speaker 1",
            Slug        = "test-speaker-1",
            Location    = "Tampa, FL",
            Description = "Test Speaker 1 from Tampa, FL"
        });
        Context.Speakers.Add(new Speaker
        {
            Id          = Guid.NewGuid(),
            Name        = "Test Speaker 2",
            Slug        = "test-speaker-2",
            Location    = "Tampa, FL",
            Description = "Test Speaker 2 from Tampa, FL"
        });
        Context.Speakers.Add(new Speaker
        {
            Id          = Guid.NewGuid(),
            Name        = "Test Speaker 3",
            Slug        = "test-speaker-3",
            Location    = "Tampa, FL",
            Description = "Test Speaker 3 from Tampa, FL"
        });
        Context.SaveChanges();

        Repository = new SpeakerMeetRepository(Context);
    }
 private void InitializeDbForTests(SpeakerMeetContext db)
 {
     db.Speakers.RemoveRange(db.Speakers);
     db.Speakers.Add(new Speaker
     {
         Id          = Guid.NewGuid(),
         Name        = "Test Speaker",
         Slug        = "test-speaker",
         Location    = "Tampa, FL",
         Description = "Test Speaker from Tampa, FL"
     });
     db.SaveChanges();
 }
Example #3
0
        public Get()
        {
            _options = new DbContextOptionsBuilder <SpeakerMeetContext>()
                       .UseInMemoryDatabase(Guid.NewGuid().ToString())
                       .Options;

            using (var context = new SpeakerMeetContext(_options))
            {
                context.Speakers.Add(new Speaker {
                    Id = 1, Name = "Test", Location = "Location"
                });
                context.SaveChanges();
            }
        }
        public ContextFixture()
        {
            var options = new DbContextOptionsBuilder <SpeakerMeetContext>()
                          .UseInMemoryDatabase("SpeakerMeetContext")
                          .Options;

            Context = new SpeakerMeetContext(options);

            if (!Context.Speakers.Any())
            {
                Context.Speakers.Add(new Speaker {
                    Id = 1, Name = "Test", Location = "Location"
                });
                Context.SaveChanges();
            }
        }