DateTimeTest



  • Bernie discovered a class named PspUntiTest. He could not see immediately what that was meant to test. Hence he opened it and found out:

    using System;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    
    namespace PsPlayerViewModel.Tests
    {
        [TestClass]
        public class PspUnitTest
        {
            [TestMethod]
            public void DateTimeTest()
            {
                Assert.IsTrue(DateTime.Now.Date.CompareTo(DateTime.Today) == 0, "DT-Compare failed.");
            }
        }
    }
    

    Congratulations, Kevin, you wrote a unit test!


  • Fake News

    @BernieTheBernie Hey, it's important to check your assumptions, and thanks to this test we know that the universe hasn't broken down.

    However, better don't run it on 11:59 PM in case it might run Now and Today just opposite of midnight...



  • @JBert said in DateTimeTest:

    Hey, it's important to check your assumptions

    I actually do have some unit tests for library functions. Because those libraries have changed assumptions over the years. Like libfmt with respect to number formatting.


Log in to reply