Пример #1
0
        public void GetOddNumbers_LimitIsGreaterThanZero_ReturnOddNumbersUpToLimit()
        {
            var result = _math.GetOddNumbers(5);

            Assert.That(result, Is.Not.Empty);
            Assert.That(result.Count(), Is.EqualTo(3));
            Assert.That(result, Is.EquivalentTo(new[] { 1, 3, 5 }));
        }
Пример #2
0
        public void GetOddNumbers_LimitIsGreaterThanZero_ReturnOddNumbersUpToLimit()
        {
            var result = math.GetOddNumbers(5);

            int[] expectedResult = new int[] { 1, 3, 5 };

            Assert.IsTrue(result.SequenceEqual(expectedResult));
        }
Пример #3
0
        public void Math_GetOddNumbers_LimitGreaterThanZero_ReturnOddNumbersUptoLimit()
        {
            var result = _math.GetOddNumbers(5);

            Assert.That(result, Is.EquivalentTo(new[] { 1, 3, 5 }));
            Assert.That(result, Is.Ordered);
            Assert.That(result, Is.Unique);
        }
Пример #4
0
        public void GetOddNumbers_LimitIsGreaterThanZero_ReturnsOddNumbersUpToLimit()
        {
            var result = _math.GetOddNumbers(5);

            //Assert.That(result, Is.Not.Empty);

            //Assert.That(result.Count(), Is.EqualTo(3));

            //Assert.That(result, Does.Contain(1));
            //Assert.That(result, Does.Contain(2));
            //Assert.That(result, Does.Contain(3));

            Assert.That(result, Is.EquivalentTo(new [] { 1, 3, 5 }));

            //Assert.That(result, Is.Ordered);
            //Assert.That(result, Is.Unique);
        }
Пример #5
0
//        [Ignore("Because I am tupid!")]
        public void GetOddNumbers_WhenCalled_returnsListOfOddNumbers()
        {
            var result = _math.GetOddNumbers(5);
            //Set it to enumerable so don't have to do ir every time when method was called
            var enumerable = result as int[] ?? result.ToArray();

            Assert.That(enumerable, Is.Not.Empty);
            Assert.That(enumerable.Count(), Is.EqualTo(3));
            //Another way twsating on array
            Assert.That(enumerable, Is.EqualTo(new [] { 1, 3, 5 }));
            Assert.That(enumerable, Is.EqualTo(new List <int>()
            {
                1, 3, 5
            }));
            // Make sure it is ordered
            Assert.That(enumerable, Is.Ordered);
            Assert.That(enumerable, Is.Unique);
        }
        public void GetOddNumbers_LimitGreaterThanZero_ReturnsOddNumbersUpToLimit()
        {
            var result = _math.GetOddNumbers(5);

            //General
            Assert.That(result, Is.Not.Empty);
            //More specific
            Assert.That(result.Count(), Is.EqualTo(3));

            Assert.That(result, Is.EquivalentTo(new int[] { 1, 3, 5 }));
        }
Пример #7
0
        public void GetOddNumbers_LimitGreaterThanZero_ReturnsOddNumbersFromZeroToLimit()
        {
            // Arrange
            var math = new TestNinja.Fundamentals.Math();

            // Act
            var result = math.GetOddNumbers(5);

            // Assert
            Assert.Equal(new[] { 1, 3, 5 }, result);
        }
Пример #8
0
        public void GetOddNumbers_LimitIsGreaterThanZero_ReturnOddNumbersUpToLimit()
        {
            // Arrange, Act
            _oddNumbers = _math.GetOddNumbers(5).ToList();

            // Assert
            _oddNumbers.Count.ShouldBe(3);
            this.ShouldSatisfyAllConditions(
                () => _oddNumbers.ShouldContain(1),
                () => _oddNumbers.ShouldContain(3),
                () => _oddNumbers.ShouldContain(5));
        }
