コード例 #1
0
        public void ShouldGetADataTableFromDatabase()
        {
            var query = "select " + ConfigSettings.WhatKey + " , " + ConfigSettings.When3Key + " , " +
                        ConfigSettings.Where4Key + " , " + ConfigSettings.How3Key + " FROM " +
                        ConfigSettings.Schema + "." + ConfigSettings.FactDataTable + " where " + ConfigSettings.Id +
                        " = 133" + " or " + ConfigSettings.Id + " = 306;";
            var datatable = Helper.GetStandardFactDataTable();
            var factDimension = new FactDimensions
            {
                Whatkey = "59",
                Whenkey = "5",
                Wherekey = "1",
                Howkey = "2"
            };
            var factDimension1 = new FactDimensions
            {
                Whatkey = "71",
                Whenkey = "2",
                Wherekey = "1",
                Howkey = "2"
            };
            datatable.Rows.Add(Helper.GetStandardFactDataRow(datatable, factDimension));
            datatable.Rows.Add(Helper.GetStandardFactDataRow(datatable, factDimension1));

            var expected = datatable.GetDataRows().ToList();
            var actual = ConnectionPool.Execute(query).GetDataRows().ToList();
            Assert.AreEqual(expected.Count, actual.Count);
            Assert.AreEqual(expected.ToString(), actual.ToString());
        }
コード例 #2
0
 public void ShouldGetADataTableFromDatabase()
 {
     const string query =
         "select WhatKey , When3Key , Where4Key , How3Key FROM new_student.fact_data_sheet1 where Fact_DataId = 133;";
     var datatable = FactData.GetStandardFactDataTable();
     var factDimension = new FactDimensions
     {
         Whatkey = "59",
         Whenkey = "5",
         Wherekey = "1",
         Howkey = "2"
     };
     datatable.Rows.Add(FactData.GetStandardFactDataRow(datatable , factDimension));
     var expected = datatable.GetDataRows().ToList();
     var actual = DatabaseUtils.ExecuteQuery(query).GetDataRows().ToList();
     Assert.AreEqual(expected.Count, actual.Count);
     Assert.AreEqual(expected.ToString(), actual.ToString());
 }
コード例 #3
0
 public void ShouldGiveAQueryToGetAllTheParentChildIdFromFactDimension()
 {
     const string query = "select distinct fact.id " +
                          "from fact_dimension_relationship.fact_data fact " +
                          "join fact_dimension_relationship.parent_child_data child " +
                          "on child.anchorWhatKey = 12 and child.anchorHow3Key  = 2 " +
                          "and child.When3Key = 8 and child.anchorWhere4Key = 1 " +
                          "and ( fact.WhatKey = child.childWhatKey or child.childWhatKey = '*') " +
                          "and ( fact.Where4Key = child.childWhere4Key or child.childWhere4Key = '*') " +
                          "and ( fact.How3Key = child.childHow3Key or child.childHow3Key = '*') " +
                          "and fact.When3Key = child.When3Key;";
     var factDimension = new FactDimensions
     {
         Howkey = "2",
         Whatkey = "12",
         Whenkey = "8",
         Wherekey = "1"
     };
     Assert.AreEqual(query, QueryCreator.GetChildIdQuery(factDimension));
 }
コード例 #4
0
        public void GetValueTakesARowAndColumnNameReturnsTheValueOfThatColumnForThatRow()
        {
            var datatable = Helper.GetStandardFactDataTable();
            var factDimensions = new FactDimensions
            {
                Wherekey = "1",
                Whatkey = "59",
                Whenkey = "5",
                Howkey = "2"
            };
            var dataRow = Helper.GetStandardFactDataRow(datatable, factDimensions);
            datatable.Rows.Add(dataRow);
            const string expectedWhen3Key = "5";
            const string expectedWhere4Key = "1";
            const string expectedWhatKey = "59";
            const string expectedHow3Key = "2";

            Assert.AreEqual(dataRow.GetValue(ConfigSettings.When3Key), expectedWhen3Key);
            Assert.AreEqual(dataRow.GetValue(ConfigSettings.Where4Key), expectedWhere4Key);
            Assert.AreEqual(dataRow.GetValue(ConfigSettings.WhatKey), expectedWhatKey);
            Assert.AreEqual(dataRow.GetValue(ConfigSettings.How3Key), expectedHow3Key);
        }
コード例 #5
0
        public void ShouldGetFactDimensionsFromDataRow()
        {
            var dataTable = Helper.GetStandardFactDataTable();
            const string whatKey = "59";
            const string whenKey = "5";
            const string whereKey = "1";
            const string howKey = "2";

            var factDimensions = new FactDimensions
            {
                Howkey = "2",
                Whatkey = "59",
                Whenkey = "5",
                Wherekey = "1"
            };
            var result =
                FactDimensions.GetFactDimensionsFromRow(Helper.GetStandardFactDataRow(dataTable, whatKey, whenKey,
                    whereKey, howKey));
            Assert.AreEqual(result.Howkey, factDimensions.Howkey);
            Assert.AreEqual(result.Wherekey, factDimensions.Wherekey);
            Assert.AreEqual(result.Whenkey, factDimensions.Whenkey);
            Assert.AreEqual(result.Whatkey, factDimensions.Whatkey);
        }
コード例 #6
0
 public static DataRow GetStandardFactDataRow(DataTable dataTable, FactDimensions factDimension)
 {
     return GetStandardFactDataRow(dataTable, factDimension.Whatkey, factDimension.Whenkey,
         factDimension.Wherekey, factDimension.Howkey);
 }