public void GetParameters_ConvertsLongParamCorrectly() { var command = Substitute.For<ICommand>(); command.Parameters.Returns(new Hashtable { { "Port", "80" } }); var installerContext = new InstallerContext(command); var sut = installerContext.GetParameters<SingleLongParameter>(); Assert.Equal(80, sut.Port); }
public void GetParameters_ConvertsFloatParamCorrectly() { var command = Substitute.For<ICommand>(); command.Parameters.Returns(new Hashtable { { "NetFramework", "4.5" } }); var installerContext = new InstallerContext(command); var sut = installerContext.GetParameters<SingleFloatParameter>(); Assert.Equal(4.5f, sut.NetFramework); }
public void GetParameters_ThrowsWhenTypeNotCompatibleWithShort() { var command = Substitute.For<ICommand>(); command.Parameters.Returns(new Hashtable { { "Port", "blah" } }); var installerContext = new InstallerContext(command); var sut = Catch.Exception(() => installerContext.GetParameters<SingleShortParameter>()); Assert.IsType<ParameterCastException>(sut); Assert.Equal("Cannot cast to type System.Int16 for parameter name Port", sut.Message); }
public void GetParameters_ThrowsWhenRequiredParameterIsNotGiven() { var command = Substitute.For<ICommand>(); command.Parameters.Returns(new Hashtable { { "Port", "80" } }); var installerContext = new InstallerContext(command); var sut = Catch.Exception(() => installerContext.GetParameters<RequiredParameters>()); Assert.IsType<RequiredParameterNotGivenException>(sut); Assert.Equal("Parameter SiteName is required please specify it.", sut.Message); }
public void GetParameters_SetsAllParameters() { var command = Substitute.For<ICommand>(); command.Parameters.Returns(new Hashtable { { "Port", "80"}, {"SiteName", "MySite"}, {"AppPoolName", "AppPool1"} }); var installerContext = new InstallerContext(command); var sut = installerContext.GetParameters<MultipleParameters>(); Assert.Equal(80, sut.Port); Assert.Equal("MySite", sut.SiteName); Assert.Equal("AppPool1", sut.AppPoolName); }
public void GetParameters_IgnoresExtraNotRequiredParameters() { var command = Substitute.For<ICommand>(); command.Parameters.Returns(new Hashtable { { "SiteName", "MySite" }, {"ApplicationPoolName", "AppPool1"} }); var installerContext = new InstallerContext(command); var sut = installerContext.GetParameters<SingleStringParameter>(); Assert.Equal("MySite", sut.SiteName); }
public void GetParameters_GivesParametersWhenSuppliedUsingCorrectCasing() { var command = Substitute.For<ICommand>(); command.Parameters.Returns(new Hashtable { { "SiteName", "MySite" } }); var installerContext = new InstallerContext(command); var sut = installerContext.GetParameters<SingleStringParameter>(); Assert.Equal("MySite", sut.SiteName); }
public void GetParameters_DoesNotThrowWhenNotRequiredParamNotGiven() { var command = Substitute.For<ICommand>(); command.Parameters.Returns(new Hashtable { { "SiteName", "MySite" } }); var installerContext = new InstallerContext(command); var sut = installerContext.GetParameters<RequiredParameters>(); Assert.Equal("MySite", sut.SiteName); }