Beispiel #1
0
 /// <summary>
 /// Adds a message block to describe the expected values.
 /// </summary>
 /// <param name="expectedValues">
 /// The expected values.
 /// </param>
 /// <param name="index">
 /// The index to highlight.
 /// </param>
 /// <returns>
 /// The created MessageBlock.
 /// </returns>
 public MessageBlock ExpectedValues(object expectedValues, long index = 0)
 {
     this.expectedLabel = GenericLabelBlock.BuildExpectedBlock(new EntityNamer {
         EntityName = "value(s)"
     });
     this.expectedBlock = new MessageBlock(this, expectedValues, this.expectedLabel, index);
     return(this.expectedBlock);
 }
Beispiel #2
0
 /// <summary>
 /// Adds a message block to describe the expected values.
 /// </summary>
 /// <param name="expectedValues">
 /// The expected values.
 /// </param>
 /// <param name="index">
 /// The index to highlight.
 /// </param>
 /// <returns>
 /// The created MessageBlock.
 /// </returns>
 public MessageBlock ExpectedValues <T>(T expectedValues, long index = 0)
 {
     this.expectedNamingLogic.SetPlural();
     this.expectedNamingLogic.EntityType = null;
     this.expectedLabel = GenericLabelBlock.BuildExpectedBlock(this.expectedNamingLogic);
     this.expectedBlock = MessageBlock.Build(this, expectedValues, this.expectedLabel, index, true);
     return(this.expectedBlock);
 }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FluentMessage"/> class.
 /// </summary>
 /// <param name="message">
 /// The main message.
 /// </param>
 /// <remarks>
 /// You can use {x} as place holders for standard wordings:
 /// - {0}.
 /// </remarks>
 private FluentMessage(string message)
 {
     this.message       = message ?? throw new ArgumentNullException(nameof(message));
     this.entity        = null;
     this.checkedNamer  = new EntityNamer();
     this.expectedNamer = new EntityNamer();
     this.checkedLabel  = GenericLabelBlock.BuildCheckedBlock(this.checkedNamer);
     this.expectedLabel = GenericLabelBlock.BuildExpectedBlock(this.expectedNamer);
 }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FluentMessage"/> class.
 /// </summary>
 /// <param name="message">
 /// The main message.
 /// </param>
 /// <remarks>
 /// You can use {x} as place holders for standard wordings:
 /// - {0}.
 /// </remarks>
 private FluentMessage(string message)
 {
     this.message           = message;
     this.EntityDescription = null;
     this.checkedNamer      = new EntityNamer();
     this.expectedNamer     = new EntityNamer();
     this.checkedLabel      = GenericLabelBlock.BuildCheckedBlock(this.checkedNamer);
     this.expectedLabel     = GenericLabelBlock.BuildExpectedBlock(this.expectedNamer);
 }
Beispiel #5
0
        /// <summary>
        /// Adds a message block to describe the expected values.
        /// </summary>
        /// <param name="expectedValues">The expected values.</param>
        /// <returns>The created MessageBlock.</returns>
        public MessageBlock ExpectedValues(object expectedValues)
        {
            var customNamer = new EntityNamer {
                EntityName = "value(s)"
            };

            this.expectedLabel = GenericLabelBlock.BuildExpectedBlock(customNamer);
            this.expectedBlock = new MessageBlock(this, expectedValues, this.expectedLabel);
            this.referenceType = this.referenceType ?? expectedValues.GetTypeWithoutThrowingException();
            return(this.expectedBlock);
        }
Beispiel #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FluentMessage"/> class.
        /// </summary>
        /// <param name="message">
        /// The main message.
        /// </param>
        /// <remarks>
        /// You can use {x} as place holders for standard wordings:
        /// - {0}.
        /// </remarks>
        private FluentMessage(string message)
        {
            var format = message;

            format                  = format.Replace("{checked}", "{0}");
            format                  = format.Replace("{expected}", "{1}");
            format                  = format.Replace("{given}", "{1}");
            this.message            = format;
            this.dontRepeatExpected = NormalOrder.IsMatch(format);
            this.dontRepeatChecked  = ReverseOrder.IsMatch(format);

            this.checkedNamingLogic  = new EntityNamingLogic();
            this.expectedNamingLogic = new EntityNamingLogic();
            this.checkedLabel        = GenericLabelBlock.BuildCheckedBlock(this.checkedNamingLogic);
            this.expectedLabel       = GenericLabelBlock.BuildExpectedBlock(this.expectedNamingLogic);
        }