コード例 #1
0
        public void ValidateSetsDefaultVariables()
        {
            TestPage page = new TestPage(HttpContext.Current);
            TestUserControl c1 = new TestUserControl();
            page.Controls.Add(c1);

            ConditionValidator v1 = new ConditionValidator("#page == #this.Page", null);
            ConditionValidator v2 = new ConditionValidator("#usercontrol == #this", null);

            Assert.IsTrue(c1.Validate(c1, v1, v2));
        }
コード例 #2
0
        public void StoresAndRetrievesModelItem()
        {
            TestSessionModelPersistenceMedium pm = new TestSessionModelPersistenceMedium();
            Control tuc = new TestUserControl("TucID");
            pm.SaveToMedium( tuc, this );
            // ensure key was generated by GetKey() and Item was added to storage
            Assert.AreEqual( this, pm.SessionItems["TucID"] );

            // ensure key was generated by GetKey() and Item is retrieved from storage
            Assert.AreEqual( this, pm.LoadFromMedium( tuc ) );
        }
コード例 #3
0
        public void SetResultSelectsCorrectResult()
        {
            MockRepository mocks = new MockRepository();
            TestUserControl uc = new TestUserControl();
            Result theResult = (Result)mocks.CreateMock(typeof(Result));

            using (mocks.Ordered())
            {
                theResult.Navigate(uc);
            }
            mocks.ReplayAll();

            uc.Results.Add("theResult", theResult);
            uc.SetResult("theResult");
            mocks.VerifyAll();
        }
コード例 #4
0
        public void SetResultBubblesUpHierarchyUntilFirstMatch()
        {
            MockRepository mocks = new MockRepository();
            TestUserControl c1 = new TestUserControl();
            Control c11 = new Control(); c1.Controls.Add(c11);
            TestUserControl c111 = new TestUserControl(c11);
            Result theResult = (Result)mocks.CreateMock(typeof(Result));

            using (mocks.Ordered())
            {
                // context is the control, that contains matching Result
                theResult.Navigate(c1);
            }
            mocks.ReplayAll();

            c1.Results.Add("theResult", theResult);
            c111.SetResult("theResult");
            mocks.VerifyAll();
        }
コード例 #5
0
 public void NoNullModelPersistenceMediumAllowed()
 {
     TestUserControl tuc = new TestUserControl();
     tuc.ModelPersistenceMedium = null;
 }
コード例 #6
0
 public void StoresAndLoadsModelUsingModelPersistenceMedium()
 {
     TestUserControl tuc = new TestUserControl();
     tuc.ModelPersistenceMedium = new DictionaryModelPersistenceMedium();
     tuc.SaveModelToPersistenceMedium( this );
     Assert.AreEqual(this, tuc.LoadModelFromPersistenceMedium());
 }
コード例 #7
0
 public void NoNullModelPersistenceMediumAllowed()
 {
     TestUserControl tuc = new TestUserControl();
     Assert.Throws<ArgumentNullException>(() => tuc.ModelPersistenceMedium = null);
 }