public void Constructor_Null() { DataKeyCollection dkc = new DataKeyCollection(null); Assert.IsNotNull(dkc, "ctor"); Assert.IsFalse(dkc.IsReadOnly, "IsReadOnly"); Assert.IsFalse(dkc.IsSynchronized, "IsSynchronized"); Assert.IsTrue(Object.ReferenceEquals(dkc, dkc.SyncRoot), "SyncRoot"); // unusable Assert.AreEqual(0, dkc.Count, "NRE"); }
public void Constructor_Empty() { ArrayList al = new ArrayList(); DataKeyCollection dkc = new DataKeyCollection(al); Assert.AreEqual(0, dkc.Count, "Count0"); Assert.IsFalse(dkc.IsReadOnly, "IsReadOnly"); Assert.IsFalse(dkc.IsSynchronized, "IsSynchronized"); Assert.IsTrue(Object.ReferenceEquals(dkc, dkc.SyncRoot), "SyncRoot"); al.Add(String.Empty); Assert.AreEqual(1, dkc.Count, "Count++"); // note: no add/insert/remove/... Assert.AreEqual(String.Empty, dkc[0], "[0]"); al.Clear(); Assert.AreEqual(0, dkc.Count, "Count--"); // we can add/remove from the original ArrayList }
public void RpQuestionsGrid_itemcommand_DeleteCommand_DeleteCalled(int selectedPageIndex) { // Arrange var dataKeyCol = new DataKeyCollection(new ArrayList() { 1 }); ShimBaseDataList.AllInstances.DataKeysGet = (d) => dataKeyCol; var dlPagedList = new DataList(); dlPagedList.SelectedIndex = selectedPageIndex; _defineQuestionsPrivateObject.SetField("dlPages", BindingFlags.Instance | BindingFlags.NonPublic, dlPagedList); var pagesList = new List <Page>(); pagesList.Add(new Page() { PageID = 500 }); ECN_Framework_BusinessLayer.Collector.Fakes.ShimPage.GetBySurveyIDInt32User = (i, u) => pagesList; ECN_Framework_BusinessLayer.Collector.Fakes.ShimPage.BranchFromExistsInt32User = (i, u) => true; _defineQuestionsPrivateObject.SetField("chkShowAllPages", BindingFlags.Instance | BindingFlags.NonPublic, new CheckBox() { Checked = false }); _defineQuestionsInstance.SurveyID = 1; InitTest_RpQuestionsGrid_Itemcommand(question: out Question question, page: out Page page, pageHeader: "pageHeader", pageNumber: 1, questionFormat: string.Empty, commandArg: "10", commandName: "delete", repeaterArg: out RepeaterCommandEventArgs e); // Act _defineQuestionsInstance.rpQuestionsGrid_itemcommand(null, e); // Assert var dropQDataSource = dlPagedList.DataSource as IList; var pageResult = dropQDataSource[0]; dropQDataSource.ShouldSatisfyAllConditions( () => dropQDataSource.ShouldNotBeNull(), () => dropQDataSource.Count.ShouldBeGreaterThan(0), () => pageResult.GetType().GetProperty("PageID").GetValue(pageResult).ToString().ShouldBe("500"), () => _questionDeleteMethodCallCount.ShouldBe(1)); }