Addressing code review comments by making the Configuration class's fields readonly.

This commit is contained in:
Livar Cunha 2018-05-17 10:01:42 -07:00
parent 2a735db882
commit e5e2256ae9
3 changed files with 122 additions and 97 deletions

View file

@ -5,10 +5,20 @@ namespace Microsoft.DotNet.Configurer
{ {
public class DotnetFirstRunConfiguration public class DotnetFirstRunConfiguration
{ {
public bool GenerateAspNetCertificate { get; set; } public bool GenerateAspNetCertificate { get; }
public bool PrintTelemetryMessage { get; set; } public bool PrintTelemetryMessage { get; }
public bool SkipFirstRunExperience { get; set; } public bool SkipFirstRunExperience { get; }
public DotnetFirstRunConfiguration(
bool generateAspNetCertificate,
bool printTelemetryMessage,
bool skipFirstRunExperience)
{
GenerateAspNetCertificate = generateAspNetCertificate;
PrintTelemetryMessage = printTelemetryMessage;
SkipFirstRunExperience = skipFirstRunExperience;
}
} }
} }

View file

@ -164,12 +164,10 @@ namespace Microsoft.DotNet.Cli
skipFirstRunExperience = false; skipFirstRunExperience = false;
} }
var dotnetFirstRunConfiguration = new DotnetFirstRunConfiguration var dotnetFirstRunConfiguration = new DotnetFirstRunConfiguration(
{ generateAspNetCertificate,
GenerateAspNetCertificate = generateAspNetCertificate, printTelemetryMessage,
PrintTelemetryMessage = printTelemetryMessage, skipFirstRunExperience);
SkipFirstRunExperience = skipFirstRunExperience
};
ConfigureDotNetForFirstTimeUse( ConfigureDotNetForFirstTimeUse(
nugetCacheSentinel, nugetCacheSentinel,

View file

@ -49,10 +49,11 @@ namespace Microsoft.DotNet.Configurer.UnitTests
_aspNetCoreCertificateGeneratorMock.Object, _aspNetCoreCertificateGeneratorMock.Object,
_toolPathSentinelMock.Object, _toolPathSentinelMock.Object,
new DotnetFirstRunConfiguration new DotnetFirstRunConfiguration
{ (
SkipFirstRunExperience = false, generateAspNetCertificate: true,
PrintTelemetryMessage = true printTelemetryMessage: true,
}, skipFirstRunExperience: false
),
_reporterMock.Object, _reporterMock.Object,
CliFallbackFolderPath, CliFallbackFolderPath,
_pathAdderMock.Object); _pathAdderMock.Object);
@ -76,10 +77,11 @@ namespace Microsoft.DotNet.Configurer.UnitTests
_aspNetCoreCertificateGeneratorMock.Object, _aspNetCoreCertificateGeneratorMock.Object,
_toolPathSentinelMock.Object, _toolPathSentinelMock.Object,
new DotnetFirstRunConfiguration new DotnetFirstRunConfiguration
{ (
SkipFirstRunExperience = true, generateAspNetCertificate: true,
PrintTelemetryMessage = true printTelemetryMessage: true,
}, skipFirstRunExperience: true
),
_reporterMock.Object, _reporterMock.Object,
CliFallbackFolderPath, CliFallbackFolderPath,
_pathAdderMock.Object); _pathAdderMock.Object);
@ -103,10 +105,11 @@ namespace Microsoft.DotNet.Configurer.UnitTests
_aspNetCoreCertificateGeneratorMock.Object, _aspNetCoreCertificateGeneratorMock.Object,
_toolPathSentinelMock.Object, _toolPathSentinelMock.Object,
new DotnetFirstRunConfiguration new DotnetFirstRunConfiguration
{ (
SkipFirstRunExperience = false, generateAspNetCertificate: true,
PrintTelemetryMessage = false printTelemetryMessage: false,
}, skipFirstRunExperience: false
),
_reporterMock.Object, _reporterMock.Object,
CliFallbackFolderPath, CliFallbackFolderPath,
_pathAdderMock.Object); _pathAdderMock.Object);
@ -130,10 +133,11 @@ namespace Microsoft.DotNet.Configurer.UnitTests
_aspNetCoreCertificateGeneratorMock.Object, _aspNetCoreCertificateGeneratorMock.Object,
_toolPathSentinelMock.Object, _toolPathSentinelMock.Object,
new DotnetFirstRunConfiguration new DotnetFirstRunConfiguration
{ (
SkipFirstRunExperience = false, generateAspNetCertificate: true,
PrintTelemetryMessage = true printTelemetryMessage: true,
}, skipFirstRunExperience: false
),
_reporterMock.Object, _reporterMock.Object,
CliFallbackFolderPath, CliFallbackFolderPath,
_pathAdderMock.Object); _pathAdderMock.Object);
@ -157,10 +161,11 @@ namespace Microsoft.DotNet.Configurer.UnitTests
_aspNetCoreCertificateGeneratorMock.Object, _aspNetCoreCertificateGeneratorMock.Object,
_toolPathSentinelMock.Object, _toolPathSentinelMock.Object,
new DotnetFirstRunConfiguration new DotnetFirstRunConfiguration
{ (
SkipFirstRunExperience = false, generateAspNetCertificate: true,
PrintTelemetryMessage = true printTelemetryMessage: true,
}, skipFirstRunExperience: false
),
_reporterMock.Object, _reporterMock.Object,
CliFallbackFolderPath, CliFallbackFolderPath,
_pathAdderMock.Object); _pathAdderMock.Object);
@ -183,10 +188,11 @@ namespace Microsoft.DotNet.Configurer.UnitTests
_aspNetCoreCertificateGeneratorMock.Object, _aspNetCoreCertificateGeneratorMock.Object,
_toolPathSentinelMock.Object, _toolPathSentinelMock.Object,
new DotnetFirstRunConfiguration new DotnetFirstRunConfiguration
{ (
SkipFirstRunExperience = false, generateAspNetCertificate: true,
PrintTelemetryMessage = true printTelemetryMessage: true,
}, skipFirstRunExperience: false
),
_reporterMock.Object, _reporterMock.Object,
CliFallbackFolderPath, CliFallbackFolderPath,
_pathAdderMock.Object); _pathAdderMock.Object);
@ -209,10 +215,11 @@ namespace Microsoft.DotNet.Configurer.UnitTests
_aspNetCoreCertificateGeneratorMock.Object, _aspNetCoreCertificateGeneratorMock.Object,
_toolPathSentinelMock.Object, _toolPathSentinelMock.Object,
new DotnetFirstRunConfiguration new DotnetFirstRunConfiguration
{ (
SkipFirstRunExperience = false, generateAspNetCertificate: true,
PrintTelemetryMessage = true printTelemetryMessage: true,
}, skipFirstRunExperience: false
),
_reporterMock.Object, _reporterMock.Object,
CliFallbackFolderPath, CliFallbackFolderPath,
_pathAdderMock.Object); _pathAdderMock.Object);
@ -235,10 +242,11 @@ namespace Microsoft.DotNet.Configurer.UnitTests
_aspNetCoreCertificateGeneratorMock.Object, _aspNetCoreCertificateGeneratorMock.Object,
_toolPathSentinelMock.Object, _toolPathSentinelMock.Object,
new DotnetFirstRunConfiguration new DotnetFirstRunConfiguration
{ (
SkipFirstRunExperience = true, generateAspNetCertificate: true,
PrintTelemetryMessage = true printTelemetryMessage: true,
}, skipFirstRunExperience: true
),
_reporterMock.Object, _reporterMock.Object,
CliFallbackFolderPath, CliFallbackFolderPath,
_pathAdderMock.Object); _pathAdderMock.Object);
@ -261,10 +269,11 @@ namespace Microsoft.DotNet.Configurer.UnitTests
_aspNetCoreCertificateGeneratorMock.Object, _aspNetCoreCertificateGeneratorMock.Object,
_toolPathSentinelMock.Object, _toolPathSentinelMock.Object,
new DotnetFirstRunConfiguration new DotnetFirstRunConfiguration
{ (
SkipFirstRunExperience = false, generateAspNetCertificate: true,
PrintTelemetryMessage = true printTelemetryMessage: true,
}, skipFirstRunExperience: false
),
_reporterMock.Object, _reporterMock.Object,
CliFallbackFolderPath, CliFallbackFolderPath,
_pathAdderMock.Object); _pathAdderMock.Object);
@ -288,10 +297,11 @@ namespace Microsoft.DotNet.Configurer.UnitTests
_aspNetCoreCertificateGeneratorMock.Object, _aspNetCoreCertificateGeneratorMock.Object,
_toolPathSentinelMock.Object, _toolPathSentinelMock.Object,
new DotnetFirstRunConfiguration new DotnetFirstRunConfiguration
{ (
SkipFirstRunExperience = false, generateAspNetCertificate: true,
PrintTelemetryMessage = true printTelemetryMessage: true,
}, skipFirstRunExperience: false
),
_reporterMock.Object, _reporterMock.Object,
CliFallbackFolderPath, CliFallbackFolderPath,
_pathAdderMock.Object); _pathAdderMock.Object);
@ -318,10 +328,11 @@ namespace Microsoft.DotNet.Configurer.UnitTests
_aspNetCoreCertificateGeneratorMock.Object, _aspNetCoreCertificateGeneratorMock.Object,
_toolPathSentinelMock.Object, _toolPathSentinelMock.Object,
new DotnetFirstRunConfiguration new DotnetFirstRunConfiguration
{ (
SkipFirstRunExperience = false, generateAspNetCertificate: true,
PrintTelemetryMessage = true printTelemetryMessage: true,
}, skipFirstRunExperience: false
),
_reporterMock.Object, _reporterMock.Object,
CliFallbackFolderPath, CliFallbackFolderPath,
_pathAdderMock.Object); _pathAdderMock.Object);
@ -349,10 +360,11 @@ namespace Microsoft.DotNet.Configurer.UnitTests
_aspNetCoreCertificateGeneratorMock.Object, _aspNetCoreCertificateGeneratorMock.Object,
_toolPathSentinelMock.Object, _toolPathSentinelMock.Object,
new DotnetFirstRunConfiguration new DotnetFirstRunConfiguration
{ (
SkipFirstRunExperience = false, generateAspNetCertificate: true,
PrintTelemetryMessage = true printTelemetryMessage: true,
}, skipFirstRunExperience: false
),
_reporterMock.Object, _reporterMock.Object,
CliFallbackFolderPath, CliFallbackFolderPath,
_pathAdderMock.Object); _pathAdderMock.Object);
@ -376,11 +388,11 @@ namespace Microsoft.DotNet.Configurer.UnitTests
_aspNetCoreCertificateGeneratorMock.Object, _aspNetCoreCertificateGeneratorMock.Object,
_toolPathSentinelMock.Object, _toolPathSentinelMock.Object,
new DotnetFirstRunConfiguration new DotnetFirstRunConfiguration
{ (
SkipFirstRunExperience = false, generateAspNetCertificate: true,
PrintTelemetryMessage = true, printTelemetryMessage: true,
GenerateAspNetCertificate = true skipFirstRunExperience: false
}, ),
_reporterMock.Object, _reporterMock.Object,
CliFallbackFolderPath, CliFallbackFolderPath,
_pathAdderMock.Object); _pathAdderMock.Object);
@ -404,10 +416,11 @@ namespace Microsoft.DotNet.Configurer.UnitTests
_aspNetCoreCertificateGeneratorMock.Object, _aspNetCoreCertificateGeneratorMock.Object,
_toolPathSentinelMock.Object, _toolPathSentinelMock.Object,
new DotnetFirstRunConfiguration new DotnetFirstRunConfiguration
{ (
SkipFirstRunExperience = false, generateAspNetCertificate: true,
PrintTelemetryMessage = true printTelemetryMessage: true,
}, skipFirstRunExperience: false
),
_reporterMock.Object, _reporterMock.Object,
CliFallbackFolderPath, CliFallbackFolderPath,
_pathAdderMock.Object); _pathAdderMock.Object);
@ -438,10 +451,11 @@ namespace Microsoft.DotNet.Configurer.UnitTests
_aspNetCoreCertificateGeneratorMock.Object, _aspNetCoreCertificateGeneratorMock.Object,
_toolPathSentinelMock.Object, _toolPathSentinelMock.Object,
new DotnetFirstRunConfiguration new DotnetFirstRunConfiguration
{ (
SkipFirstRunExperience = false, generateAspNetCertificate: true,
PrintTelemetryMessage = true printTelemetryMessage: true,
}, skipFirstRunExperience: false
),
_reporterMock.Object, _reporterMock.Object,
CliFallbackFolderPath, CliFallbackFolderPath,
_pathAdderMock.Object); _pathAdderMock.Object);
@ -464,10 +478,11 @@ namespace Microsoft.DotNet.Configurer.UnitTests
_aspNetCoreCertificateGeneratorMock.Object, _aspNetCoreCertificateGeneratorMock.Object,
_toolPathSentinelMock.Object, _toolPathSentinelMock.Object,
new DotnetFirstRunConfiguration new DotnetFirstRunConfiguration
{ (
SkipFirstRunExperience = false, generateAspNetCertificate: true,
PrintTelemetryMessage = true printTelemetryMessage: true,
}, skipFirstRunExperience: false
),
_reporterMock.Object, _reporterMock.Object,
CliFallbackFolderPath, CliFallbackFolderPath,
_pathAdderMock.Object); _pathAdderMock.Object);
@ -491,10 +506,11 @@ namespace Microsoft.DotNet.Configurer.UnitTests
_aspNetCoreCertificateGeneratorMock.Object, _aspNetCoreCertificateGeneratorMock.Object,
_toolPathSentinelMock.Object, _toolPathSentinelMock.Object,
new DotnetFirstRunConfiguration new DotnetFirstRunConfiguration
{ (
SkipFirstRunExperience = false, generateAspNetCertificate: true,
PrintTelemetryMessage = true printTelemetryMessage: true,
}, skipFirstRunExperience: true
),
_reporterMock.Object, _reporterMock.Object,
CliFallbackFolderPath, CliFallbackFolderPath,
_pathAdderMock.Object); _pathAdderMock.Object);
@ -518,10 +534,11 @@ namespace Microsoft.DotNet.Configurer.UnitTests
_aspNetCoreCertificateGeneratorMock.Object, _aspNetCoreCertificateGeneratorMock.Object,
_toolPathSentinelMock.Object, _toolPathSentinelMock.Object,
new DotnetFirstRunConfiguration new DotnetFirstRunConfiguration
{ (
SkipFirstRunExperience = false, generateAspNetCertificate: false,
PrintTelemetryMessage = true printTelemetryMessage: true,
}, skipFirstRunExperience: false
),
_reporterMock.Object, _reporterMock.Object,
CliFallbackFolderPath, CliFallbackFolderPath,
_pathAdderMock.Object); _pathAdderMock.Object);
@ -545,11 +562,11 @@ namespace Microsoft.DotNet.Configurer.UnitTests
_aspNetCoreCertificateGeneratorMock.Object, _aspNetCoreCertificateGeneratorMock.Object,
_toolPathSentinelMock.Object, _toolPathSentinelMock.Object,
new DotnetFirstRunConfiguration new DotnetFirstRunConfiguration
{ (
SkipFirstRunExperience = false, generateAspNetCertificate: true,
PrintTelemetryMessage = true, printTelemetryMessage: true,
GenerateAspNetCertificate = true skipFirstRunExperience: false
}, ),
_reporterMock.Object, _reporterMock.Object,
CliFallbackFolderPath, CliFallbackFolderPath,
_pathAdderMock.Object); _pathAdderMock.Object);
@ -573,11 +590,11 @@ namespace Microsoft.DotNet.Configurer.UnitTests
_aspNetCoreCertificateGeneratorMock.Object, _aspNetCoreCertificateGeneratorMock.Object,
_toolPathSentinelMock.Object, _toolPathSentinelMock.Object,
new DotnetFirstRunConfiguration new DotnetFirstRunConfiguration
{ (
SkipFirstRunExperience = false, generateAspNetCertificate: true,
PrintTelemetryMessage = true, printTelemetryMessage: true,
GenerateAspNetCertificate = true skipFirstRunExperience: false
}, ),
_reporterMock.Object, _reporterMock.Object,
CliFallbackFolderPath, CliFallbackFolderPath,
_pathAdderMock.Object); _pathAdderMock.Object);
@ -598,11 +615,11 @@ namespace Microsoft.DotNet.Configurer.UnitTests
_aspNetCoreCertificateGeneratorMock.Object, _aspNetCoreCertificateGeneratorMock.Object,
_toolPathSentinelMock.Object, _toolPathSentinelMock.Object,
new DotnetFirstRunConfiguration new DotnetFirstRunConfiguration
{ (
SkipFirstRunExperience = true, generateAspNetCertificate: true,
PrintTelemetryMessage = true, printTelemetryMessage: true,
GenerateAspNetCertificate = true skipFirstRunExperience: true
}, ),
_reporterMock.Object, _reporterMock.Object,
CliFallbackFolderPath, CliFallbackFolderPath,
_pathAdderMock.Object); _pathAdderMock.Object);