public void FormatItemAddedMessageThrowsExceptionWithNullDefinition() { var arguments = Model.UsingModule <ConfigurationModule>().Create <FormatArguments>(); var sut = new DefaultMessageFormatter(); Action action = () => sut.FormatItemAddedMessage(null !, arguments); action.Should().Throw <ArgumentNullException>(); }
public void FormatItemAddedMessageThrowsExceptionWithNullArguments() { var definition = Substitute.For <IItemDefinition>(); var sut = new DefaultMessageFormatter(); Action action = () => sut.FormatItemAddedMessage(definition, null !); action.Should().Throw <ArgumentNullException>(); }
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 "); }
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}"); }
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}"); }
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}"); }