public void ctor_WithErrors_HasErrors() { subject = new IdentityManagerResult("error1", "error2", "error3"); Assert.AreEqual(3, subject.Errors.Count()); Assert.IsTrue(subject.Errors.Contains("error1")); Assert.IsTrue(subject.Errors.Contains("error2")); Assert.IsTrue(subject.Errors.Contains("error3")); }
public static void AddErrors(this ModelStateDictionary modelState, IdentityManagerResult result) { if (modelState == null) throw new ArgumentNullException("modelState"); if (result == null) throw new ArgumentNullException("result"); foreach (var error in result.Errors) { modelState.AddModelError("", error); } }
public static ErrorModel ToError(this IdentityManagerResult result) { if (result == null) { throw new ArgumentNullException("result"); } return(new ErrorModel { Errors = result.Errors.ToArray() }); }
public void ctor_WithErrors_HasNoResult() { subject = new IdentityManagerResult<FooResult>("error"); Assert.IsNull(subject.Result); }
public void ctor_WithResult_HasResult() { var r = new FooResult(); subject = new IdentityManagerResult<FooResult>(r); Assert.AreSame(r, subject.Result); }
public static bool TrySet(this PropertyMetadata property, object instance, string value, out IdentityManagerResult result) { if (property == null) { throw new ArgumentNullException("property"); } result = null; var executableProperty = property as ExecutablePropertyMetadata; if (executableProperty != null) { result = executableProperty.Set(instance, value); return(true); } return(false); }
public static bool TrySet(this IEnumerable <PropertyMetadata> properties, object instance, string type, string value, out IdentityManagerResult result) { if (properties == null) { throw new ArgumentNullException("properties"); } result = null; var executableProperty = properties.Where(x => x.Type == type).SingleOrDefault() as ExecutablePropertyMetadata; if (executableProperty != null) { return(executableProperty.TrySet(instance, value, out result)); } return(false); }
public void IsSuccess_WithErrors_ReturnsFalse() { subject = new IdentityManagerResult("error"); Assert.IsFalse(subject.IsSuccess); }
public void IsSuccess_NoErrors_ReturnsTrue() { subject = new IdentityManagerResult(); Assert.IsTrue(subject.IsSuccess); }