Esempio n. 1
0
        public void BtnCopy_Click_Success()
        {
            // Arrange
            InitilizeTestObjects();
            QueryString.Add("GroupID", "1");
            var drpSourceGroup = privateObject.GetFieldOrProperty("drpSourceGroup") as DropDownList;

            drpSourceGroup.Items.Add("1");
            drpSourceGroup.SelectedValue = "1";
            var gvUDF = privateObject.GetFieldOrProperty("gvUDF") as GridView;

            gvUDF.DataKeyNames = new string[] { "id" };
            gvUDF.DataSource   = new DataTable {
                Columns = { "id" }, Rows = { { "1" } }
            };
            gvUDF.DataBind();
            gvUDF.Rows[0].Cells[0].Controls.Add(new CheckBox {
                ID = "chkCopyUDF", Checked = true
            });
            gvUDF.Rows[0].Cells[0].Controls.Add(new Label {
                ID = "lblName"
            });
            ShimGroupDataFields.GetByIDInt32Int32User = (p1, p2, p3) => new GroupDataFields {
                DatafieldSetID = 1
            };
            ShimDataFieldSets.GetByGroupIDNameInt32String = (p1, p2) => null;
            ShimDataFieldSets.SaveDataFieldSetsUser       = (p1, p2) => 0;
            ShimGroupDataFields.SaveGroupDataFieldsUser   = (p1, p2) => 2;
            ShimGroupDataFieldsDefault.GetByGDFIDInt32    = (p) => new GroupDataFieldsDefault {
                GDFID = 1
            };
            GroupDataFieldsDefault result = null;

            ShimGroupDataFieldsDefault.SaveGroupDataFieldsDefault  = (p) => result = p;
            ShimDataFieldSets.GetByDataFieldsetIDInt32Int32Boolean = (p1, p2, p3) => new DataFieldSets {
            };
            ShimDataFieldSets.GetByGroupIDInt32 = (p) => new List <DataFieldSets> {
                new DataFieldSets {
                }
            };
            ShimGroupDataFields.GetByGroupIDInt32UserBoolean = (p1, p2, p3) => new List <GroupDataFields> {
                new GroupDataFields {
                }
            };

            // Act
            privateObject.Invoke("btnCopy_Click", new object[] { null, null });

            // Assert
            result.ShouldSatisfyAllConditions(
                () => result.ShouldNotBeNull(),
                () => result.GDFID.ShouldBe(2));
        }
Esempio n. 2
0
        public void Add_Button_Click_SystemValue_Success()
        {
            // Arrange
            InitilizeTestObjects();
            QueryString.Add("GroupID", "1");
            var drpTransactionName = privateObject.GetFieldOrProperty("drpTransactionName") as DropDownList;

            drpTransactionName.Items.Add("1");
            drpTransactionName.SelectedValue            = "1";
            ShimGroupDataFields.SaveGroupDataFieldsUser = (p1, p2) => 0;
            var chkUseDefaultValue = privateObject.GetFieldOrProperty("chkUseDefaultValue") as CheckBox;

            chkUseDefaultValue.Checked = true;
            var ddlDefaultType = privateObject.GetFieldOrProperty("ddlDefaultType") as DropDownList;

            ddlDefaultType.Items.Add("system");
            ddlDefaultType.SelectedValue = "system";
            var ddlSystemValues = privateObject.GetFieldOrProperty("ddlSystemValues") as DropDownList;

            ddlSystemValues.Items.Add("systemTest");
            ddlSystemValues.SelectedValue = "systemTest";
            GroupDataFieldsDefault result = null;

            ShimGroupDataFieldsDefault.SaveGroupDataFieldsDefault = (p) => result = p;
            ShimGroupDataFields.GetByGroupIDInt32UserBoolean      = (p1, p2, p3) => new List <GroupDataFields> {
                new GroupDataFields {
                }
            };

            // Act
            privateObject.Invoke("add_button_Click", new object[] { null, null });

            // Assert
            result.ShouldSatisfyAllConditions(
                () => result.ShouldNotBeNull(),
                () => result.DataValue.ShouldBeEmpty(),
                () => result.SystemValue.ShouldBe("systemTest"));
        }