CSharp examples for Microsoft.VisualStudio.TestTools.UnitTesting:Assert
Assert Not Null Or Empty
using System.Threading.Tasks; using System.Text; using System.Linq; using System.Collections.Generic; using System;/* w ww .ja v a 2s .co m*/ public class Main{ public static void NotNullOrEmpty(string o, string name) { Assert.NotNull(o, name); if (o.Length == 0) { name = name ?? "argument"; throw new ArgumentException(String.Format("{0} cannot be empty", name)); } } public static void NotNull(object o, string name) { if (o == null) { name = name ?? "argument"; throw new ArgumentNullException(String.Format("{0} cannot be null", name)); } } }