/// <summary> /// Builds an error message in. /// </summary> /// <param name="message">The message.</param> /// <returns>A <see cref="FluentMessage"/> instance.</returns> public FluentMessage BuildMessage(string message) { var result = FluentMessage.BuildMessage(message); result.On(this.Value); return(result); }
/// <summary> /// Builds an error message. /// </summary> /// <param name="message">The message.</param> /// <returns>A <see cref="FluentMessage"/> instance.</returns> public FluentMessage BuildShortMessage(string message) { var result = FluentMessage.BuildMessage(message); if (!string.IsNullOrEmpty(this.sutLabel)) { result.For(this.sutLabel); } return(result); }
/// <summary> /// Initializes a new instance of the <see cref="MessageBlock"/> class. /// </summary> /// <param name="message"> /// The message. /// </param> /// <param name="type"> /// The tested type. /// </param> /// <param name="label"> /// The block label. /// </param> internal MessageBlock(FluentMessage message, Type type, GenericLabelBlock label) { if (message == null) { throw new ArgumentNullException("message"); } this.value = new InstanceBlock(type); this.message = message; this.block = label; }
/// <summary> /// Initializes a new instance of the <see cref="MessageBlock"/> class. /// </summary> /// <param name="message"> /// The message. /// </param> /// <param name="test"> /// The tested object. /// </param> /// <param name="block"> /// The block attribute. /// </param> /// <param name="forceArray">test is an enumeration.</param>> /// <param name="index">The index for enumerable types</param> internal MessageBlock(FluentMessage message, object test, GenericLabelBlock block, long index = 0, bool forceArray = false) : this(message, test.GetTypeWithoutThrowingException(), block) { if (!(test is string) && (forceArray || (test is IEnumerable))) { this.value = new EnumerationBlock((IEnumerable)test, index); } else { this.value = new ValueBlock(test); } }
public void BlockTest() { var message = new FluentMessage("test"); var x = 4; var block = new FluentMessage.MessageBlock(message, x, string.Empty); Assert.AreEqual("The value:\n\t[4]", block.GetMessage()); block.WithHashCode().WithType(); Assert.AreEqual("The value:\n\t[4] of type: [int] with HashCode: [4]", block.GetMessage()); }
/// <summary> /// Initializes a new instance of the <see cref="MessageBlock"/> class. /// </summary> /// <param name="message"> /// The message. /// </param> /// <param name="test"> /// The tested object. /// </param> /// <param name="block"> /// The block attribute. /// </param> /// <param name="index">The index for enumerable types</param> internal MessageBlock(FluentMessage message, object test, GenericLabelBlock block, int index = 0) : this(message, test.GetTypeWithoutThrowingException(), block) { if (!(test is string) && (test is IEnumerable)) { this.value = new EnumerationBlock((IEnumerable) test, index); } else { this.value = new ValueBlock(test); } }
/// <summary> /// Initializes a new instance of the <see cref="MessageBlock"/> class. /// </summary> /// <param name="message"> /// The message. /// </param> /// <param name="test"> /// The tested object. /// </param> /// <param name="index">Index to focus on.</param> /// <param name="block"> /// The block attribute. /// </param> internal MessageBlock(FluentMessage message, IEnumerable test, int index, GenericLabelBlock block) : this(message, test.GetTypeWithoutThrowingException(), block) { if (!(test is string)) { this.value = new EnumerationBlock(test, index); } else { this.value = new ValueBlock(test); } }
/// <summary> /// Initializes a new instance of the <see cref="MessageBlock"/> class. /// </summary> /// <param name="message"> /// The message. /// </param> /// <param name="test"> /// The tested object. /// </param> /// <param name="block"> /// The block attribute. /// </param> internal MessageBlock(FluentMessage message, object test, GenericLabelBlock block) : this(message, test.GetTypeWithoutThrowingException(), block) { if (!(test is string) && (test is IEnumerable)) { this.value = new EnumerationBlock(test as IEnumerable, 0); } else { this.value = new ValueBlock(test); } }
/// <summary> /// Initializes a new instance of the <see cref="MessageBlock"/> class. /// </summary> /// <param name="message">The message.</param> /// <param name="type">The tested type.</param> /// <param name="attribute">The block attribute.</param> public MessageBlock(FluentMessage message, Type type, string attribute) { if (message == null) { throw new ArgumentNullException("message"); } this.message = message; this.test = null; this.type = type; this.anyInstance = true; this.attribute = attribute; }
internal static MessageBlock Build <T>(FluentMessage message, T value, GenericLabelBlock block, long index = 0, bool forceArray = false) { var result = new MessageBlock(message, block); if (value.IsAnEnumeration(forceArray)) { result.value = new EnumerationBlock <IEnumerable>(value as IEnumerable, index); } else { result.value = new ValueBlock <T>(value); } return(result); }
/// <summary> /// Initializes a new instance of the <see cref="MessageBlock"/> class. /// </summary> /// <param name="message">The message.</param> /// <param name="test">The tested object.</param> /// <param name="attribute">The block attribute.</param> public MessageBlock(FluentMessage message, object test, string attribute) : this(message, test.GetTypeWithoutThrowingException(), attribute) { this.test = test; this.anyInstance = false; }
/// <summary> /// Initializes a new instance of the <see cref="MessageBlock"/> class. /// </summary> /// <param name="message"> /// The message. /// </param> /// <param name="type"> /// The tested type. /// </param> /// <param name="label"> /// The block label. /// </param> internal MessageBlock(FluentMessage message, Type type, GenericLabelBlock label) { if (message == null) { throw new ArgumentNullException(nameof(message)); } this.value = new InstanceBlock(type); this.message = message; this.block = label; }
internal MessageBlock(FluentMessage message, GenericLabelBlock block) { this.And = message; this.block = block; }
/// <summary> /// Builds an error message. /// </summary> /// <param name="message">The message.</param> /// <returns>A <see cref="FluentMessage"/> instance.</returns> public FluentMessage BuildShortMessage(string message) { var result = FluentMessage.BuildMessage(message); return(result); }
/// <summary> /// Initializes a new instance of the <see cref="MessageBlock"/> class. /// </summary> /// <param name="message"> /// The message. /// </param> /// <param name="type"> /// The tested type. /// </param> /// <param name="label"> /// The block label. /// </param> internal MessageBlock(FluentMessage message, Type type, GenericLabelBlock label) { this.value = new InstanceBlock(type); this.message = message; this.block = label; }
/// <summary> /// Initializes a new instance of the <see cref="MessageBlock"/> class. /// </summary> /// <param name="message">The message.</param> /// <param name="test">The tested object.</param> /// <param name="attribute">The block attribute.</param> public MessageBlock(FluentMessage message, object test, string attribute) { if (message == null) { throw new ArgumentNullException("message"); } this.message = message; this.test = test; this.type = test.GetTypeWithoutThrowingException(); this.attribute = attribute; }