Exemplo n.º 1
0
        public void TryCompositeFormatDate_GivenString_FormatSuccessfully()
        {
            const string   compositeFormat = "{0}-{1}-{2}";
            DateTimeOffset now             = DateTimeOffset.Now;

            Assert.IsTrue(
                EnhancedPatternMatching.TryCompositeFormatDate(now.ToString(), compositeFormat, out string?result));

            Assert.AreEqual <string>(now.ToString("yyyy-M-dd"), result !);
        }
Exemplo n.º 2
0
        public void TryFormatDateTest_GivenString_FormatSuccessfully()
        {
            const string   format = "MMMM dd, yyyy";
            DateTimeOffset now    = DateTimeOffset.Now;

            Assert.IsTrue(
                EnhancedPatternMatching.TryFormatDate(now.ToString(), format, out string?result));

            Assert.AreEqual <string>(now.ToString(format), result !);
        }
Exemplo n.º 3
0
        public void TryConvertToNotNull_GivenNull_ReturnFalse()
        {
            string?test;

            test = Guid.NewGuid().ToString();
            test ??= null;
            Console.WriteLine(test);
            object?text = null;

            Assert.IsFalse(EnhancedPatternMatching.TryConvertToNotNullable(ref text));
            text = "Inigo Montoya";
            Assert.IsTrue(EnhancedPatternMatching.TryConvertToNotNullable(ref text));
        }
Exemplo n.º 4
0
 public void TryCompositeFormatDate_GivenUnconvertableDateText_FormatFails()
 {
     Assert.IsFalse(
         EnhancedPatternMatching.TryCompositeFormatDate("Inigo Montoya", "", out string?result));
 }
Exemplo n.º 5
0
        public void IsWeekend_GivenWeekdayDate_ReturnTrue()
        {
            DateTime dateTime = new DateTime(2019, 9, 23);

            Assert.IsFalse(EnhancedPatternMatching.IsWeekend(dateTime));
        }
Exemplo n.º 6
0
 public void TryCompositeFormatDate_GivenObject_FormatFails()
 {
     Assert.IsFalse(
         EnhancedPatternMatching.TryCompositeFormatDate(new object(), "", out string?result));
 }