Esempio n. 1
0
        public void Test50DecodeJsonToSqlDataWithSingleRemovalOk()
        {
            //SETUP

            //EXECUTE
            var sqlData = LoadJsonHelpers.DeserializeObjectWithSingleRemoval <SqlAllInfo>("SqlAllInfo01*.json", "Indexes", 1);

            //VERIFY
            sqlData.Indexes.Count.ShouldEqual(2);
        }
        public void Test17CompareMockDataRemoveColumnInRefOk()
        {
            //SETUP
            var comparer = new SqlCompare("RefUnitTest", "ToBeCheckUnitTest", "", true);
            var sqlData1 = LoadJsonHelpers.DeserializeObjectWithSingleRemoval <SqlAllInfo>("SqlAllInfo01*.json", "TableInfos", 0, "ColumnInfos", 0);
            var sqlData2 = LoadJsonHelpers.DeserializeData <SqlAllInfo>("SqlAllInfo01*.json");

            //EXECUTE
            var status = comparer.CompareSqlToSql(sqlData1, sqlData2);

            //VERIFY
            status.ShouldBeValid();
            string.Join(",", status.Warnings).ShouldEqual("Warning: Extra Column: The 'ToBeCheckUnitTest' database SQL table [dbo].[DataTop] has a column called DataTopId (type int), which database 'RefUnitTest' did not have.", string.Join(",", status.Warnings));
        }
        public void Test41CompareMockDataChangeIndexRemovePrimaryKeyInSetOk()
        {
            //SETUP
            var comparer = new SqlCompare("RefUnitTest", "ToBeCheckUnitTest", "", true);
            var sqlData1 = LoadJsonHelpers.DeserializeData <SqlAllInfo>("SqlAllInfo01*.json");
            var sqlData2 = LoadJsonHelpers.DeserializeObjectWithSingleRemoval <SqlAllInfo>("SqlAllInfo01*.json", "Indexes", 1);

            //EXECUTE
            var status = comparer.CompareSqlToSql(sqlData1, sqlData2);

            //VERIFY
            status.ShouldBeValid(false);
            status.GetAllErrors().ShouldEqual("Missing Index: The 'RefUnitTest' SQL database has an index [dbo].[DataChild].DataChildId: (primary key, clustered, unique), which is missing in the 'ToBeCheckUnitTest' database.", status.GetAllErrors());
            status.HasWarnings.ShouldEqual(false, string.Join(",", status.Warnings));
        }
        public void Test16CompareMockDataRemoveColumnInToBeCheckedOk()
        {
            //SETUP
            var comparer = new SqlCompare("RefUnitTest", "ToBeCheckUnitTest", "", true);
            var sqlData1 = LoadJsonHelpers.DeserializeData <SqlAllInfo>("SqlAllInfo01*.json");
            var sqlData2 = LoadJsonHelpers.DeserializeObjectWithSingleRemoval <SqlAllInfo>("SqlAllInfo01*.json", "TableInfos", 0, "ColumnInfos", 0);

            //EXECUTE
            var status = comparer.CompareSqlToSql(sqlData1, sqlData2);

            //VERIFY
            status.ShouldBeValid(false);
            status.GetAllErrors().ShouldEqual("Missing Column: The SQL table [dbo].[DataTop] in second database does not contain a column called DataTopId.", status.GetAllErrors());
            status.HasWarnings.ShouldEqual(false, string.Join(",", status.Warnings));
        }
        public void Test16CompareMockDataRemoveColumnInToBeCheckedOk()
        {
            //SETUP
            var efData   = LoadJsonHelpers.DeserializeData <List <EfTableInfo> >("EfTableInfos01*.json");
            var sqlData  = LoadJsonHelpers.DeserializeObjectWithSingleRemoval <SqlAllInfo>("SqlAllInfo01*.json", "TableInfos", 0, "ColumnInfos", 0);
            var comparer = new EfCompare("SqlRefString", sqlData.TableInfos.ToDictionary(x => x.CombinedName));

            //EXECUTE
            var status = comparer.CompareEfWithSql(efData, sqlData);

            //VERIFY
            status.ShouldBeValid(false);
            status.GetAllErrors().ShouldEqual("Missing Column: The SQL SqlRefString table [dbo].[DataTop] does not contain a column called DataTopId. Needed by EF class DataTop.\n" +
                                              "Missing Foreign Key: EF has a Many-to-One relationship between DataChild.Parent and DataTop but we don't find that in SQL.", status.GetAllErrors());
            status.HasWarnings.ShouldEqual(false, string.Join(",", status.Warnings));
        }