Class describing a message block.
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
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)
 {
     this.expectedValuesBlock = new MessageBlock(this, expectedValues, ExpectedAdjective);
     this.expectedValuesBlock.Label("The expected value(s):");
     return(this.expectedValuesBlock);
 }
Beispiel #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;
 }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #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;
 }
Beispiel #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;
 }
Beispiel #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;
 }
Beispiel #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;
 }
Beispiel #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;
 }
Beispiel #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;
 }
Beispiel #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);
 }
Beispiel #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;
 }
Beispiel #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);
 }
Beispiel #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;
 }
Beispiel #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);
 }
Beispiel #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;
 }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #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;
        }