public void DbServices_TestService_NestedTransactions_DoesNotThrowException() { //------------Setup for test-------------------------- var dbService = new DbService { Recordset = new Recordset(), Method = new ServiceMethod { Name = "dbo.Pr_GeneralTestNestedTransaction", ExecuteAction = "dbo.Pr_GeneralTestNestedTransaction" }, Source = SqlServerTests.CreateDev2TestingDbSource() }; var args = JsonConvert.SerializeObject(dbService); Mock <IResourceCatalog> mockedResourceCatelog = new Mock <IResourceCatalog>(); mockedResourceCatelog.Setup(a => a.GetResource <DbSource>(Guid.Empty, dbService.Source.ResourceID)).Returns(dbService.Source as DbSource); var dbServices = new TestDbServices(mockedResourceCatelog.Object, new Mock <IAuthorizationService>().Object); //------------Execute Test--------------------------- var result = dbServices.DbTest(args, Guid.Empty, Guid.Empty); //------------Assert Results------------------------- Assert.IsNotNull(result, "DbTest returned null when it was expected to return an error free object."); Assert.IsFalse(result.HasErrors, result.ErrorMessage); }
public void DbServices_TestService_InvokesDatabaseBrokerTestServiceMethod_Done() { //------------Setup for test-------------------------- var dbService = new DbService { Recordset = new Recordset(), Method = new ServiceMethod(), Source = SqlServerTests.CreateDev2TestingDbSource() }; var args = JsonConvert.SerializeObject(dbService); 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.TestService(It.IsAny <DbService>())).Returns(outputDescription.Object).Verifiable(); var dbServices = new TestDbServices(dbBroker.Object); //------------Execute Test--------------------------- var result = dbServices.DbTest(args, Guid.Empty, Guid.Empty); //------------Assert Results------------------------- dbBroker.Verify(b => b.TestService(It.IsAny <DbService>())); Assert.IsNotNull(result); }
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); }
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"); }
public void DbSources_Test_InvokesDatabaseBrokerTestMethod_Done() { //------------Setup for test-------------------------- var dbSource = SqlServerTests.CreateDev2TestingDbSource(); var args = JsonConvert.SerializeObject(dbSource); var dbBroker = new Mock <SqlDatabaseBroker>(); dbBroker.Setup(b => b.GetDatabases(It.IsAny <DbSource>())).Verifiable(); var dbSources = new TestDbSources(dbBroker.Object); //------------Execute Test--------------------------- var result = dbSources.Test(args, Guid.Empty, Guid.Empty); //------------Assert Results------------------------- dbBroker.Verify(b => b.GetDatabases(It.IsAny <DbSource>())); Assert.IsNotNull(result); }
public static DbService CreateDev2TestingDbService() { var service = new DbService { ResourceID = Guid.NewGuid(), ResourceName = "Dev2TestingService", ResourceType = ResourceType.DbService, ResourcePath = "Test\\Dev2TestingService", Method = new ServiceMethod { Name = "dbo.Pr_CitiesGetCountries", Parameters = new List <MethodParameter>(new[] { new MethodParameter { Name = "Prefix", EmptyToNull = false, IsRequired = true, Value = "b" } }), ExecuteAction = "dbo.Pr_CitiesGetCountries" }, Recordset = new Recordset { Name = "Countries", }, Source = SqlServerTests.CreateDev2TestingDbSource() }; service.Recordset.Fields.AddRange(new[] { new RecordsetField { Name = "CountryID", Alias = "CountryID" }, new RecordsetField { Name = "Description", Alias = "Name" } }); return(service); }