Exemplo n.º 1
0
        /// <summary>
        /// WA DNR fiscal year boundary is June 30th.
        /// </summary>
        /// <param name="qtr"></param>
        /// <param name="calendarYear"></param>
        /// <returns></returns>
        public static DateTime GetFirstDateInFiscalQuarter(FiscalQuarter qtr, int calendarYear)
        {
            if (qtr == FiscalQuarter.First)
            {
                // 1st FiscalQuarter = July 1 to Sept 30
                return(new DateTime(calendarYear, 7, 1));
            }
            if (qtr == FiscalQuarter.Second)
            {
                // 2nd FiscalQuarter = October 1 to December 31
                return(new DateTime(calendarYear, 10, 1));
            }
            if (qtr == FiscalQuarter.Third)
            {
                // 3rd FiscalQuarter = January 1 to  March 31
                return(new DateTime(calendarYear, 1, 1));
            }
            if (qtr == FiscalQuarter.Fourth)
            {
                // 4th FiscalQuarter = April 1 to June 30
                return(new DateTime(calendarYear, 4, 1));
            }

            throw new InvalidDataException($"Unknown FiscalQuarter: {qtr.ToString()}");
        }
        public static void ToString___Should_return_friendly_string_representation_of_object___When_called()
        {
            // Arrange
            var systemUnderTest1 = new FiscalQuarter(2017, QuarterNumber.Q1);
            var systemUnderTest2 = new FiscalQuarter(2017, QuarterNumber.Q4);

            // Act
            var toString1 = systemUnderTest1.ToString();
            var toString2 = systemUnderTest2.ToString();

            // Assert
            toString1.Should().Be("1Q2017");
            toString2.Should().Be("4Q2017");
        }