Ejemplo n.º 1
0
        public void ReelFixRotations_SetNextValue_WorksAsExpected()
        {
            DayOfWeek[] days = new DayOfWeek[] { DayOfWeek.Monday, DayOfWeek.Thursday, DayOfWeek.Wednesday, DayOfWeek.Monday, DayOfWeek.Sunday };
            ReelFixRotations <DayOfWeek> test = new ReelFixRotations <DayOfWeek>(days, DayOfWeek.Monday, 2);

            //Początkowo maszyna powinna się zatrzymać na drugim poniedziałku, dlatego jak jeszcze raz będziemy chcieli go ustawić, to powinien być to "pierwszy" poniedziałek.
            IEnumerable <DayOfWeek> spinHistory = test.SetNextValue(DayOfWeek.Monday);

            //Sprawdzamy najpierw pozycję, czy w ogóle  jest dobra
            IReelPosition <DayOfWeek> position = test.GetCurrentPossition();

            position.Current.Should().Be(DayOfWeek.Monday);
            position.Next.Should().Be(DayOfWeek.Thursday);
            position.Previous.Should().Be(DayOfWeek.Sunday);

            DayOfWeek[] properSpinHistory = new DayOfWeek[] {
                //Pierwszy pełen obrót
                DayOfWeek.Sunday, DayOfWeek.Monday, DayOfWeek.Thursday, DayOfWeek.Wednesday, DayOfWeek.Monday,
                //Drugi pełen obrót
                DayOfWeek.Sunday, DayOfWeek.Monday, DayOfWeek.Thursday, DayOfWeek.Wednesday, DayOfWeek.Monday,
                //Normalne dojście do zadanego elementu
                DayOfWeek.Sunday, DayOfWeek.Monday
            };

            spinHistory.Should().BeEquivalentTo(properSpinHistory, options => options.WithStrictOrdering(), "Kolekcje powinny być takie same.");

            this.Invoking(t => test.SetNextValue(DayOfWeek.Friday)).Should().Throw <InvalidOperationException>().And.Message.Should().ContainEquivalentOf($"does not contains");
        }
Ejemplo n.º 2
0
        public void ReelFixRotations_GetCurrentPossition_WorksAsExpected()
        {
            DayOfWeek[] days = new DayOfWeek[] { DayOfWeek.Monday, DayOfWeek.Thursday, DayOfWeek.Wednesday, DayOfWeek.Monday, DayOfWeek.Sunday };
            ReelFixRotations <DayOfWeek> test = new ReelFixRotations <DayOfWeek>(days, DayOfWeek.Monday, 3);

            IReelPosition <DayOfWeek> position = test.GetCurrentPossition();

            //Powinien zostać wybrany najdalszy wskazany symbol, startujemy od 0, więc powinien być drugi poniedziałek na liście
            position.Current.Should().Be(DayOfWeek.Monday);
            position.Next.Should().Be(DayOfWeek.Sunday);
            position.Previous.Should().Be(DayOfWeek.Wednesday);
        }