Itenso.TimePeriod.TimePeriodCollection.IndexOf C# (CSharp) Method

IndexOf() public method

public IndexOf ( ITimePeriod item ) : int
item ITimePeriod
return int
        public virtual int IndexOf( ITimePeriod item )
        {
            if ( item == null )
            {
                throw new ArgumentNullException( "item" );
            }
            return periods.IndexOf( item );
        }

Usage Example

コード例 #1
0
        public void IndexOfTest()
        {
            DateTime now = ClockProxy.Clock.Now;
            SchoolDay schoolDay = new SchoolDay( now );
            TimePeriodCollection timePeriods = new TimePeriodCollection();

            Assert.AreEqual( timePeriods.IndexOf( new TimeRange() ), -1 );
            Assert.AreEqual( timePeriods.IndexOf( new TimeBlock() ), -1 );

            timePeriods.AddAll( schoolDay );

            Assert.AreEqual( timePeriods.IndexOf( schoolDay.Lesson1 ), 0 );
            Assert.AreEqual( timePeriods.IndexOf( schoolDay.Break1 ), 1 );
            Assert.AreEqual( timePeriods.IndexOf( schoolDay.Lesson2 ), 2 );
            Assert.AreEqual( timePeriods.IndexOf( schoolDay.Break2 ), 3 );
            Assert.AreEqual( timePeriods.IndexOf( schoolDay.Lesson3 ), 4 );
            Assert.AreEqual( timePeriods.IndexOf( schoolDay.Break3 ), 5 );
            Assert.AreEqual( timePeriods.IndexOf( schoolDay.Lesson4 ), 6 );

            timePeriods.Remove( schoolDay.Lesson1 );
            Assert.AreEqual( timePeriods.IndexOf( schoolDay.Lesson1 ), -1 );
        }
All Usage Examples Of Itenso.TimePeriod.TimePeriodCollection::IndexOf