Exemplo n.º 1
0
        public void Warning_WithStringAndParameters_ShouldCallHandler()
        {
            AmbientLogService sut     = new AmbientLogService();
            string            message = Guid.NewGuid().ToString();

            sut.Warning(message, 1, 2);

            _handler1.Received(1).Warning(message, 1, 2);
        }
Exemplo n.º 2
0
        public void Warning_WithExceptionString_ShouldCallHandler()
        {
            AmbientLogService sut     = new AmbientLogService();
            string            message = Guid.NewGuid().ToString();
            var exception             = new Exception();

            sut.Warning(exception, message);

            _handler1.Received(1).Warning(exception, message);
        }
        public void Add(params int[] numbersToAdd)
        {
            int sum = 0;

            foreach (var number in numbersToAdd)
            {
                sum += number;
            }

            Logger.Information("The sum is {Sum}", sum);

            if (sum % 10 != 0)
            {
                Logger.Warning("The sum {Sum} is not divisible by 10", sum);
            }

            if (sum % 2 == 0)
            {
                throw new Exception("The sum {Sum} is even. Abort !");
            }
        }