• Unit Testing Events with Anonymous Delegates in .NET 2.0

    How do you unit test your event code? You use Anonymous Delegates

    Here’s a sample unit test that I’ve created that makes use of this technique:

        \[TestMethod()\]
    
        public void UpdateTestTimesTest()
    
        {
    
            object expected = UniSA.UniSAnet.SmartMark.DataAccess.DataItemChangedEventArgs.ChangeType.Update;
    
            object actual = null;
    
            UniSA.UniSAnet.SmartMark.DataAccess.TestComponent.DataItemChanged += delegate(object sender, UniSA.UniSAnet.SmartMark.DataAccess.DataItemChangedEventArgs e)
    
            {
    
                actual = e.Change;
    
            };
    
            Test test = UniSA.UniSAnet.SmartMark.DataAccess.TestComponent.GetTest(UnitTestingTestId);
    
            test.MinutesAllowed += 1;
    
            UniSA.UniSAnet.SmartMark.DataAccess.TestComponent.UpdateTestTimes(test);
    
            Assert.AreEqual(expected, actual);
    
        }
    

  • Default content in ContentPlaceHolder is not replaced when it contains <%= %> tags

    I think I’ve found a bug (Broken link, was originally lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=f0a9000e-3ce5-46c2-b10f-343b8126a0c7) in ASP.NET Master Pages - if you try to include any <%= %> tags in a ContentPlaceHolder control on a Master Page, then it doesn’t get overidden by the content in the Content control.

  • Using CSS when JavaScript is disabled

    I’ve often worried about pages that use CSS to hide content, then allow JavaScript to dynamically show it again (eg. when you click on something), that if JavaScript was disabled, then there’s no way to show the content.

    Project Seven shows an example of how to use CSS and make sure content is viewable with or without JavaScript enabled.

    Click on the example to see how it works.