Beispiel #1
0
        public void CantRemoveHarmonicFromEmptyListByIndexAndThrowException()
        {
            var testObj = new TestObject();
            var main    = new HarmonicsContainer();

            main.ActiveHarmonicChanged += testObj.OnActiveHarmonicChanged;
            main.HarmonicDeleted       += testObj.OnHarmonicDeleted;
            Assert.ThrowsException <IndexOutOfRangeException>(() => main.DeleteActiveHarmonic(0));
            Assert.ThrowsException <IndexOutOfRangeException>(() => main.DeleteActiveHarmonic(-1));
            Assert.ThrowsException <IndexOutOfRangeException>(() => main.DeleteActiveHarmonic(1));
        }
Beispiel #2
0
        public void CantRemoveHarmonicFromNotEmptyListByIndexIfIndexLessThen0OrEqualesOrMoreThanCountAndThrowsException()
        {
            var testObj = new TestObject();
            var main    = new HarmonicsContainer();

            main.ActiveHarmonicChanged += testObj.OnActiveHarmonicChanged;
            main.HarmonicDeleted       += testObj.OnHarmonicDeleted;
            var h = new Harmonic();

            main.AddNewHarmonic(h);
            Assert.ThrowsException <IndexOutOfRangeException>(() => main.DeleteActiveHarmonic(-1));
            Assert.ThrowsException <IndexOutOfRangeException>(() => main.DeleteActiveHarmonic(1));
            Assert.ThrowsException <IndexOutOfRangeException>(() => main.DeleteActiveHarmonic(2));
        }
Beispiel #3
0
        public void SaveHarmonicsContainerInValidStateWhenItstateHasChangedSinceHarmonicDeletedEvent()
        {
            var main           = new HarmonicsContainer();
            var testObj        = new TestObject(main);
            var newActiveIndex = 2;

            testObj.newActiveIndex = newActiveIndex;

            main.ActiveHarmonicChanged += testObj.OnActiveHarmonicChanged;
            main.HarmonicDeleted       += testObj.ChangeHarmonicSelectedIndexOnHarmonicDeleted;
            var h = new Harmonic();

            main.AddNewHarmonic(h);
            main.AddNewHarmonic(h);
            main.AddNewHarmonic(h);
            main.DeleteActiveHarmonic(2);

            Assert.IsTrue(testObj.IsEventHarmonicDeletedInvoked);
            Assert.AreEqual(testObj.deletedIndex, 2);

            Assert.IsTrue(testObj.ExceptionWasThrownInSelectActiveHarmonicMethod);

            Assert.IsTrue(testObj.IsEventActiveHarmonicChangedInvoked);
            Assert.AreEqual(testObj.activeIndex, 1);
            Assert.IsFalse(main.IsEmpty());
        }
Beispiel #4
0
        public void CanRemoveHarmonicByIndexAndThenInvokeHarmonicDeltedAndActiveHarmonicChangedEvents()
        {
            var testObj = new TestObject();
            var main    = new HarmonicsContainer();

            main.ActiveHarmonicChanged += testObj.OnActiveHarmonicChanged;
            main.HarmonicDeleted       += testObj.OnHarmonicDeleted;
            var h = new Harmonic();

            main.AddNewHarmonic(h);
            main.DeleteActiveHarmonic(0);

            Assert.IsTrue(testObj.IsEventHarmonicDeletedInvoked);
            Assert.AreEqual(testObj.deletedIndex, 0);

            Assert.IsTrue(testObj.IsEventActiveHarmonicChangedInvoked);
            Assert.AreEqual(testObj.activeIndex, -1);
            Assert.IsTrue(main.IsEmpty());
        }
Beispiel #5
0
        public void CanRemoveFirstHarmonicFromNonEmptyListByIndexAndThenInvokeHarmonicDeletedAndActiveHarmonicsChangedEventsIfListAfterThatNotEmpty()
        {
            var testObj = new TestObject();
            var main    = new HarmonicsContainer();

            main.ActiveHarmonicChanged += testObj.OnActiveHarmonicChanged;
            main.HarmonicDeleted       += testObj.OnHarmonicDeleted;
            var h = new Harmonic();

            main.AddNewHarmonic(h);
            main.AddNewHarmonic(h);
            main.DeleteActiveHarmonic(0);

            Assert.IsTrue(testObj.IsEventHarmonicDeletedInvoked);
            Assert.AreEqual(testObj.deletedIndex, 0);

            Assert.IsTrue(testObj.IsEventActiveHarmonicChangedInvoked);
            Assert.AreEqual(testObj.activeIndex, 0);
            Assert.IsFalse(main.IsEmpty());
        }