コード例 #1
0
        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"));
        }
コード例 #2
0
        public void CreateThrowsExceptionIfUnknownFactory()
        {
            var factory = new AbstractDbFactory();

            Assert.Throws <ArgumentException>(() => factory.Create("ABC", "123"));
        }