Here’s handy NUnit test method I used today to check whether some variables were set before passing them to my service:

            public void InvalidInput(Action func)
            {
                func.Invoke();
                ServiceToTest.SaveDraft(dto);
                MockContext.VerifySet(x => x.StatusCode = HttpStatusCode.BadRequest);
            }

Used like this:

            [Test]
            public void Should_fail_blank_username()
            {
                InvalidInput(() => dto.UpdateUser = "");
            }

or

            [Test]
            public void Should_fail_blank_UserIds()
            {
                InvalidInput(() => dto.UserId = 0);
            }

I can use the same method for string and it’s by just passing the Action to the InvalidInput and invoking it and the other test code there.

You could also define the test method like this:

            public void TestCaseGeneric<T>(Func<T> func)
            {
                func.Invoke();
                ServiceToTest.SaveDraft(dto);
                MockContext.VerifySet(x => x.StatusCode = HttpStatusCode.BadRequest);
            }

But the action bit is pretty clean.