Inheritance: Resource
Ejemplo n.º 1
0
 public void ToStringEmptyObjectExpected()
 {
     var testDbSource = new DbSource();
     string actualSerializedDbSource = testDbSource.ToString();
     string expected = JsonConvert.SerializeObject(testDbSource);
     Assert.AreEqual(expected, actualSerializedDbSource);
 }
// ReSharper disable InconsistentNaming
        public void AbstractDataBaseBroker_GetServiceMethods_WhenCached_CachedResults()
// ReSharper restore InconsistentNaming
        {
            //------------Setup for test--------------------------
            TestDatabaseBroker broker = new TestDatabaseBroker();

            DbSource source = new DbSource();

            TestDatabaseBroker.TheCache = new ConcurrentDictionary<string, ServiceMethodList>();
// ReSharper disable UseObjectOrCollectionInitializer
            var methodList = new ServiceMethodList();
// ReSharper restore UseObjectOrCollectionInitializer
            methodList.Add(new ServiceMethod("bob", "bob src", null, null, null,""));

            TestDatabaseBroker.TheCache.TryAdd(source.ConnectionString, methodList);
            //------------Execute Test---------------------------

            var result = broker.GetServiceMethods(source);

            // set back to empty ;)
            TestDatabaseBroker.TheCache = new ConcurrentDictionary<string, ServiceMethodList>();
            //------------Assert Results-------------------------

            Assert.AreEqual(1, result.Count);
            Assert.AreEqual("bob", result[0].Name);
        }
Ejemplo n.º 3
0
 public void DbSource_ConnectionString_NotNamedInstance_ShouldUsePortNumber()
 {
     //------------Setup for test--------------------------
     var dbSource = new DbSource
     {
         Server = "myserver", 
         ServerType = enSourceType.SqlDatabase, 
         AuthenticationType = AuthenticationType.Windows, 
         DatabaseName = "testdb",
         Port=1433
     };
     //------------Execute Test---------------------------
     var connectionString = dbSource.ConnectionString;
     //------------Assert Results-------------------------
     StringAssert.Contains(connectionString,",1433");
 }
        // ReSharper disable InconsistentNaming

        public static DbSource CreateDev2TestingDbSource(AuthenticationType authenticationType = AuthenticationType.User)
        {
            var dbSource = new DbSource
            {
                ResourceID = Guid.NewGuid(),
                ResourceName = "Dev2TestingDB",
                ResourcePath = "Test",
                DatabaseName = "Dev2TestingDB",
                Server = "RSAKLFSVRGENDEV",
                AuthenticationType = authenticationType,
                ServerType = enSourceType.SqlDatabase,
                ReloadActions = true,
                UserID = authenticationType == AuthenticationType.User ? "testUser" : null,
                Password = authenticationType == AuthenticationType.User ? "test123" : null
            };
            return dbSource;
        }
Ejemplo n.º 5
0
 public void DbSource_ConnectionString_NamedInstanceDefaultPort_ShouldNotUsePort()
 {
     //------------Setup for test--------------------------
     var dbSource = new DbSource
     {
         Server = "myserver\\instance", 
         ServerType = enSourceType.SqlDatabase, 
         AuthenticationType = AuthenticationType.Windows, 
         DatabaseName = "testdb",
         Port=1433
     };
     //------------Execute Test---------------------------
     var connectionString = dbSource.ConnectionString;
     //------------Assert Results-------------------------
     var contains = connectionString.Contains(",1433");
     Assert.IsFalse(contains);
 }
Ejemplo n.º 6
0
 // POST: Service/dbSources/Get
 public DbSource Get(string resourceId, Guid workspaceId, Guid dataListId)
 {
     var result = new DbSource { ResourceID = Guid.Empty, ResourceType = ResourceType.DbSource, AuthenticationType = AuthenticationType.Windows };
     try
     {
         var xmlStr = ResourceCatalog.Instance.GetResourceContents(workspaceId, Guid.Parse(resourceId)).ToString();
         if(!string.IsNullOrEmpty(xmlStr))
         {
             var xml = XElement.Parse(xmlStr);
             result = new DbSource(xml);
         }
     }
     catch(Exception ex)
     {
         RaiseError(ex);
     }
     return result;
 }
Ejemplo n.º 7
0
 static DbSource CreateDbSource()
 {
     var resourceID = Guid.NewGuid();
     var dbSource = new DbSource { ResourcePath = "SQL Tests\\" + resourceID, ResourceName = resourceID.ToString(), ResourceID = resourceID };
     ResourceCatalog.Instance.SaveResource(Guid.Empty, dbSource);
     return dbSource;
 }
