Ejemplo n.º 1
0
        public ObjectsContextTests()
        {
            var config = new Configuration.Configuration();

            config.SetValue("currentSchema", "test");

            var objManager = new Mock <IDbObjectManager>();

            objManager.SetupGet(x => x.ObjectType)
            .Returns(DbObjectType.Variable);
            objManager.Setup(x => x.GetObjectInfoAsync(It.IsAny <ObjectName>()))
            .Returns <ObjectName>(name => Task.FromResult <IDbObjectInfo>(
                                      new VariableInfo(name.Name, PrimitiveTypes.String(), true, SqlExpression.Constant(SqlObject.Integer(2)))));
            objManager.Setup(x => x.GetObjectAsync(It.IsAny <ObjectName>()))
            .Returns <ObjectName>(name => Task.FromResult <IDbObject>(
                                      new Variable(name.Name, PrimitiveTypes.String(), true, SqlExpression.Constant(SqlObject.Integer(2)))));
            objManager.Setup(x => x.ResolveNameAsync(It.IsAny <ObjectName>(), It.IsAny <bool>()))
            .Returns <ObjectName, bool>((name, ignoreCase) => Task.FromResult(name));

            var container = new ServiceContainer();

            container.AddObjectManager(objManager.Object);

            var mock = new Mock <IContext>();

            mock.As <IConfigurationScope>()
            .SetupGet(x => x.Configuration).Returns(config);
            mock.SetupGet(x => x.Scope)
            .Returns(container);

            context = mock.Object;
        }