Beispiel #1
0
        public void GetYearInfo_should_be_callable_indirectly()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                PJapaneseLunisolarCalendar.GetYearInfoInt32Int32().Body = (@this, lunarYear, index) => 41;

                // Act
                var calendar = new JapaneseLunisolarCalendar();
                var actual   = calendar.GetLeapMonth(26, calendar.Eras[0]);

                // Assert
                // Before setting indirection: 平成 26 年 閏 9
                Assert.AreEqual(42, actual);
            }
        }
Beispiel #2
0
        public void GetYearInfo_should_be_callable_indirectly_against_only_specified_instance()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                var calendar = new JapaneseLunisolarCalendar();

                var calendarProxy = new PProxyJapaneseLunisolarCalendar();
                calendarProxy.GetEraDateTime().Body             = (@this, time) => calendar.Eras[0];
                calendarProxy.GetGregorianYearInt32Int32().Body = (@this, year, era) => 2000;
                calendarProxy.GetYearInfoInt32Int32().Body      = (@this, lunarYear, index) => 41;
                var calendar_sut = (JapaneseLunisolarCalendar)calendarProxy;

                // Act
                var actual = calendar_sut.GetLeapMonth(26, calendar.Eras[0]);

                // Assert
                Assert.AreEqual(42, actual);
                Assert.AreNotEqual(calendar.GetLeapMonth(26, calendar.Eras[0]), actual);
            }
        }