Пример #9
0
        public void GetOddNumbers_WhenCalled_ReturnAllOddNumbers()
        {
            ///arrange
            List <int> expected = new List <int> {
                1, 3
            };

            ///act
            var result = _math.GetOddNumbers(4);

            ///assert
            CollectionAssert.AreEqual(result, expected);
        }
Пример #10
0
        public void GetOddNumbers_LimitIsGreaterThanZero_ReturnOddNumbersUpToLimit()
        {
            var results = _maths.GetOddNumbers(5);

            // Assert.That(results, Is.Not.Empty); // general you cannot write all these assertion
            //  Assert.That(results.Count(),Is.EqualTo(3));//

            // Assert.That(results, Does.Contain(1));//
            //  Assert.That(results, Does.Contain(3));//
            //  Assert.That(results, Does.Contain(5));//
            // Assert.That(results,Is.Orderd);
            // Assert.That(results,
            Assert.That(results, Is.EquivalentTo(new [] { 1, 3, 5 }));
        }
Пример #11
0
        public void GetOddNumbers_LimitIsGreaterThanZero_ReturnOddNumbersUpToLimit()
        {
            //Arrange
            //Act
            var result = _math.GetOddNumbers(5);

            //Assert
            //Assert.That(result, Is.Not.Empty);
            //Assert.That(result.Count(), Is.EqualTo(3));
            //Assert.That(result, Does.Contain(1));
            //Assert.That(result, Does.Contain(3));
            //Assert.That(result, Does.Contain(5));
            Assert.That(result, Is.EquivalentTo(new [] { 1, 3, 5 }));
        }
Пример #12
0
        public void GetOddNumbers_LimitIsGreateerThanZero_ReturnsListOfOddNumbers()
        {
            var result = _math.GetOddNumbers(5);

            //too general
            //Assert.That(result, Is.Not.Empty);

            //checks whether the count is what we need
            //Assert.That(result.Count(), Is.EqualTo((3)));

            //more specific
            //Assert.That(result, Does.Contain(1));
            //Assert.That(result, Does.Contain(3));
            //Assert.That(result, Does.Contain(5));

            //way more specific (elements with sequence)
            Assert.That(result, Is.EquivalentTo(new [] { 1, 3, 5 }));
        }
Пример #13
0
        //[TestCase(5, new [] {1, 3, 5})]
        public void GetOddNumbers_WhenCalled_ReturnsEnumerableOfOddNumbersToMaxNumber()
        {
            var result = _math.GetOddNumbers(5);

            //general
            Assert.That(result, Is.Not.Empty);
            Assert.That(result.Count(), Is.EqualTo(3));
            //more specific
            Assert.That(result, Does.Contain(1));
            Assert.That(result, Does.Contain(3));
            Assert.That(result, Does.Contain(5));
            //hyper specific
            Assert.That(result, Is.EqualTo(new [] { 1, 3, 5 }));

            //other possible useful assertions:
            Assert.That(result, Is.Ordered);
            Assert.That(result, Is.Unique);
        }
Пример #14
0
        public void GetOddNumbers_LimitIsGreaterThanZero_ReturnOddNumbersUpToLimit()
        {
            var result = _math.GetOddNumbers(5);

            //Assert.That(result, Is.Not.Empty);

            //Assert.That(result.Count, Is.EqualTo(3));

            //Assert.That(result,Does.Contain(1));
            //Assert.That(result,Does.Contain(3));
            //Assert.That(result,Does.Contain(5));

            // Doesn't care about the ordering
            Assert.That(result, Is.EquivalentTo(new[] { 3, 1, 5 }));

            Assert.That(result, Is.Ordered);

            Assert.That(result, Is.Unique);
        }
        public void GetOddNumbers_LimitIsGreaterThanZero_ReturnOddNumbersUpToLimit()
        {
            var result = _math.GetOddNumbers(5);

            //Assert - use one
//            Assert.That(result, Is.Not.Empty);

//            Assert.That(result.Count(), Is.EqualTo(3));


//            Assert.That(result, Does.Contain(1));
//            Assert.That(result, Does.Contain(3));
//            Assert.That(result, Does.Contain(5));

            // Preffered way to test three odd numbers
            Assert.That(result, Is.EquivalentTo(new[] { 1, 3, 5 }));

//            Assert.That(result, Is.Ordered);
//            Assert.That(result, Is.Unique);
        }
