public void Given_NullParameter_Constructor_ShouldThrow_Exception() { var options = CreateDbContextOptions <FooContext>(); Action action = () => { var context = new FooContext(options, null); }; action.ShouldThrow <ArgumentNullException>(); }
public UnicornService(FooContextService contextService) { if (contextService == null) { throw new ArgumentNullException("contextService"); } _ctx = contextService.Context; }
public void Given_That_Map_ShouldBe_Called() { var options = CreateDbContextOptions <FooContext>(); using (var context = new FooContext(options, this._mapper.Object)) { context.Model.GetAnnotations(); } this._mapper.Verify(m => m.Map(It.IsAny <EntityTypeBuilder <Foo> >()), Times.Once); }
public void DisposeWorksCorrectly() { //Arrange DbConnection connection = Effort.DbConnectionFactory.CreateTransient(); var context = new FooContext(connection); var unitOfWork = new Ef6UnitOfWork(_context, IsolationLevel.Unspecified); var repository = new BaseRepository <Foo>(unitOfWork); //Act repository.Insert(new Foo { Id = Guid.NewGuid() }); unitOfWork.SaveChanges(); unitOfWork.Dispose(); //Assert }
public void Given_That_SetDefaultStringMaxLength_ShouldBe_Set() { IEntityType entityType; var options = CreateDbContextOptions <FooContext>(); using (var context = new FooContext(options, new FooMapper())) { context.Model.GetAnnotations(); entityType = context.Model.FindEntityType(typeof(Foo)); } var fooName = entityType.FindProperty(nameof(Foo.Name)); var tagName = entityType.FindProperty(nameof(Foo.Tag)); fooName.GetMaxLength().GetValueOrDefault().Should().Be(10); tagName.GetMaxLength().GetValueOrDefault().Should().Be(10); }
public void Given_That_HasMaxLength_ShouldOverride_DefaultMaxLength() { IEntityType entityType; var options = CreateDbContextOptions <FooContext>(); using (var context = new FooContext(options, new FooMapper())) { context.Model.GetAnnotations(); entityType = context.Model.FindEntityType(typeof(Foo)); } var fooAlreadyMappedByOthers = entityType.FindProperty(nameof(Foo.AlreadyMappedByOthers)); var fooAnnotatedString = entityType.FindProperty(nameof(Foo.AnnotatedString)); var fooFluentApiString = entityType.FindProperty(nameof(Foo.FluentApiString)); fooAlreadyMappedByOthers.GetMaxLength().GetValueOrDefault().Should().Be(200); fooAnnotatedString.GetMaxLength().GetValueOrDefault().Should().Be(200); fooFluentApiString.GetMaxLength().GetValueOrDefault().Should().Be(200); }
public FooController(FooContext context) { _context = context; }
public FooContextService() { _ctx = new FooContext(); }
public void DisposeWorksCorrectly() { //Arrange DbConnection connection = Effort.DbConnectionFactory.CreateTransient(); var context = new FooContext(connection); var unitOfWork = new Ef6UnitOfWork(_context, IsolationLevel.Unspecified); var repository = new BaseRepository<Foo>(unitOfWork); //Act repository.Insert(new Foo { Id = Guid.NewGuid() }); unitOfWork.SaveChanges(); unitOfWork.Dispose(); //Assert }
public UnitOfWork(IDbContext dbContext) { _dbContext = dbContext; }
public HomeController(FooContext context, ILoggerFactory loggerFactory) { _context = context ?? throw new ArgumentNullException(nameof(context)); _logger = (loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory))).CreateLogger(GetType()); }
public FooContextService(bool proxyCreationEnabled) { _ctx = new FooContext(); _ctx.Configuration.ProxyCreationEnabled = proxyCreationEnabled; }
public BindableChannels(FooContext db) { _db = db; }
public CastClosureTests(ITestOutputHelper output) { _output = output; _db = new FooContext(); }