Class describing a message block.
示例#1
0
        /// <summary>
        /// Adds a block describing the checked object.
        /// </summary>
        /// <param name="test">
        /// The tested object/value.
        /// </param>
        /// <param name="index">
        /// The interesting index (for enumerable types).
        /// </param>
        /// <returns>
        /// A <see cref="FluentMessage"/> to continue build the message.
        /// </returns>
        public MessageBlock On <T>(T test, long index = 0)
        {
            var theType = test.GetTypeWithoutThrowingException();

            this.checkedBlock = MessageBlock.Build(this, test, this.checkedLabel, index);
            this.For(theType);
            this.checkedType = theType;
            return(this.checkedBlock);
        }
示例#2
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);
        }
示例#3
0
        /// <summary>
        /// Adds a block describing the checked object.
        /// </summary>
        /// <param name="test">
        /// The tested object/value.
        /// </param>
        /// <param name="index">
        /// The interesting index (for enumerable types).
        /// </param>
        /// <returns>
        /// A <see cref="FluentMessage"/> to continue build the message.
        /// </returns>
        public MessageBlock On(object test, long index = 0)
        {
            this.checkedBlock = new MessageBlock(this, test, this.checkedLabel, index);
            if (this.referenceType == null)
            {
                this.referenceType = test.GetTypeWithoutThrowingException();
            }

            this.checkedType = test.GetTypeWithoutThrowingException();

            return(this.checkedBlock);
        }
示例#4
0
        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);
        }
示例#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)
 {
     this.expectedValuesBlock = new MessageBlock(this, expectedValues, ExpectedAdjective);
     this.expectedValuesBlock.Label("The expected value(s):");
     return(this.expectedValuesBlock);
 }
示例#6
0
 /// <summary>
 /// Adds a message block to describe the expected result.
 /// </summary>
 /// <param name="expected">The expected value.</param>
 /// <returns>
 /// The created MessageBlock.
 /// </returns>
 public MessageBlock Expected(object expected)
 {
     this.expectedBlock = new MessageBlock(this, expected, this.expectedLabel);
     this.referenceType = expected.GetTypeWithoutThrowingException();
     return this.expectedBlock;
 }
示例#7
0
 /// <summary>
 /// Adds a message block to describe the given value (usually used as an
 /// alternative to the Expected block).
 /// </summary>
 /// <param name="givenValue">The given value.</param>
 /// <returns>The created MessageBlock.</returns>
 public MessageBlock WithGivenValue(object givenValue)
 {
     this.expectedLabel = GenericLabelBlock.BuildGivenBlock(this.checkedNamer);
     this.expectedBlock = new MessageBlock(this, givenValue, this.expectedLabel);
     return(this.expectedBlock);
 }
示例#8
0
 /// <summary>
 /// Adds a message block to describe the expected result.
 /// </summary>
 /// <param name="expected">The expected value.</param>
 /// <returns>
 /// The created MessageBlock.
 /// </returns>
 public MessageBlock ReferenceValues(object expected)
 {
     this.expectedBlock = new MessageBlock(this, expected, this.expectedLabel);
     return(this.expectedBlock);
 }
示例#9
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)
 {
     this.expectedValuesBlock = new MessageBlock(this, expectedValues, ExpectedAdjective);
     this.expectedValuesBlock.Label("The expected value(s):");
     return this.expectedValuesBlock;
 }
示例#10
0
 /// <summary>
 /// Adds a block describing the checked objet.
 /// </summary>
 /// <param name="test">The tested object/value.</param>
 /// <returns>A <see cref="FluentMessage"/> to continue build the message.</returns>
 public MessageBlock On(object test)
 {
     this.checkedBlock = new MessageBlock(this, test, TestedAdjective);
     return this.checkedBlock;
 }
示例#11
0
 /// <summary>
 /// Adds a message block to describe the given value (usually used as an 
 /// alternative to the Expected block).
 /// </summary>
 /// <param name="givenValue">The given value.</param>
 /// <returns>The created MessageBlock.</returns>
 public MessageBlock WithGivenValue(object givenValue)
 {
     this.expectedLabel = GenericLabelBlock.BuildGivenBlock(this.checkedNamer);
     this.expectedBlock = new MessageBlock(this, givenValue, this.expectedLabel);
     return this.expectedBlock;
 }
示例#12
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;
 }
示例#13
0
 /// <summary>
 /// Adds a message block to describe the expected type.
 /// </summary>
 /// <param name="expectedType">The expected type.</param>
 /// <returns>The created MessageBlock.</returns>
 public MessageBlock ExpectedType(Type expectedType)
 {
     this.expectedBlock = new MessageBlock(this, expectedType, this.expectedLabel);
     this.referenceType = null;
     return this.expectedBlock;
 }
示例#14
0
 /// <summary>
 /// Adds a message block to describe the expected result.
 /// </summary>
 /// <param name="expected">The expected value.</param>
 /// <returns>
 /// The created MessageBlock.
 /// </returns>
 public MessageBlock ReferenceValues(object expected)
 {
     this.expectedBlock = new MessageBlock(this, expected, this.expectedLabel);
     return this.expectedBlock;
 }
示例#15
0
 /// <summary>
 /// Adds a message block to describe the given value (usually used as an
 /// alternative to the Expected block).
 /// </summary>
 /// <param name="givenValue">The given value.</param>
 /// <returns>The created MessageBlock.</returns>
 public MessageBlock WithGivenValue(object givenValue)
 {
     this.givenValueBlock = new MessageBlock(this, givenValue, GivenAdjective);
     return(this.givenValueBlock);
 }
