﻿using System;
using Xunit;

namespace Cascara.Tests
{
    public class AssertExtension : Assert
    {
        public static T ThrowsWithMessage<T>(Func<object> testCode, string message)
            where T : Exception
        {
            var ex = Assert.Throws<T>(testCode);
            Assert.Equal(ex.Message, message);

            return ex;
        }
    }
}

﻿using System;
using Xunit;

namespace Cascara.Tests
{
    public class AssertExtension : Assert
    {
        public static T ThrowsWithMessage<T>(Func<object> testCode, string message)
            where T : Exception
        {
            var ex = Assert.Throws<T>(testCode);
            Assert.Equal(ex.Message, message);

            return ex;
        }

        public static T ThrowsWithMessage<T>(Func<object> testCode, string fmt, params object[] args)
            where T : Exception
        {
            string message = string.Format(fmt, args);

            var ex = Assert.Throws<T>(testCode);
            Assert.Equal(ex.Message, message);

            return ex;
        }
    }
}

Add ThrowsWithMessage() overload with format string
Add ThrowsWithMessage() overload with format string
