示例#1
0
        public void FormatItemAddedMessageThrowsExceptionWithNullDefinition()
        {
            var arguments = Model.UsingModule <ConfigurationModule>().Create <FormatArguments>();

            var sut = new DefaultMessageFormatter();

            Action action = () => sut.FormatItemAddedMessage(null !, arguments);

            action.Should().Throw <ArgumentNullException>();
        }
示例#2
0
        public void FormatItemAddedMessageThrowsExceptionWithNullArguments()
        {
            var definition = Substitute.For <IItemDefinition>();

            var sut = new DefaultMessageFormatter();

            Action action = () => sut.FormatItemAddedMessage(definition, null !);

            action.Should().Throw <ArgumentNullException>();
        }
示例#3
0
        public void FormatItemAddedMessageMapsKnownDefinitionTypes(Type definitionType)
        {
            const string?messageFormat = "{DefinitionType} {Identifier}";
            var          identifier    = Guid.NewGuid().ToString();
            var          arguments     = new FormatArguments(messageFormat, identifier, null, null);

            var definition = (IItemDefinition)Substitute.For(new[] { definitionType }, Array.Empty <object>());

            var sut = new DefaultMessageFormatter();

            var actual = sut.FormatItemAddedMessage(definition, arguments !);

            actual.Should().NotStartWith("Element ");
        }
示例#4
0
        public void FormatItemAddedMessageDeterminesDefinitionTypeBasedOnDefinitionType(Type definitionType,
                                                                                        string expected)
        {
            const string?messageFormat = "{DefinitionType} {Identifier}";
            var          identifier    = Guid.NewGuid().ToString();
            var          arguments     = new FormatArguments(messageFormat, identifier, null, null);

            var definition = (IItemDefinition)Substitute.For(new[] { definitionType }, Array.Empty <object>());

            var sut = new DefaultMessageFormatter();

            var actual = sut.FormatItemAddedMessage(definition, arguments !);

            actual.Should().Be($"{expected} {identifier}");
        }
示例#5
0
        public void FormatItemAddedMessageFormatsMessageWithProvidedArguments()
        {
            const string?messageFormat = "{DefinitionType} - {Identifier} - {OldValue} - {NewValue}";
            var          identifier    = Guid.NewGuid().ToString();
            var          oldValue      = Guid.NewGuid().ToString();
            var          newValue      = Guid.NewGuid().ToString();
            var          arguments     = new FormatArguments(messageFormat, identifier, oldValue, newValue);

            var definition = Substitute.For <IClassDefinition>();

            var sut = new DefaultMessageFormatter();

            var actual = sut.FormatItemAddedMessage(definition, arguments !);

            actual.Should().Be($"Class - {identifier} - {oldValue} - {newValue}");
        }
示例#6
0
        public void FormatItemAddedMessageDeterminesDefinitionTypeBasedOnArgumentType(ArgumentType argumentType,
                                                                                      string expected)
        {
            const string?messageFormat = "{DefinitionType} {Identifier}";
            var          identifier    = Guid.NewGuid().ToString();
            var          arguments     = new FormatArguments(messageFormat, identifier, null, null);

            var definition = Substitute.For <IArgumentDefinition>();

            definition.ArgumentType.Returns(argumentType);

            var sut = new DefaultMessageFormatter();

            var actual = sut.FormatItemAddedMessage(definition, arguments !);

            actual.Should().Be($"{expected} {identifier}");
        }