Exemplo n.º 1
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());
        }
Exemplo n.º 2
0
        static void Main()
        {
            var mainWindow = new HarmonicsContainer();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm(mainWindow));
        }
Exemplo n.º 3
0
        public void CantGetHarmonicFromEmptyListByIndexAndThrowsException()
        {
            var testObj = new TestObject();
            var main    = new HarmonicsContainer();
            var h       = new Harmonic();

            Assert.ThrowsException <IndexOutOfRangeException>(() => main.GetHarmonicByIndex(0));
            Assert.ThrowsException <IndexOutOfRangeException>(() => main.GetHarmonicByIndex(-1));
            Assert.ThrowsException <IndexOutOfRangeException>(() => main.GetHarmonicByIndex(1));
        }
Exemplo n.º 4
0
        public void CantSelectHarmonicByIndexFromEmptyListAndThrowsException()
        {
            var testObj = new TestObject();
            var main    = new HarmonicsContainer();
            var h       = new Harmonic();

            main.ActiveHarmonicChanged += testObj.OnActiveHarmonicChanged;
            Assert.ThrowsException <IndexOutOfRangeException>(() => main.SelectHarmonicByIndex(0));
            Assert.ThrowsException <IndexOutOfRangeException>(() => main.SelectHarmonicByIndex(-1));
            Assert.ThrowsException <IndexOutOfRangeException>(() => main.SelectHarmonicByIndex(1));
        }
Exemplo n.º 5
0
        public void CantGetHarmonicFromNonEmptyListByIndexIfIndexLessThan0OrEqualsOrMoreThanCountAndThrowsException()
        {
            var testObj = new TestObject();
            var main    = new HarmonicsContainer();
            var h       = new Harmonic();

            main.AddNewHarmonic(h);

            Assert.ThrowsException <IndexOutOfRangeException>(() => main.GetHarmonicByIndex(-1));
            Assert.ThrowsException <IndexOutOfRangeException>(() => main.GetHarmonicByIndex(1));
        }
Exemplo n.º 6
0
        public void CanGetHarmonicFromNonEmptyListByIndexAndReturnHarmonic()
        {
            var testObj = new TestObject();
            var main    = new HarmonicsContainer();
            var h       = new Harmonic();

            main.AddNewHarmonic(h);
            var h1 = main.GetHarmonicByIndex(0);

            Assert.AreEqual(h1, h);
        }
Exemplo n.º 7
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));
        }
Exemplo n.º 8
0
        public void CantSelectHarmonicByIndexFromNonEmptyListIfIndexLessThan0OrEqualsToOrMoreThanCountAndThrowsException()
        {
            var testObj = new TestObject();
            var main    = new HarmonicsContainer();
            var h       = new Harmonic();

            main.AddNewHarmonic(h);
            main.ActiveHarmonicChanged += testObj.OnActiveHarmonicChanged;
            main.SelectHarmonicByIndex(0);

            Assert.ThrowsException <IndexOutOfRangeException>(() => main.SelectHarmonicByIndex(-1));
            Assert.ThrowsException <IndexOutOfRangeException>(() => main.SelectHarmonicByIndex(1));
        }
Exemplo n.º 9
0
        public void CanSelectHarmonicByIndexAndThenInvokeActiveHarmonicChangedEvent()
        {
            var testObj = new TestObject();
            var main    = new HarmonicsContainer();
            var h       = new Harmonic();

            main.AddNewHarmonic(h);
            main.ActiveHarmonicChanged += testObj.OnActiveHarmonicChanged;
            main.SelectHarmonicByIndex(0);

            Assert.IsTrue(testObj.IsEventActiveHarmonicChangedInvoked);
            Assert.AreEqual(testObj.activeIndex, 0);
        }
Exemplo n.º 10
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));
        }
Exemplo n.º 11
0
        public void CanAddNewHarmonicAndThenInvokeHarmonicAddedAndActiveHarmonicChangedEvents()
        {
            var testObj = new TestObject();
            var main    = new HarmonicsContainer();

            main.HarmonicAdded         += testObj.OnHarmonicAdded;
            main.ActiveHarmonicChanged += testObj.OnActiveHarmonicChanged;

            var h = new Harmonic();

            main.AddNewHarmonic(h);

            Assert.IsTrue(testObj.IsEventHarmonicAddedInvoked);
            Assert.AreEqual(testObj.addedIndex, 0);
            Assert.IsTrue(testObj.IsEventActiveHarmonicChangedInvoked);
            Assert.AreEqual(testObj.activeIndex, 0);
        }
Exemplo n.º 12
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());
        }
Exemplo n.º 13
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());
        }