public void WithDbContext_Taking_FactoryMethod_When_Called_Calls_WithDbContext_Method_Of_The_Builder() { // Arrange var entityFrameworkDestinationBuilder = new Mock <IEntityFrameworkDestinationBuilder>(); entityFrameworkDestinationBuilder.Setup(x => x.WithDbContext(It.IsAny <IDbContextProvider>())).Returns(entityFrameworkDestinationBuilder.Object); LogModelFunc <DbContext> factoryMethod = d => null; // Act var returned = IEntityFrameworkDestinationBuilderExtensions.WithDbContext(entityFrameworkDestinationBuilder.Object, factoryMethod); // Assert entityFrameworkDestinationBuilder.Verify(x => x.WithDbContext(It.Is <FactoryMethodDbContextProvider>(c => c.FactoryMethod == factoryMethod)), Times.Once); Assert.AreEqual(entityFrameworkDestinationBuilder.Object, returned); }
public void WithDbContext_Taking_DbContext_When_Called_Calls_WithDbContext_Method_Of_The_Builder() { // Arrange var entityFrameworkDestinationBuilder = new Mock <IEntityFrameworkDestinationBuilder>(); entityFrameworkDestinationBuilder.Setup(x => x.WithDbContext(It.IsAny <IDbContextProvider>())).Returns(entityFrameworkDestinationBuilder.Object); DbContext dbContext = new Mock <DbContext>().Object; // Act var returned = IEntityFrameworkDestinationBuilderExtensions.WithDbContext(entityFrameworkDestinationBuilder.Object, dbContext); // Assert entityFrameworkDestinationBuilder.Verify(x => x.WithDbContext(It.Is <DbContextProvider>(c => c.DbContext == dbContext)), Times.Once); Assert.AreEqual(entityFrameworkDestinationBuilder.Object, returned); }