コード例 #1
0
        public void Get_nepaliDate_in_past(int year, int month, int day, string expected)
        {
            var dateTimeService = Substitute.For <ISystemTime>();

            var mockDate = new DateTime(year, month, day);

            dateTimeService.GetDateTime().Returns(mockDate);

            var    calendarService = new NepaliCalendarService(dateTimeService);
            string nepaliDate      = calendarService.GetNepaliDate(mockDate);

            nepaliDate.ShouldBe(expected);
        }
コード例 #2
0
        public void Get_nepaliDate_With_DateInfo()
        {
            var            info            = TZConvert.GetTimeZoneInfo("Nepal Standard Time");
            DateTimeOffset localServerTime = DateTimeOffset.Now;
            DateTimeOffset localTime       = TimeZoneInfo.ConvertTime(localServerTime, info);

            var dateTimeService = Substitute.For <ISystemTime>();

            var mockDate = localTime.Date;

            dateTimeService.GetDateTime().Returns(mockDate);

            var calendarService = new NepaliCalendarService(dateTimeService);

            string nepaliDate = calendarService.GetNepaliDate(mockDate);

            nepaliDate.ShouldNotBe(null);
        }