public void AddRowObject_GetsExpectedRowId()
        {
            FormObject formObject = new FormObject()
            {
                FormId            = "1",
                MultipleIteration = true
            };

            formObject.CurrentRow = new RowObject("1||1");
            formObject.OtherRows.Add(new RowObject("1||2"));
            // Intentional gap in numbering
            formObject.OtherRows.Add(new RowObject("1||4"));
            formObject.OtherRows.Add(new RowObject("1||5"));
            formObject.OtherRows.Add(new RowObject("1||6"));
            formObject.OtherRows.Add(new RowObject("1||7"));
            formObject.OtherRows.Add(new RowObject("1||8"));
            formObject.OtherRows.Add(new RowObject("1||9"));
            formObject.OtherRows.Add(new RowObject("1||10"));
            formObject.OtherRows.Add(new RowObject("1||11"));
            formObject.OtherRows.Add(new RowObject("1||12"));
            formObject.OtherRows.Add(new RowObject("1||13"));
            formObject.OtherRows.Add(new RowObject("1||14"));
            formObject.OtherRows.Add(new RowObject("1||15"));

            formObject = (FormObject)OptionObjectHelpers.AddRowObject(formObject, new RowObject());   // Gap in series
            formObject = (FormObject)OptionObjectHelpers.AddRowObject(formObject, new RowObject());   // End of series

            Assert.IsTrue(formObject.IsRowPresent("1||1"));
            Assert.IsTrue(formObject.IsRowPresent("1||2"));
            Assert.IsTrue(formObject.IsRowPresent("1||3"));     // Gap in series filled
            Assert.IsTrue(formObject.IsRowPresent("1||16"));    // Added to end of series
        }
Пример #2
0
        public void DeleteRowObject_FromFormObject_MI_RowId_IsFound()
        {
            RowObject rowObject1 = new RowObject
            {
                RowId = "2||1"
            };
            RowObject rowObject2 = new RowObject
            {
                RowId = "2||1"
            };
            FormObject formObject = new FormObject
            {
                FormId            = "2",
                MultipleIteration = true
            };

            formObject.CurrentRow = rowObject1;
            formObject.OtherRows.Add(rowObject2);

            formObject.DeleteRowObject(rowObject1.RowId);
            formObject.DeleteRowObject(rowObject2.RowId);

            Assert.IsTrue(formObject.IsRowPresent(rowObject1.RowId));
            Assert.IsTrue(formObject.IsRowMarkedForDeletion(rowObject1.RowId));
            Assert.IsTrue(formObject.IsRowPresent(rowObject2.RowId));
            Assert.IsTrue(formObject.IsRowMarkedForDeletion(rowObject2.RowId));
        }
        public void AddRowObject_ToFormObject_MI_Success()
        {
            string     formId     = "1";
            string     expected1  = "1||1";
            string     expected2  = "1||2";
            RowObject  rowObject1 = new RowObject();
            RowObject  rowObject2 = new RowObject();
            FormObject formObject = new FormObject()
            {
                FormId            = formId,
                MultipleIteration = true
            };

            formObject = (FormObject)OptionObjectHelpers.AddRowObject(formObject, rowObject1);
            formObject = (FormObject)OptionObjectHelpers.AddRowObject(formObject, rowObject2);
            Assert.IsTrue(formObject.IsRowPresent(expected1));
            Assert.AreEqual(expected1, formObject.CurrentRow.RowId);
            Assert.IsTrue(formObject.IsRowPresent(expected2));
            Assert.AreEqual(expected2, formObject.OtherRows[0].RowId);
        }
        public void IsRowPresent_FormObject_FormsNull_Error()
        {
            // Arrange
            string     rowId      = "1||1";
            FormObject formObject = null;

            // Act
            bool actual = formObject.IsRowPresent(rowId);

            // Assert
            Assert.IsTrue(actual);
        }
        public void AddRowObject_TooManyRowsAdded()
        {
            FormObject formObject = new FormObject()
            {
                FormId            = "1",
                MultipleIteration = true
            };

            formObject.AddRowObject(new RowObject());       // Row 1 = CurrentRow

            int rowsToAdd = 9997;                           // Fill all available rows except 1

            for (int i = 0; i < rowsToAdd; ++i)
            {
                // Replace with get next RowId (if fast enough)
                string rowId = formObject.FormId + "||" + (i + 2).ToString();
                formObject.OtherRows.Add(new RowObject(rowId));
            }

            Assert.IsTrue(formObject.IsRowPresent("1||1"));     // Beginning of series
            Assert.IsTrue(formObject.IsRowPresent("1||2"));
            Assert.IsTrue(formObject.IsRowPresent("1||3"));
            Assert.IsTrue(formObject.IsRowPresent("1||9998"));

            formObject.AddRowObject(new RowObject());           // Add last row. Should succeed.
            Assert.IsTrue(formObject.IsRowPresent("1||9999"));  // Last of series

            formObject.AddRowObject(new RowObject());           // Add 1 row too many. Should cause error.
            Assert.IsTrue(formObject.IsRowPresent("1||10000")); // Too many rows, should have triggered Exception when added
        }
        public void IsRowPresent_FormObject_RowIdEmpty_Error()
        {
            // Arrange
            string rowId      = "";
            var    rowObject  = new RowObject();
            var    formObject = new FormObject()
            {
                CurrentRow = rowObject
            };

            // Act
            bool actual = formObject.IsRowPresent(rowId);

            // Assert
            Assert.IsTrue(actual);
        }
        public void IsRowPresent_FormObject_IsFalse()
        {
            // Arrange
            string rowId      = "1||1";
            var    rowObject  = new RowObject();
            var    formObject = new FormObject()
            {
                CurrentRow = rowObject
            };

            // Act
            bool actual = formObject.IsRowPresent(rowId);

            // Assert
            Assert.IsFalse(actual);
        }
Пример #8
0
        public void DeleteRowObject_FromFormObject_RowId_IsFound()
        {
            RowObject rowObject = new RowObject
            {
                RowId = "1||1"
            };
            FormObject formObject = new FormObject
            {
                FormId            = "1",
                MultipleIteration = false
            };

            formObject.CurrentRow = rowObject;

            formObject.DeleteRowObject(rowObject.RowId);

            Assert.IsTrue(formObject.IsRowPresent(rowObject.RowId));
            Assert.IsTrue(formObject.IsRowMarkedForDeletion(rowObject.RowId));
        }
        public void DeleteRowObject_FormObject_MI_RowObject_IsNotFound()
        {
            RowObject rowObject = new RowObject
            {
                RowId = "2||1"
            };
            RowObject rowObject2 = new RowObject
            {
                RowId = "2||2"
            };
            FormObject formObject = new FormObject
            {
                FormId            = "2",
                MultipleIteration = true
            };

            formObject.CurrentRow = rowObject;

            formObject.DeleteRowObject(rowObject2);

            Assert.IsTrue(formObject.IsRowPresent(rowObject2.RowId));
            Assert.IsTrue(formObject.IsRowMarkedForDeletion(rowObject2.RowId));
        }