public void CreateInstantiatesForKnownFactory() { const string NAME = "Testing"; var connection = new Mock <IDbConnection>(); var dbFactory = new Mock <IDbFactory>(); dbFactory.Setup(x => x.Create(It.IsAny <string>())).Returns(() => connection.Object); var factory = new AbstractDbFactory(); factory.Register(NAME, dbFactory.Object); Assert.Same(connection.Object, factory.Create(NAME, "XYZ")); }
public void CreateThrowsExceptionIfUnknownFactory() { var factory = new AbstractDbFactory(); Assert.Throws <ArgumentException>(() => factory.Create("ABC", "123")); }