Пример #16
0
        public void GetOddNumbers_LimitIsGreaterThanZero_ReturnsOddNumbersUpToLimit()
        {
            var result = _math.GetOddNumbers(5);

            // Most General
            //Assert.That(result, Is.Not.Empty);

            // More Specific
            //Assert.That(result.Count(), Is.EqualTo(3));

            // Even More Specific, but dont care about order
            //Assert.That(result, Does.Contain(1));
            //Assert.That(result, Does.Contain(3));
            //Assert.That(result, Does.Contain(5));

            // Most Specific
            Assert.That(result, Is.EquivalentTo(new int[] { 1, 3, 5 }));

            // Useful tests
            //Assert.That(result, Is.Ordered);
            //Assert.That(result, Is.Unique);
        }
Пример #17
0
        //**focus for this is on unit testing arrays and collections
        public void GetOddNumber_WhenLimitIsGreatherThanZero_ReturnsOddNumbersUpToLimit()

        // **My list of test cases
        //public void GetOddNumber_WhenLimitIsZero_ReturnsZero()
        //public void GetOddNumber_WhenLimitIsOne_ReturnsOne()
        //public void GetOddNumber_WhenLimitIsGreaterThan3_ReturnsArray()
        //public void GetOddNumber_WhenLimitIsOdd_ReturnsArrayWithLimitInt()
        //public void GetOddNumber_WhenLimitIsEven_ReturnsArrayWithLimitIntMinusOne()
        //public void GetOddNumber_WhenLimitIsNegative_ReturnsArrayWithLimitIntMinusOne()
        //public void GetOddNumber_WhenLimitIsPositive_ReturnsArrayWithLimitIntMinusOne()


        {
            //act
            var results = _math.GetOddNumbers(5);

            //Assert

            //Assert.That(results, Is.Not.Empty); //very general, shows there is something there, but doesn't show what the array contains

            //Assert.That(results.Count(), Is.EqualTo(3)); //checks for count

            //Assert.That(results, Does.Contain(1)); //checks the array contains certain or specific items, but not the order
            //Assert.That(results, Does.Contain(3));
            //Assert.That(results, Does.Contain(5));

            //shortcut to the above is to check against another small array.  Doesn't check order, just the items are in the array
            Assert.That(results, Is.EquivalentTo(new[] { 1, 3, 5 }));


            ////to check the array order
            //Assert.That(results, Is.Ordered);

            ////check the array has unique values
            //Assert.That(results, Is.Unique);
        }
Пример #18
0
        public void GetOddNumbers_WhenCalled_Returns()
        {
            IEnumerable <int> result = _math.GetOddNumbers(5);

            Assert.That(result, Is.EqualTo(new[] { 1, 3, 5 }));
        }
Пример #19
0
        [Test] // 3 Scenarios: limit is >0, <0, or =0.
        public void GetOddNumbers_WhenCalled_ReturnsOddNumbersUpToLimit()
        {
            var result = _math.GetOddNumbers(10);

            Assert.That(result, Is.EquivalentTo(new int[] { 1, 3, 5, 7, 9 }));
        }
Пример #20
0
        public void GetOddNumbers_LimitIsGreaterThanZero_ReturnOddNumbersUUpToLimit()
        {
            var result = _math.GetOddNumbers(9);

            Assert.That(result, Is.EquivalentTo(new[] { 1, 3, 5, 7, 9 }));
        }
Пример #21
0
        public void GetOddNumbers_LimitIsGreaterThanZero_ReturnsOddNumberUpToZero()
        {
            var result = _math.GetOddNumbers(5);

            Assert.That(result, Is.EquivalentTo(new[] { 1, 3, 5 }));
        }