示例#16
0
 /// <summary>
 /// Adds a message block to describe the expected type.
 /// </summary>
 /// <param name="expectedType">The expected type.</param>
 /// <returns>The created MessageBlock.</returns>
 public MessageBlock ExpectedType(Type expectedType)
 {
     this.expectedBlock = new MessageBlock(this, expectedType, ExpectedAdjective);
     return this.expectedBlock;
 }
示例#17
0
 /// <summary>
 /// Adds a message block to describe the expected result.
 /// </summary>
 /// <param name="expected">The expected value.</param>
 /// <param name="index"></param>
 /// <returns>
 /// The created MessageBlock.
 /// </returns>
 public MessageBlock Expected <T>(T expected, long index = 0)
 {
     this.expectedBlock = MessageBlock.Build(this, expected, this.expectedLabel, index);
     this.For(expected.GetTypeWithoutThrowingException());
     return(this.expectedBlock);
 }
示例#18
0
 /// <summary>
 /// Adds a message block to describe the expected result.
 /// </summary>
 /// <param name="expected">The expected value.</param>
 /// <returns>The created MessageBlock.</returns>
 public MessageBlock Expected(object expected)
 {
     this.expectedBlock = new MessageBlock(this, expected, ExpectedAdjective);
     return this.expectedBlock;
 }
示例#19
0
 /// <summary>
 /// Adds a message block to describe the expected result.
 /// </summary>
 /// <param name="expected">The expected value.</param>
 /// <returns>
 /// The created MessageBlock.
 /// </returns>
 public MessageBlock ReferenceValues <T>(T expected)
 {
     this.expectedBlock = MessageBlock.Build(this, expected, this.expectedLabel);
     return(this.expectedBlock);
 }
示例#20
0
 /// <summary>
 /// Adds a message block to describe the given value (usually used as an 
 /// alternative to the Expected block).
 /// </summary>
 /// <param name="givenValue">The given value.</param>
 /// <returns>The created MessageBlock.</returns>
 public MessageBlock WithGivenValue(object givenValue)
 {
     this.givenValueBlock = new MessageBlock(this, givenValue, GivenAdjective);
     return this.givenValueBlock;
 }
示例#21
0
 /// <summary>
 /// Adds a message block to describe the given value (usually used as an
 /// alternative to the Expected block).
 /// </summary>
 /// <param name="givenValue">The given value.</param>
 /// <returns>The created MessageBlock.</returns>
 public MessageBlock WithGivenValue <T>(T givenValue)
 {
     this.expectedLabel = GenericLabelBlock.BuildGivenBlock(this.expectedNamingLogic);
     this.expectedBlock = MessageBlock.Build(this, givenValue, this.expectedLabel);
     return(this.expectedBlock);
 }
示例#22
0
 /// <summary>
 /// Adds a message block to describe the expected result.
 /// </summary>
 /// <param name="expected">The expected value.</param>
 /// <returns>
 /// The created MessageBlock.
 /// </returns>
 public MessageBlock Expected(object expected)
 {
     this.expectedBlock = new MessageBlock(this, expected, this.expectedLabel);
     this.referenceType = expected.GetTypeWithoutThrowingException();
     return(this.expectedBlock);
 }
示例#23
0
 /// <summary>
 /// Adds a block describing the checked objet.
 /// </summary>
 /// <param name="test">The tested object/value.</param>
 /// <returns>A <see cref="FluentMessage"/> to continue build the message.</returns>
 public MessageBlock On(object test)
 {
     this.checkedBlock = new MessageBlock(this, test, TestedAdjective);
     return(this.checkedBlock);
 }
示例#24
0
 /// <summary>
 /// Adds a message block to describe the expected type.
 /// </summary>
 /// <param name="expectedType">The expected type.</param>
 /// <returns>The created MessageBlock.</returns>
 public MessageBlock ExpectedType(Type expectedType)
 {
     this.expectedBlock = new MessageBlock(this, expectedType, this.expectedLabel);
     this.referenceType = null;
     return(this.expectedBlock);
 }
示例#25
0
 /// <summary>
 /// Adds a message block to describe the expected result.
 /// </summary>
 /// <param name="expected">The expected value.</param>
 /// <returns>The created MessageBlock.</returns>
 public MessageBlock Expected(object expected)
 {
     this.expectedBlock = new MessageBlock(this, expected, ExpectedAdjective);
     return(this.expectedBlock);
 }
示例#26
0
 /// <summary>
 /// Adds a message block to describe the expected type.
 /// </summary>
 /// <param name="expectedType">The expected type.</param>
 /// <returns>The created MessageBlock.</returns>
 public MessageBlock ExpectedType(Type expectedType)
 {
     this.expectedBlock = new MessageBlock(this, expectedType, ExpectedAdjective);
     return(this.expectedBlock);
 }
示例#27
0
        /// <summary>
        /// Adds a block describing the checked objet.
        /// </summary>
        /// <param name="test">The tested object/value.</param>
        /// <param name="index">The interesting index (for enumerable types)</param>
        /// <returns>A <see cref="FluentMessage"/> to continue build the message.</returns>
        public MessageBlock On(object test, int index=0)
        {
            this.checkedBlock = new MessageBlock(this, test, this.checkedLabel, index);
            if (this.referenceType == null)
            {
                this.referenceType = test.GetTypeWithoutThrowingException();
            }

            this.checkedType = test.GetTypeWithoutThrowingException();

            return this.checkedBlock;
        }