From 7b2c4952ebc469bcab6550a0a206417d3a339fac Mon Sep 17 00:00:00 2001 From: ktmitton Date: Sun, 17 Apr 2022 13:05:57 -0400 Subject: [PATCH 1/3] Moved the Option extension into the option class, no reason to have an extension when we control the class --- .../Extensions/OptionExtensionsTests.cs | 85 ++----------------- .../Models/OptionTests.cs | 76 +++++++++++++++++ .../Extensions/IEnumerableExtensions.cs | 22 +++++ .../Extensions/OptionExtensions.cs | 53 ------------ Mittons.Fixtures/Models/Option.cs | 22 ++++- 5 files changed, 123 insertions(+), 135 deletions(-) create mode 100644 Mittons.Fixtures.Tests.Unit/Models/OptionTests.cs create mode 100644 Mittons.Fixtures/Extensions/IEnumerableExtensions.cs delete mode 100644 Mittons.Fixtures/Extensions/OptionExtensions.cs diff --git a/Mittons.Fixtures.Tests.Unit/Extensions/OptionExtensionsTests.cs b/Mittons.Fixtures.Tests.Unit/Extensions/OptionExtensionsTests.cs index 28ce38c..906d758 100644 --- a/Mittons.Fixtures.Tests.Unit/Extensions/OptionExtensionsTests.cs +++ b/Mittons.Fixtures.Tests.Unit/Extensions/OptionExtensionsTests.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using Mittons.Fixtures.Extensions; using Mittons.Fixtures.Models; @@ -10,87 +9,13 @@ namespace Mittons.Fixtures.Tests.Unit.Extensions; public class OptionExtensionsTests { [Fact] - public void ToExecutionParameterFormattedString_WhenOptionIsNull_ExpectArgumentNullException() - { - Option? stubOption = null; - - Assert.Throws(() => stubOption.ToExecutionParameterFormattedString()); - } - - [Fact] - public void ToExecutionParameterFormattedString_WhenNameIsNull_ExpectArgumentNullException() - { - var stubOption = new Option - { - Name = null, - Value = "value" - }; - - Assert.Throws(() => stubOption.ToExecutionParameterFormattedString()); - } - - [Fact] - public void ToExecutionParameterFormattedString_WhenValueIsNull_ExpectExecutionParameterFormattedStringWithOnlyName() - { - var stubOption = new Option - { - Name = "--option", - Value = null - }; - - var commandFormattedString = stubOption.ToExecutionParameterFormattedString(); - - Assert.Equal("--option", commandFormattedString); - } - - [Fact] - public void ToExecutionParameterFormattedString_WhenValueIsEmptyString_ExpectExecutionParameterFormattedStringWithOnlyName() - { - var stubOption = new Option - { - Name = "--option", - Value = string.Empty - }; - - var commandFormattedString = stubOption.ToExecutionParameterFormattedString(); - - Assert.Equal("--option", commandFormattedString); - } - - [Fact] - public void ToExecutionParameterFormattedString_WhenValueIsWhiteSpace_ExpectExecutionParameterFormattedStringWithOnlyName() - { - var stubOption = new Option - { - Name = "--option", - Value = " " - }; - - var commandFormattedString = stubOption.ToExecutionParameterFormattedString(); - - Assert.Equal("--option", commandFormattedString); - } - - [Fact] - public void ToExecutionParameterFormattedString_WhenNameAndValueAreNotNull_ExpectExecutionParameterFormattedString() - { - var stubOption = new Option - { - Name = "--option", - Value = "value" - }; - - var commandFormattedString = stubOption.ToExecutionParameterFormattedString(); - - Assert.Equal("--option \"value\"", commandFormattedString); - } - - [Fact] - public void ToExecutionParametersFormattedString_WhenOptionsIsNull_ExpectArgumentNullException() + public void ToExecutionParametersFormattedString_WhenOptionsIsNull_ExpectEmptyString() { IEnumerable