public void ShouldReturnNoSpecimenForNullSpecimenContext( [Frozen] Mock <IRequestSpecification> optionsSpecification) { var optionsType = typeof(DbContextOptions <TestDbContext>); var options = new DbContextOptions <TestDbContext>(); var builder = new DelegatingDbContextOptionsBuilder(optionsSpecification.Object) { BuildOptions = _ => options }; optionsSpecification .Setup(x => x.IsSatisfiedBy(It.Is <Type>(x => x == optionsType))) .Returns(true); Action act = () => builder.Create(typeof(DbContextOptions <TestDbContext>), default); act.Should().ThrowExactly <ArgumentNullException>(); }
public void ShouldReturnNoSpecimenForNonOptionsRequestt( object request, Mock <ISpecimenContext> contextMock, [Frozen] Mock <IRequestSpecification> optionsSpecification) { var optionsType = typeof(DbContextOptions <TestDbContext>); var options = new DbContextOptions <TestDbContext>(); var builder = new DelegatingDbContextOptionsBuilder(optionsSpecification.Object) { BuildOptions = _ => options }; optionsSpecification .Setup(x => x.IsSatisfiedBy(It.Is <Type>(x => x == optionsType))) .Returns(true); var actual = builder.Create(request, contextMock.Object); actual.Should().BeOfType <NoSpecimen>(); }
public void ShouldCreateDbContext( Mock <ISpecimenContext> contextMock, [Frozen] Mock <IRequestSpecification> optionsSpecification) { var optionsType = typeof(DbContextOptions <TestDbContext>); var options = new DbContextOptions <TestDbContext>(); var builder = new DelegatingDbContextOptionsBuilder(optionsSpecification.Object) { BuildOptions = _ => options }; optionsSpecification .Setup(x => x.IsSatisfiedBy(It.Is <Type>(x => x == optionsType))) .Returns(true); var actual = builder.Create(typeof(DbContextOptions <TestDbContext>), contextMock.Object); actual.Should().NotBeNull() .And.Subject.Should().BeOfType(optionsType); }