Ejemplo n.º 1
0
        public static void CalculateWithInvalidValue()
        {
            var value  = "wrong";
            var logger = Rock.Create <ILogger>();

            logger.Handle(_ => _.Log(Arg.IsAny <string>()));

            var controller = new CollatzController(logger.Make());
            var result     = controller.Get(value).Result as BadRequestObjectResult;

            Assert.That(result.StatusCode, Is.EqualTo(400));

            logger.Verify();
        }
Ejemplo n.º 2
0
        public static void CalculateWithValue()
        {
            var value  = "5";
            var logger = Rock.Create <ILogger>();

            logger.Handle(_ => _.Log(Arg.IsAny <string>()), 2);

            var controller  = new CollatzController(logger.Make());
            var result      = controller.Get(value).Result as OkObjectResult;
            var resultValue = (ImmutableArray <BigInteger>)result.Value;

            Assert.That(result.StatusCode, Is.EqualTo(200));
            Assert.That(resultValue.Length, Is.EqualTo(5));
            Assert.That(resultValue[0], Is.EqualTo(new BigInteger(5)));
            Assert.That(resultValue[1], Is.EqualTo(new BigInteger(8)));
            Assert.That(resultValue[2], Is.EqualTo(new BigInteger(4)));
            Assert.That(resultValue[3], Is.EqualTo(new BigInteger(2)));
            Assert.That(resultValue[4], Is.EqualTo(new BigInteger(1)));

            logger.Verify();
        }