Ejemplo n.º 1
0
        public void CanGenerateData_WhenGenerateDataFalse()
        {
            //given
            var columnPOCO = new MultilineTextColumnPOCO()
            {
                GenerateData = false
            };

            //then
            Assert.IsFalse(generator.CanGenerateData(columnPOCO));
        }
Ejemplo n.º 2
0
        public void GenerateData_ReturnsExactNumberOfRecords()
        {
            //given
            var columnPOCO = new MultilineTextColumnPOCO()
            {
                MinLength = 5,
                MaxLength = 15
            };
            var recordsCount = 123;
            //when
            var data = generator.GenerateData(columnPOCO, recordsCount);

            //then
            Assert.AreEqual(recordsCount, data.Count());
        }
Ejemplo n.º 3
0
        public void SyncModels()
        {
            //given
            var columnPOCO = new MultilineTextColumnPOCO();
            var columnVM   = new MultilineTextColumnVM()
            {
                MaxLength = 100,
                MinLength = 10
            };

            //when
            columnVM.SyncModels(columnPOCO);
            //then
            Assert.AreEqual(columnPOCO.MinLength, columnVM.MinLength);
            Assert.AreEqual(columnPOCO.MaxLength, columnVM.MaxLength);
        }
Ejemplo n.º 4
0
        public void TextColumnVM_FromPOCO()
        {
            //given
            var columnPOCO = new MultilineTextColumnPOCO()
            {
                InternalName = "test column name",
                DisplayName  = "test column display name",
                Required     = true,
                MaxLength    = 100,
                MinLength    = 10,
            };
            //when
            var columnVM = new MultilineTextColumnVM(columnPOCO);

            //then
            Assert.AreEqual(columnPOCO.InternalName, columnVM.InternalName);
            Assert.AreEqual(columnPOCO.DisplayName, columnVM.DisplayName);
            Assert.AreEqual(columnPOCO.Required, columnVM.Required);
            Assert.AreEqual(columnPOCO.MaxLength, columnVM.MaxLength);
            Assert.AreEqual(columnPOCO.MinLength, columnVM.MinLength);
        }
Ejemplo n.º 5
0
        public void GenerateData_ReturnsOnlyTextOfLengthSpecifiedInColumn()
        {
            //given
            var columnPOCO = new MultilineTextColumnPOCO()
            {
                MinLength = 5,
                MaxLength = 15
            };
            var recordsCount = 123;
            //when
            var data = generator.GenerateData(columnPOCO, recordsCount);

            //then
            foreach (var dataPiece in data)
            {
                Assert.IsInstanceOfType(dataPiece, typeof(string));
                var stringData = (string)dataPiece;
                Assert.IsTrue(stringData.Length <= columnPOCO.MaxLength);
                Assert.IsTrue(stringData.Length >= columnPOCO.MinLength);
            }
        }
Ejemplo n.º 6
0
        public void Validate_GenerateDataWhenRequired()
        {
            //given
            var columnPOCO = new MultilineTextColumnPOCO()
            {
                Required = true
            };
            var columnVM = new MultilineTextColumnVM()
            {
                InternalName = "test column name",
                GenerateData = false,
                MaxLength    = 100,
                MinLength    = 10
            };

            columnVM.SyncModels(columnPOCO);
            //when
            var validationResults = columnVM.Validate(null);

            //then
            Assert.AreEqual(1, validationResults.Count());
            Assert.IsTrue(validationResults.First().MemberNames.Contains(nameof(MultilineTextColumnVM.GenerateData)));
        }