コード例 #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 <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);
 }
コード例 #2
0
ファイル: FluentMessage.cs プロジェクト: itanoss/NFluent
 /// <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);
 }
コード例 #3
0
ファイル: FluentMessage.cs プロジェクト: itanoss/NFluent
 /// <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);
 }
コード例 #4
0
ファイル: FluentMessage.cs プロジェクト: tprzepiorka/NFluent
 /// <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);
 }
コード例 #5
0
ファイル: FluentMessage.cs プロジェクト: tprzepiorka/NFluent
        /// <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);
        }
コード例 #6
0
ファイル: MessageBlock.cs プロジェクト: tprzepiorka/NFluent
        /// <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;
        }
コード例 #7
0
 /// <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);
     }
 }
コード例 #8
0
ファイル: MessageBlock.cs プロジェクト: tprzepiorka/NFluent
 /// <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);
     }
 }
コード例 #9
0
ファイル: MessageBlock.cs プロジェクト: tprzepiorka/NFluent
 /// <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);
     }
 }
コード例 #10
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);
        }
コード例 #11
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);
        }
コード例 #12
0
 internal MessageBlock(FluentMessage message, GenericLabelBlock block)
 {
     this.And   = message;
     this.block = block;
 }
コード例 #13
0
ファイル: FluentMessage.cs プロジェクト: itanoss/NFluent
 /// <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);
 }
コード例 #14
0
 /// <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;
 }
コード例 #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 <T>(T givenValue)
 {
     this.expectedLabel = GenericLabelBlock.BuildGivenBlock(this.expectedNamingLogic);
     this.expectedBlock = MessageBlock.Build(this, givenValue, this.expectedLabel);
     return(this.expectedBlock);
 }