Exemple #1
0
        public void CannotSetPersonListToInvalidLength()
        {
            var deskRandomizer = new DeskRandomizer(4);
            var testArray      = new int[5];

            Assert.Throws <ArgumentOutOfRangeException>(() => deskRandomizer.People = testArray);
        }
Exemple #2
0
        public void FinalArrangementShouldBePopulated()
        {
            var deskRandomizer = new DeskRandomizer(3);

            foreach (var element in deskRandomizer.FinalArrangement)
            {
                Assert.Equal(-1, element);
            }
        }
Exemple #3
0
        public void PersonListShouldBePopulated()
        {
            var deskRandomizer = new DeskRandomizer(4);

            foreach (var person in deskRandomizer.People)
            {
                Assert.True(person > 0);
            }
        }
Exemple #4
0
        public void AllocatePlacesPeopleInFinalAllocation()
        {
            var deskRandomizer = new DeskRandomizer(6);

            deskRandomizer.Allocate(deskRandomizer.People.ToList());

            Assert.Equal(new List <int> {
                1, 4, 2, 5, 3, 6
            }.ToArray(), deskRandomizer.FinalArrangement);
        }
Exemple #5
0
        public void AllocatePlacesPeopleInWithNoPreviousNeighbours()
        {
            var deskRandomizer = new DeskRandomizer(6);

            deskRandomizer.Allocate(deskRandomizer.People.ToList());
            var expected = new List <int> {
                1, 4, 2, 5, 3, 6
            }.ToArray();

            Assert.Equal(expected, deskRandomizer.FinalArrangement);
        }
Exemple #6
0
        public void PlacesLastPersonCorrectlyWhenLastPersonShouldBeFirstPlace()
        {
            var deskRandomizer = new DeskRandomizer(6);

            deskRandomizer.Allocate(new List <int> {
                4, 3, 6, 5, 1, 2
            });

            Assert.Equal(new List <int> {
                2, 6, 3, 5, 1, 4
            }.ToArray(), deskRandomizer.FinalArrangement);
        }
Exemple #7
0
        public void PlacesLastPersonCorrectlyWhenLastPersonShouldBeSecondLastPlace()
        {
            var deskRandomizer = new DeskRandomizer(6);

            deskRandomizer.Allocate(new List <int> {
                1, 5, 3, 6, 4, -1
            });

            deskRandomizer.PlaceLastPerson(2);
            Assert.Equal(new List <int> {
                1, 5, 3, 6, 2, 4
            }.ToArray(), deskRandomizer.FinalArrangement);
        }
Exemple #8
0
        public void HasPreviousNeighboursReturnsTrueWithPreviousNeighboursWrapped()
        {
            var deskRandomizer = new DeskRandomizer(3);

            var resultLeft = deskRandomizer.HasPreviousNeighbours(0, 2, new List <int> {
                2, 7, 1
            }.ToArray());
            var resultRight = deskRandomizer.HasPreviousNeighbours(2, 1, new List <int> {
                2, 7, 1
            }.ToArray());

            Assert.True(resultLeft);
            Assert.True(resultRight);
        }
Exemple #9
0
        public void HasPreviousNeighboursReturnsTrueWithPreviousNeighboursOnLeft()
        {
            var deskRandomizer = new DeskRandomizer(3);

            var resultHigher = deskRandomizer.HasPreviousNeighbours(1, 3, new List <int> {
                2, 3, 7
            }.ToArray());
            var resultLower = deskRandomizer.HasPreviousNeighbours(1, 3, new List <int> {
                2, 3, 7
            }.ToArray());

            Assert.True(resultHigher);
            Assert.True(resultLower);
        }
Exemple #10
0
        public void AllocatePlacesPeopleInWithNoPreviousNeighboursWithShuffle()
        {
            var deskRandomizer = new DeskRandomizer(11);

            deskRandomizer.ShufflePeople();
            deskRandomizer.Allocate(deskRandomizer.People.ToList());

            var passed = true;

            for (var i = 0; i < 11; i++)
            {
                if (deskRandomizer.HasPreviousNeighbours(i, deskRandomizer.FinalArrangement[i], deskRandomizer.FinalArrangement))
                {
                    Assert.Equal(new List <int> {
                        1, 4, 2, 5, 3, 6
                    }.ToArray(), deskRandomizer.BeforePlacement);
                    Assert.False(true);
                }

                ;
            }
        }
Exemple #11
0
        public void PersonListShouldBeUnique()
        {
            var deskRandomizer = new DeskRandomizer(4);

            Assert.Equal(4, deskRandomizer.People.Distinct().Count());
        }
Exemple #12
0
        public void PersonListShouldBeInitialized()
        {
            var deskRandomizer = new DeskRandomizer(3);

            Assert.Equal(3, deskRandomizer.People.Length);
        }
Exemple #13
0
        public void CreatePersonListShouldCreateAnArrayWithGivenInput()
        {
            var deskRandomizer = new DeskRandomizer(3);

            Assert.Equal(3, deskRandomizer.FinalArrangement.Length);
        }