Ejemplo n.º 8
0
        private void SetupArguments(string currentDL, string testData, ISqlBulkInserter sqlBulkInserter, IList<DataColumnMapping> inputMappings, string resultString, DbSource dbSource = null, string destinationTableName = null, PopulateOptions populateOptions = PopulateOptions.IgnoreBlankRows, bool keepIdentity = false)
        {
            var ignoreBlankRows = populateOptions == PopulateOptions.IgnoreBlankRows;
            if(dbSource == null)
            {
                dbSource = CreateDbSource();
            }
            if(destinationTableName == null)
            {
                destinationTableName = "SomeTestTable";
            }
            TestStartNode = new FlowStep
            {
                Action = new DsfSqlBulkInsertActivity
                {
                    Database = dbSource,
                    TableName = destinationTableName,
                    InputMappings = inputMappings,
                    SqlBulkInserter = sqlBulkInserter,
                    Result = resultString,
                    IgnoreBlankRows = ignoreBlankRows,
                    KeepIdentity = keepIdentity
                }
            };

            CurrentDl = testData;
            TestData = currentDL;
        }
Ejemplo n.º 9
0
 public DbService()
 {
     ResourceType = "DbService";
     Source       = new DbSource();
     Recordset    = new Recordset();
 }
Ejemplo n.º 10
0
 public DbService()
 {
     ResourceType = ResourceType.DbService;
     Source = new DbSource();
     Recordset = new Recordset();
 }
 DbSource CreateDev2TestingDbSource(bool emptyDBName=false)
 {
     var dbSource = new DbSource
     {
         ResourceID = Guid.NewGuid(),
         ResourceName = "Dev2TestingDB",
         ResourcePath = "Test",
         DatabaseName = emptyDBName?"": "Dev2TestingDB",
         Server = "RSAKLFSVRGENDEV",
         AuthenticationType = AuthenticationType.User,
         ServerType = enSourceType.SqlDatabase,
         ReloadActions = true,
         UserID = "testUser",
         Password = "******"
     };
     return dbSource;
 }
Ejemplo n.º 12
0
        private DbSource SetupDefaultDbSource()
        {
            var testDbSource = new DbSource
            {
                Server = "someServerIMadeUpToTest",
                Port = 420,
                AuthenticationType = AuthenticationType.Windows,
                UserID = @"Domain\User",
                Password = "******",
                DatabaseName = "someDatabaseNameIMadeUpToTest",
                ResourceID = Guid.NewGuid(),
                ResourceName = "TestResourceIMadeUp",
                ResourcePath = @"host\Server",
                ResourceType = ResourceType.DbSource
            };

            return testDbSource;
        }
Ejemplo n.º 13
0
        public void ToXmlEmptyObjectExpectedXElementContainingNoInformationRegardingSource()
        {
            var testDbSource = new DbSource();
            XElement expectedXml = testDbSource.ToXml();

            IEnumerable<XAttribute> attrib = expectedXml.Attributes();
            IEnumerator<XAttribute> attribEnum = attrib.GetEnumerator();
            while(attribEnum.MoveNext())
            {
                if(attribEnum.Current.Name == "Name")
                {
                    Assert.AreEqual(string.Empty, attribEnum.Current.Value);
                    break;
                }
            }
        }
Ejemplo n.º 14
0
 public DbService()
 {
     ResourceType = Common.Interfaces.Data.ResourceType.DbService;
     Source       = new DbSource();
     Recordset    = new Recordset();
 }
// ReSharper disable InconsistentNaming
        public void AbstractDataBaseBroker_GetServiceMethods_WhenCachedNoRefreshRequested_FreshResults()
// ReSharper restore InconsistentNaming
        {
            //------------Setup for test--------------------------
            TestDatabaseBroker broker = new TestDatabaseBroker();

            DbSource source = new DbSource { ReloadActions = true };

            TestDatabaseBroker.TheCache = new ConcurrentDictionary<string, ServiceMethodList>();
            var methodList = new ServiceMethodList { new ServiceMethod("bob", "bob src", null, null, null, null) };

            TestDatabaseBroker.TheCache.TryAdd(source.ConnectionString, methodList);
            //------------Execute Test---------------------------

            var result = broker.GetServiceMethods(source);

            // set back to empty ;)
            TestDatabaseBroker.TheCache = new ConcurrentDictionary<string, ServiceMethodList>();
            //------------Assert Results-------------------------

            Assert.AreEqual(0, result.Count);
        }
// ReSharper disable InconsistentNaming
        public void AbstractDataBaseBroker_GetDatabases_InvokesDbServerFetchDatabases_Done()
// ReSharper restore InconsistentNaming
        {
            //------------Setup for test--------------------------
            var dbSource = new DbSource();

            var dbServer = new Mock<TestDbServer>();
            dbServer.Setup(s => s.Connect(It.IsAny<string>())).Verifiable();
            dbServer.Setup(s => s.FetchDatabases()).Verifiable();

            var broker = new TestDatabaseBroker(dbServer.Object);

            //------------Execute Test---------------------------
            broker.GetDatabases(dbSource);

            //------------Assert Results-------------------------
            dbServer.Verify(s => s.Connect(It.IsAny<string>()));
            dbServer.Verify(s => s.FetchDatabases());
        }
