public void ctor_WithErrors_HasErrors()
 {
     subject = new IdentityAdminResult("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, IdentityAdminResult 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 void ctor_WithErrors_HasNoResult()
 {
     _subject = new IdentityAdminResult<FooResult>("error");
     Assert.IsNull(_subject.Result);
 }
 public void ctor_WithResult_HasResult()
 {
     var r = new FooResult();
     _subject = new IdentityAdminResult<FooResult>(r);
     Assert.AreSame(r, _subject.Result);
 }
 public void IsSuccess_WithErrors_ReturnsFalse()
 {
     subject = new IdentityAdminResult("error");
     Assert.IsFalse(subject.IsSuccess);
 }
 public void IsSuccess_NoErrors_ReturnsTrue()
 {
     subject = new IdentityAdminResult();
     Assert.IsTrue(subject.IsSuccess);
 }
        public static bool TrySet(this PropertyMetadata property, object instance, string value, out IdentityAdminResult 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 IdentityAdminResult 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;
        }