public void ProcessContextShouldReturnAnContextStringValueWhenTheAutoGeneratedValueColumnModelIsNotTheFirstAutoGeneratedValueColumnModel()
        {
            var columnModel = new ColumnModelForTest()
            {
                IsAutoGeneratedValue = true
            };
            var databaseContext = new ProcessorDatabaseContext()
            {
                Column = columnModel,
                Table  = new TableModelForTest()
                {
                    Columns = new List <IColumnModel>()
                    {
                        new ColumnModelForTest()
                        {
                            Name = "Another Auto Generated Value Column", IsAutoGeneratedValue = true
                        }, columnModel
                    }
                }
            };
            var expected = "HelloWorld";
            var actual   = _tested.ProcessContext($"{_tested.StartContext}{expected}{_tested.EndContext}", databaseContext);

            Assert.AreEqual(expected, actual);
        }
        public void ProcessContextShouldReturnAnEmptyStringWhenTheAutoGeneratedValueColumnModelIsTheLastAutoGeneratedValueColumnModelButNotTheLastElementOfColumn()
        {
            var columnModel = new ColumnModelForTest()
            {
                IsAutoGeneratedValue = true
            };
            var databaseContext = new ProcessorDatabaseContext()
            {
                Column = columnModel,
                Table  = new TableModelForTest()
                {
                    Columns = new List <IColumnModel>()
                    {
                        new ColumnModelForTest()
                        {
                            Name = "Another Auto Generated Value Column", IsAutoGeneratedValue = true
                        },
                        columnModel, new ColumnModelForTest()
                        {
                            Name = "Another column which is not Auto Generated Value"
                        }
                    }
                }
            };

            var actual = _tested.ProcessContext($"{_tested.StartContext}HelloWorld{_tested.EndContext}", databaseContext);

            Assert.AreEqual(string.Empty, actual);
        }
        public void ShouldReturnAccurateTableNameChainWhenThereIsOnlyOneDependence()
        {
            var firstForeignDependencyTable = new TableModelForTest()
            {
                Name = "firstForeignDependencyTable",
            };
            var startPointTable = new TableModelForTest()
            {
                Name = "startPointTable"
            };

            MakeDependant(startPointTable, firstForeignDependencyTable);
            string StringContext   = $"{_tested.StartContext}{tableNameTableContextHandler.Signature},{_tested.EndContext}";
            var    databaseContext = new ProcessorDatabaseContext()
            {
                Table    = startPointTable,
                Database = new DatabaseModelForTest()
                {
                    Tables = new List <ITableModel>
                    {
                        firstForeignDependencyTable,
                        startPointTable
                    }
                }
            };
            var actual   = _tested.ProcessContext(StringContext, databaseContext);
            var expected = $"{firstForeignDependencyTable.Name},";

            Assert.AreEqual(expected, actual);
        }
        public void ProcessContextShouldReturnAnContextStringValueWhenTheIndexedColumnModelIsTheFirstIndexedColumnModelButNotTheFirstElementOfColumn()
        {
            var columnModel = new ColumnModelForTest()
            {
                IsIndexed = true
            };
            var databaseContext = new ProcessorDatabaseContext()
            {
                Column = columnModel,
                Table  = new TableModelForTest()
                {
                    Columns = new List <IColumnModel>()
                    {
                        new ColumnModelForTest()
                        {
                            Name = "Another column which is not indexed"
                        },
                        columnModel, new ColumnModelForTest()
                        {
                            Name = "Another Indexed Column", IsIndexed = true
                        }
                    }
                }
            };
            var expected = "HelloWorld";
            var actual   = _tested.ProcessContext($"{_tested.StartContext}{expected}{_tested.EndContext}", databaseContext);

            Assert.AreEqual(expected, actual);
        }
        public void ProcessContextShouldReturnAnContextStringValueWhenTheAutoGeneratedValueColumnModelIsTheLastAutoGeneratedValueColumnModelButNotTheLastElementOfColumn()
        {
            var columnModel = new ColumnModelForTest()
            {
                IsAutoGeneratedValue = true
            };
            var parentTable = new TableModelForTest()
            {
                Columns = new List <IColumnModel>()
                {
                    new ColumnModelForTest()
                    {
                        Name = "Another autogenerated value column", IsAutoGeneratedValue = true
                    },
                    columnModel,
                    new ColumnModelForTest()
                    {
                        Name = "Another column which is not autogenerated value column", IsAutoGeneratedValue = false
                    },
                }
            };
            var databaseContext =
                new ProcessorDatabaseContext()
            {
                Column = columnModel,
                Table  = parentTable
            };
            var expected = "HelloWorld";
            var actual   = _tested.ProcessContext($"{_tested.StartContext}{expected}{_tested.EndContext}", databaseContext);

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 6
0
        public void ProcessContextShouldReturnAnContextStringValueWhenTheNotIndexedColumnModelIsTheLastNotIndexedColumnModel()
        {
            var columnModel = new ColumnModelForTest()
            {
                ParentTable = new TableModelForTest(), IsIndexed = false
            };
            var databaseContext = new ProcessorDatabaseContext()
            {
                Column = columnModel,
                Table  = new TableModelForTest()
                {
                    Columns = new List <IColumnModel>()
                    {
                        new ColumnModelForTest()
                        {
                            Name = "Another Not Indexed Column", IsIndexed = false
                        }, columnModel
                    }
                }
            };
            var expected = "HelloWorld";
            var actual   = _tested.ProcessContext($"{_tested.StartContext}{expected}{_tested.EndContext}", databaseContext);

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 7
0
        public void ProcessContextShouldReturnAnEmptyStringWhenTheNotIndexedColumnModelIsTheFirstNotIndexedColumnModelButNotTheFirstElementOfColumn()
        {
            var columnModel = new ColumnModelForTest()
            {
                IsIndexed = false
            };
            var parentTable = new TableModelForTest()
            {
                Columns = new List <IColumnModel>()
                {
                    new ColumnModelForTest()
                    {
                        Name = "Another column which is indexed", IsIndexed = true
                    },
                    columnModel,
                    new ColumnModelForTest()
                    {
                        Name = "Another Not Indexed Column", IsIndexed = false
                    }
                }
            };
            var databaseContext =
                new ProcessorDatabaseContext()
            {
                Column = columnModel,
                Table  = parentTable
            };
            var actual = _tested.ProcessContext($"{_tested.StartContext}HelloWorld{_tested.EndContext}", databaseContext);

            Assert.AreEqual(string.Empty, actual);
        }
Ejemplo n.º 8
0
        public void ProcessContextShouldReturnAnContextContentWhenTheIndexedColumnModelIsNotTheLastIndexedColumnModel()
        {
            var columnModel = new ColumnModelForTest()
            {
                IsIndexed = true
            };
            var databaseContext = new ProcessorDatabaseContext()
            {
                Column = columnModel,
                Table  = new TableModelForTest()
                {
                    Columns = new List <IColumnModel>()
                    {
                        columnModel, new ColumnModelForTest()
                        {
                            Name = "Another Indexed Column", IsIndexed = true
                        }
                    }
                }
            };
            var expected = "HelloWorld";
            var actual   = _tested.ProcessContext($"{_tested.StartContext}{expected}{_tested.EndContext}", databaseContext);

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 9
0
        public void ProcessedContextShouldBe1ValueIndexWhenThereIsOneAutoAndOneNoneAutoColumnInTheColumnsParentTableList()
        {
            var columnModel = new ColumnModel()
            {
                IsAutoGeneratedValue = true
            };
            var databaseContext = new ProcessorDatabaseContext()
            {
                Column = columnModel,
                Table  = new TableModelForTest()
                {
                    Columns = new List <IColumnModel>()
                    {
                        new ColumnModelForTest
                        {
                            IsAutoGeneratedValue = true,
                        },
                        new ColumnModelForTest
                        {
                            IsAutoGeneratedValue = false,
                        },
                        columnModel,
                        new ColumnModelForTest
                        {
                            IsAutoGeneratedValue = true,
                        }
                    }
                }
            };
            var processedContext = _tested.ProcessContext($"{_tested.StartContext}{_tested.EndContext}", databaseContext);

            Assert.AreEqual($"{1}", processedContext);
        }
Ejemplo n.º 10
0
        public void ProcessedContextShouldBeDefaultAutoIndexWhenColumnIsNotInTheParentTable()
        {
            var columnModel = new ColumnModelForTest()
            {
                IsAutoGeneratedValue = true
            };
            var databaseContext = new ProcessorDatabaseContext()
            {
                Column = columnModel,
                Table  = new TableModelForTest()
                {
                    Columns = new List <IColumnModel>()
                    {
                        new ColumnModel
                        {
                            IsAutoGeneratedValue = true,
                        },
                        new ColumnModel
                        {
                            IsAutoGeneratedValue = false,
                        },
                        new ColumnModel
                        {
                            IsAutoGeneratedValue = true,
                        }
                    }
                }
            };
            var processedContext = _tested.ProcessContext($"{_tested.StartContext}{_tested.EndContext}", databaseContext);

            Assert.AreEqual($"{_tested.DefaultIndex}", processedContext);
        }
Ejemplo n.º 11
0
        public void ShouldReturnEveryColumnNamePresentInTheTable()
        {
            var firstColumnName  = "firstColumnName";
            var secondColumnName = "secondColumnName";
            var databaseContext  = new ProcessorDatabaseContext()
            {
                Table =
                    new TableModelForTest()
                {
                    Columns = new List <IColumnModel>()
                    {
                        new ColumnModelForTest()
                        {
                            Name = firstColumnName
                        },
                        new ColumnModelForTest()
                        {
                            Name = secondColumnName
                        },
                    }
                }
            };
            var templateContext = $"{_tested.StartContext}{columnNameContextHandler.Signature},{_tested.EndContext}";
            var actual          = _tested.ProcessContext(templateContext, databaseContext);
            var expected        = $"{firstColumnName},{secondColumnName},";

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 12
0
        public void ProcessedContextShouldBe2ValueIndexWhenThereIsTwoColumnBefore()
        {
            var columnModel = new ColumnModel()
            {
                IsAutoGeneratedValue = true
            };

            TableModel tableModel = new TableModel
            {
                Columns = new List <IColumnModel>()
                {
                    new ColumnModel(),
                    new ColumnModel(),
                    columnModel,
                    new ColumnModel(),
                }
            };

            columnModel.ParentTable = tableModel;
            var databaseContext = new ProcessorDatabaseContext()
            {
                Column = columnModel, Table = tableModel
            };
            var processedContext = _tested.ProcessContext($"{_tested.StartContext}{_tested.EndContext}", databaseContext);

            Assert.AreEqual($"{2}", processedContext);
        }
Ejemplo n.º 13
0
        public void ShouldThrowAnExceptionWhenInternalContextIsEmpty()
        {
            string StringContext   = $"{_tested.StartContext}{_tested.EndContext}";
            var    datanaseContext = new ProcessorDatabaseContext()
            {
                Column = new ColumnModelForTest()
            };

            Assert.Throws <Exception>(() => _tested.ProcessContext(StringContext, datanaseContext),
                                      $"There is a problem with the function provided in template '{StringContext}' -> The value parameter cannot be empty");
        }
Ejemplo n.º 14
0
        public void ShouldThrowAnExceptionWhenColumnModelIsNull()
        {
            string StringContext   = "nianiania";
            var    databaseContext = new ProcessorDatabaseContext()
            {
                Column = null
            };

            Assert.Throws <Exception>(() => _tested.ProcessContext(StringContext, databaseContext),
                                      $"The { nameof(databaseContext.Column)} is not set");
        }
 public void ShouldThrowANExceptionWhenColumnModelIsNull()
 {
     Assert.Throws <ArgumentException>(() =>
     {
         var databaseContext = new ProcessorDatabaseContext()
         {
             Column = null
         };
         _tested.ProcessContext("Hello World !", databaseContext);
     });
 }
Ejemplo n.º 16
0
 public void ShouldThrowANExceptionWhenDatabaseModelIsNull()
 {
     Assert.Throws <Exception>(() =>
     {
         var databaseContext = new ProcessorDatabaseContext()
         {
             Column = null
         };
         _tested.ProcessContext("Hello World !", databaseContext);
     }, $"The {nameof(ProcessorDatabaseContext.Column)} is not set");
 }
 public void ProcessContextShouldContextContentWhenTheColumnModelAloneInCollectionValue()
 {
     var columnModel = new ColumnModelForTest() { };
     var databaseContext = new ProcessorDatabaseContext()
     {
         Column = columnModel,
         Table =new TableModelForTest() { Columns = new List<IColumnModel>() { columnModel } },
     };
     var expected = "HelloWorld";
     var actual = _tested.ProcessContext($"{_tested.StartContext}{expected}{_tested.EndContext}",databaseContext);
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 18
0
        public void ShouldReturnAccurateAndProcessedMappedValue(string columnType, string destinationTypeSet, string expectedOutput)
        {
            var databaseContext = new ProcessorDatabaseContext()
            {
                Column = new ColumnModelForTest()
                {
                    Type = columnType
                }
            };
            var result = _tested.ProcessContext($"{_tested.StartContext}{destinationTypeSet}{_tested.EndContext}", databaseContext);

            Assert.AreEqual(expectedOutput, result);
        }
Ejemplo n.º 19
0
 public void ShouldThrowAnExceptionWhenThereIsContentBetweenStartAndEndContext()
 {
     Assert.Throws <Exception>(() =>
     {
         var databaseContext = new ProcessorDatabaseContext()
         {
             Column = new ColumnModelForTest()
             {
             }
         };
         _tested.ProcessContext($"{_tested.StartContext}I Should not be here{_tested.EndContext}", databaseContext);
     });
 }
Ejemplo n.º 20
0
        public void ProcessContextShouldReturnAnEmptyStringWhenTheColumnIsNotIndexed()
        {
            var databaseContext = new ProcessorDatabaseContext()
            {
                Column = new ColumnModelForTest()
                {
                    IsIndexed = false
                }
            };
            var actual = _tested.ProcessContext($"{_tested.StartContext}HelloWorld{_tested.EndContext}", databaseContext);

            Assert.AreEqual(string.Empty, actual);
        }
        public void ShouldReturnEmptyStringWhenColumnIsNullable()
        {
            var databaseContext = new ProcessorDatabaseContext()
            {
                Column = new ColumnModelForTest()
                {
                    IsNotNull = false,
                }
            };
            var result = _tested.ProcessContext($"{_tested.StartContext}Should not present in output{_tested.EndContext}", databaseContext);

            Assert.AreEqual(string.Empty, result);
        }
        public void ProcessContextShouldReturnAnEmptyValueWhenColumnIsNotAutoGeneratedValue()
        {
            var databaseContext = new ProcessorDatabaseContext()
            {
                Column = new ColumnModelForTest()
                {
                    IsAutoGeneratedValue = false
                },
            };
            var actual = _tested.ProcessContext($"{_tested.StartContext}HelloWorld{_tested.EndContext}", databaseContext);

            Assert.AreEqual(String.Empty, actual);
        }
Ejemplo n.º 23
0
        public void ProcessContextShouldReturnAnContextContentWhenTheColumnIsIndexed()
        {
            var databaseContext = new ProcessorDatabaseContext()
            {
                Column = new ColumnModelForTest()
                {
                    IsIndexed = true
                }
            };
            var expected = "HelloWorld";
            var actual   = _tested.ProcessContext($"{_tested.StartContext}{expected}{_tested.EndContext}", databaseContext);

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 24
0
        public void ShouldReturnColumnName()
        {
            var expected        = "HelloWorldColumnName";
            var databaseContext = new ProcessorDatabaseContext()
            {
                Column = new ColumnModelForTest()
                {
                    Name = expected
                }
            };
            var actual = _tested.ProcessContext($"{_tested.Signature}", databaseContext);

            Assert.AreEqual(expected, actual);
        }
 public void ShouldThrowAnExceptionWhenColumnModelListIsNullInTableModel()
 {
     Assert.Throws <Exception>(() =>
     {
         var databaseContext = new ProcessorDatabaseContext()
         {
             Table = new TableModel()
             {
                 Columns = null
             }
         };
         _tested.ProcessContext("Hello World !", databaseContext);
     });
 }
 public void ProcessContextShouldReturnAnEmptyStringWhenTheColumnModelIsNotTheLastColumnModel()
 {
     var columnModel = new ColumnModelForTest() { };
     var databaseContext = new ProcessorDatabaseContext()
     {
         Column = columnModel,
         Table = new TableModelForTest()
         {
             Columns = new List<IColumnModel>() { columnModel, new ColumnModelForTest() { Name = "Another Column" } }
         }
     };
     var actual = _tested.ProcessContext($"{_tested.StartContext}HelloWorld{_tested.EndContext}",databaseContext);
     Assert.AreEqual(string.Empty, actual);
 }
        public void ProcessContextShouldReturnAnInnerContextValueWhenColumnIsAutoGeneratedValue()
        {
            var databaseContext = new ProcessorDatabaseContext()
            {
                Column = new ColumnModelForTest()
                {
                    IsAutoGeneratedValue = true
                },
            };
            var expected = "HelloWorld";
            var actual   = _tested.ProcessContext($"{_tested.StartContext}{expected}{_tested.EndContext}", databaseContext);

            Assert.AreEqual(expected, actual);
        }
        public void ShouldReturnContextContentWhenColumnIsNotNullable()
        {
            string expectedContent = "Should be present in output";
            var    databaseContext = new ProcessorDatabaseContext()
            {
                Column = new ColumnModelForTest()
                {
                    IsNotNull = true,
                }
            };
            var result = _tested.ProcessContext($"{_tested.StartContext}{expectedContent}{_tested.EndContext}", databaseContext);

            Assert.AreEqual(expectedContent, result);
        }
Ejemplo n.º 29
0
        public void ProcessedContextShouldBeDefaultAutoIndexWhenParentTableIsNull()
        {
            var columnModel = new ColumnModelForTest()
            {
                IsAutoGeneratedValue = true
            };
            var databaseContext = new ProcessorDatabaseContext()
            {
                Column = columnModel,
                Table  = null
            };
            var processedContext = _tested.ProcessContext($"{_tested.StartContext}{_tested.EndContext}", databaseContext);

            Assert.AreEqual($"{_tested.DefaultIndex}", processedContext);
        }
Ejemplo n.º 30
0
        public void ShouldReplaceTheValueMaxSizeSignatureByValueMaxSizeValue()
        {
            int    valueMaxSize    = _random.Next();
            string StringContext   = _tested.Signature;
            string expected        = $"{valueMaxSize}";
            var    databaseContext = new ProcessorDatabaseContext()
            {
                Column = new ColumnModelForTest()
                {
                    ValueMaxSize = valueMaxSize
                }
            };
            var actual = _tested.ProcessContext(StringContext, databaseContext);

            Assert.AreEqual(expected, actual);
        }