Пример #1
0
 public void InvalidOperationTest()
 {
     Assert.ThrowsException <InvalidOperationException>(() =>
     {
         ArrayMath.Product(new int[] { });
     });
 }
Пример #2
0
        public void Should_Be_Throw_Rover_Cannot_Found_Exception(int x, int y)
        {
            var      p       = new Plateau(x, y);
            IManager manager = new RoverManager(p);

            Assert.ThrowsException <RoverCannotFoundException>(() => manager.Run());
        }
Пример #3
0
 public void ArgumentNullTest()
 {
     Assert.ThrowsException <ArgumentNullException>(() =>
     {
         ArrayMath.Product(null);
     });
 }
 public void MakeInvalidMove_ThrowsException()
 {
     Assert.ThrowsException <ArgumentOutOfRangeException>(() =>
     {
         var game = new Game();
         game.MakeMove(0);
     });
 }
Пример #5
0
        public void BivariateDimensionMismatch()
        {
            double[] x = new double[3];
            double[] y = new double[4];

            Assert.ThrowsException <DimensionMismatchException>(() => x.CorrelationCoefficient(y));
            Assert.ThrowsException <DimensionMismatchException>(() => x.Covariance(y));
            Assert.ThrowsException <DimensionMismatchException>(() => y.LinearRegression(x));
        }
 public void MoveOnTheSameSquare_ThrowsException()
 {
     Assert.ThrowsException <InvalidOperationException>(() =>
     {
         var game = new Game();
         game.MakeMove(1);
         game.MakeMove(1);
     });
 }
Пример #7
0
        public void Calculate_GetSpeed_infSpeed_throwException()
        {
            int x1 = 0;
            int y1 = 0;

            int x2 = 0;
            int y2 = 5;

            DateTime date1 = DateTime.Parse("00:04:00");
            DateTime date2 = DateTime.Parse("00:04:00");

            Assert.ThrowsException <ArgumentException>(() => Calculator.GetSpeed(x1, y1, date1, x2, y2, date2));
        }
Пример #8
0
        public void NextLongMaximumTest()
        {
            var random = new MockRandom();

            Assert.ThrowsException <ArgumentOutOfRangeException>(() => random.NextLong(-1));

            var byteGenerator = new Random();

            var buffer = new byte[8];

            for (var i = 0; i < 100; i++)
            {
                byteGenerator.NextBytes(buffer);
                random.MockNextBytes = buffer;

                var value   = BitConverter.ToInt64(buffer, 0);
                var maximum = byteGenerator.NextInt64();

                Assert.AreEqual(
                    value % maximum, random.NextLong(maximum),
                    $"value={value}, maximum={maximum}, %={value % maximum}, {random.NextLong( maximum )}"
                    );
            }
        }
Пример #9
0
        public void TestGetArticleById_ShoulFailToReturnArticle()
        {
            var ex = Assert.ThrowsException <Exception>(() => _shopService.GetById(12));

            Assert.AreEqual(ex.Message, "Could not find article with ID: 12");
        }
Пример #10
0
        public void Should_Be_Throw_Invalid_Argument_Exception(int x, int y, Direction direction, string cmd)
        {
            var p = new Plateau(x, y);

            Assert.ThrowsException <InvalidArgumentException>(() => p.AddRover(new Rover(x, y, direction, cmd)));
        }
Пример #11
0
        public void NextFloatMinimumThrowsExceptionWhenMaximumLessThanMinimumTest()
        {
            var random = new MockRandom();

            Assert.ThrowsException <ArgumentOutOfRangeException>(() => random.NextFloat(1, 0));
        }
Пример #12
0
        public void NextFloatMaximumThrowsExceptionWhenNegativeTest()
        {
            var random = new MockRandom();

            Assert.ThrowsException <ArgumentOutOfRangeException>(() => random.NextFloat(-1));
        }
Пример #13
0
        public void NextDoubleMinimumMaximumTest()
        {
            var random = new MockRandom();

            Assert.ThrowsException <ArgumentOutOfRangeException>(() => random.NextDouble(1, 0));
        }
Пример #14
0
        public void NextDecimalMaximumTest()
        {
            var random = new MockRandom();

            Assert.ThrowsException <ArgumentOutOfRangeException>(() => random.NextDecimal(-1));
        }
 public void GenetareNumbersTest_WithException() =>
 Assert.ThrowsException <ArgumentException>(() => Fibonacci.GenerateNumbers(0));
Пример #16
0
        public void TestOrderArticleThatNotExists_ShouldFailToReturnAnArticleFromSupplier()
        {
            var ex = Assert.ThrowsException <Exception>(() => _shopService.OrderArticle(1, 20));

            Assert.AreEqual(ex.Message, "Could not order article. Article not found");
        }
Пример #17
0
        public void TestSellArticle_ShoulFailToSellAnArticle()
        {
            var ex = Assert.ThrowsException <Exception>(() => _shopService.SellArticle(null, 10, new DateTime(2018, 3, 30)));

            Assert.AreEqual(ex.Message, "Could not sell article. Article not found.");
        }
Пример #18
0
        public void Should_Throw_Invalid_Coordinates_Exception(int x, int y, Direction direction, string cmd)
        {
            var p = new Plateau(5, 5);

            Assert.ThrowsException <InvalidCoordinateException>(() => p.AddRover(new Rover(x, y, direction, cmd)));
        }