Ejemplo n.º 17
0
     public virtual ServiceMethodList FetchMethods(DbSource dbSource)
     {
         switch(dbSource.ServerType)
         {
                 case enSourceType.MySqlDatabase:
             {
                 var broker = new  MySqlDatabaseBroker();
                 return broker.GetServiceMethods(dbSource);
             }
             default:
             {
                         var broker = CreateDatabaseBroker();
                     return broker.GetServiceMethods(dbSource);
             }
         }
 
     }
Ejemplo n.º 18
0
        protected virtual DatabaseValidationResult DoDatabaseValidation(DbSource dbSourceDetails)
        {
            var result = new DatabaseValidationResult();

            switch (dbSourceDetails.ServerType)
            {
                case enSourceType.SqlDatabase:
                    var broker = CreateDatabaseBroker(dbSourceDetails.ServerType);
                    result.DatabaseList = broker.GetDatabases(dbSourceDetails);
                    break;
                case enSourceType.MySqlDatabase:
                    var mybroker = CreateMySqlDatabaseBroker(dbSourceDetails.ServerType);
                    result.DatabaseList = mybroker.GetDatabases(dbSourceDetails);
                    break;
                default:
                    result.IsValid = false;
                    break;
            }
            return result;
        }
Ejemplo n.º 19
0
        // ReSharper disable InconsistentNaming
        public void DbService_ToXml_WhenRecordSetHasBlankFields_ExpectNotPartOfOutputDescription()
        // ReSharper restore InconsistentNaming
        {
            //------------Setup for test--------------------------
            var dbService = new DbService();
            var dbSource = new DbSource { ResourceName = "Source" };
            var resourceId = Guid.NewGuid();
            dbSource.ResourceID = resourceId;
            dbService.Source = dbSource;
            var serviceMethod = new ServiceMethod { Name = "Method" };
            dbService.Method = serviceMethod;
            var recordset = new Recordset { Name = "SomeRecSet" };
            var recordsetField = new RecordsetField { Alias = "SomeAlias", Name = "" };
            recordset.Fields.Add(recordsetField);
            dbService.Recordset = recordset;

            // ReSharper disable InconsistentNaming
            const string expected = @"<Service ID=""00000000-0000-0000-0000-000000000000"" Name="""" ResourceType=""DbService"" IsValid=""false"">
  <Actions>
    <Action Name=""SomeRecSet"" Type=""InvokeStoredProc"" SourceID=""{0}"" SourceName=""Source"" ExecuteAction="""" SourceMethod=""Method"">
      <Inputs />
      <Outputs />
      <OutputDescription><![CDATA[<z:anyType xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:d1p1=""http://schemas.datacontract.org/2004/07/Unlimited.Framework.Converters.Graph.Ouput"" i:type=""d1p1:OutputDescription"" xmlns:z=""http://schemas.microsoft.com/2003/10/Serialization/""><d1p1:DataSourceShapes xmlns:d2p1=""http://schemas.microsoft.com/2003/10/Serialization/Arrays""><d2p1:anyType i:type=""d1p1:DataSourceShape""><d1p1:_x003C_Paths_x003E_k__BackingField /></d2p1:anyType></d1p1:DataSourceShapes><d1p1:Format>ShapedXML</d1p1:Format></z:anyType>]]></OutputDescription>
    </Action>
  </Actions>
  <AuthorRoles />
  <Comment />
  <Tags />
  <HelpLink />
  <UnitTestTargetWorkflowService />
  <BizRule />
  <WorkflowActivityDef />
  <XamlDefinition />
  <DataList />
  <TypeOf>InvokeStoredProc</TypeOf>
  <DisplayName></DisplayName>
  <Category></Category>
  <AuthorRoles></AuthorRoles>
  <ErrorMessages />
</Service>";
            // ReSharper restore InconsistentNaming

            //------------Execute Test---------------------------
            var xElement = dbService.ToXml();
            //------------Assert Results-------------------------
            Assert.AreEqual(string.Format(expected, resourceId), xElement.ToString());
        }
Ejemplo n.º 20
0
 protected override DatabaseValidationResult DoDatabaseValidation(DbSource dbSourceDetails)
 {
     //PBI 8720
     DatabaseValidationHitCount++;
     return new DatabaseValidationResult { IsValid = true };
 }
Ejemplo n.º 21
0
 public DbService()
 {
     ResourceType = Common.Interfaces.Data.ResourceType.DbService;
     Source = new DbSource();
     Recordset = new Recordset();
 }