Пример #1
0
        public void DbServices_DbMethods_InvokesDatabaseBrokerGetServiceMethodsMethod_Done()
        {
            //------------Setup for test--------------------------
            var dbSource        = SqlServerTests.CreateDev2TestingDbSource();
            var args            = JsonConvert.SerializeObject(dbSource);
            var resourceCatalog = new Mock <IResourceCatalog>();

            resourceCatalog.Setup(catalog => catalog.GetResource <DbSource>(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(dbSource);
            var outputDescription = new Mock <IOutputDescription>();

            outputDescription.Setup(d => d.DataSourceShapes).Returns(new List <IDataSourceShape> {
                new DataSourceShape()
            });

            var dbBroker = new Mock <SqlDatabaseBroker>();

            dbBroker.Setup(b => b.GetServiceMethods(It.IsAny <DbSource>())).Verifiable();

            var dbServices = new TestDbServices(resourceCatalog.Object, dbBroker.Object);

            //------------Execute Test---------------------------
            var result = dbServices.DbMethods(args, Guid.Empty, Guid.Empty);

            //------------Assert Results-------------------------
            dbBroker.Verify(b => b.GetServiceMethods(It.IsAny <DbSource>()));

            Assert.IsNotNull(result);
        }
Пример #2
0
        public void DBServices_DBMethods_Null_ReturnEmptyList()
        {
            var services = new TestDbServices();

            //------------Execute Test---------------------------
            var result = services.DbMethods(null, Guid.Empty, Guid.Empty);

            // Assert Empty List
            Assert.AreEqual(0, result.Count);
        }
Пример #3
0
        public void DBServices_DBMethods_InvalidArgs_ErrorList()
        {
            var services = new TestDbServices();

            //------------Execute Test---------------------------
            var result = services.DbMethods("xxxx", Guid.Empty, Guid.Empty);

            // Assert Error List
            Assert.AreEqual(1, result.Count);
            Assert.IsTrue(result[0].Name.StartsWith("Error"), "Invalid args did not return error result");
        }
Пример #4
0
        public void DBServices_DbMethods_ValidArgs_ReturnsList()
        {
            var source          = SqlServerTests.CreateDev2TestingDbSource();
            var args            = source.ToString();
            var workspaceID     = Guid.NewGuid();
            var resourceCatalog = new Mock <IResourceCatalog>();

            resourceCatalog.Setup(catalog => catalog.GetResource <DbSource>(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(source);
            EnvironmentVariables.GetWorkspacePath(workspaceID);

            var services = new TestDbServices(resourceCatalog.Object);

            //------------Execute Test---------------------------
            var result = services.DbMethods(args, workspaceID, Guid.Empty);

            // Assert Returns Valid List
            Assert.IsTrue(result.Count >= 25, "DbMethods does not return a list");
        }