Tutorial by Examples

Compares two values for equality. It can compare strings, integers, and Boolean values only. Assert.AreEqual(documentElement.LocalName, "xamlControls", "Xaml files must have a root node named 'xamlControls'.");
To assert that a value is either true or false,: Assert.IsFalse(Settings.DoBadThings, "Bad things should not happen, disable DoBadThings."); Assert.IsTrue(magicNumber =< 42, "The magic number is greater than 42!"); You can also pass formatting parameters for the exception...
ResultNotNull() checks to see if the object passed in is not null. If the object and message are not null it will then simply return the object that was passed in, otherwise it will throw InvalidOperationException. return Assert.ResultNotNull(this.Database.GetItem(this.ItemRootId), string.Concat(&q...
This checks to see if the given object is null, and then throws RequiredObjectIsNullException if it is. Assert.Required(parameter, "parameter is required.");
IsNotNull This is a very simple and popular method to use to check if an item is not null. It simply checks the object that is passed in to see if it is null. Assert.IsNotNull(database, type, "Name: {0}", item); IsNotNullOrEmpty This is the same as IsNotNull above, but works on strin...
ArgumentCondition This method checks to see if the argument specified is true. It also takes in the name of the argument that is logged if the condition fails. Assert.ArgumentCondition(pageIndex >= 0, "pageIndex", "Value must be greater than or equal to zero."); ArgumentN...
Checks to see if the passed Item is in Editing mode. If not, it throws an EditingNotAllowedException. Assert.IsEditing(Sitecore.Context.Item);
CanRunApplication To check to see if the user has permission to run the given application. If not, AccessDeniedException is thrown. Assert.CanRunApplication("WebEdit"); HasAccess HasAccess will check if the given parameter is true, otherwise an AccessDeniedException will be thrown. ...

Page 1 of 1