public void LoadFromString_WithInvalidOrNullValue_ShouldThrow(string input, Type expectedException) { var option = new ResponseFromFileOption(); Action testAction = () => option.LoadFromString(input); testAction.ShouldThrow(expectedException); }
public void LoadFromString_WithInvalidRetryTimeout_ShouldThrowArgumentException() { string input = "ContentRootPath;file.txt;abc"; var option = new ResponseFromFileOption(); Action testAction = () => option.LoadFromString(input); testAction.ShouldThrow <ArgumentException>(); }
public void LoadFromString_WithValidInput_StringValueShouldEqualInput() { const string input = "ContentRootPath;file.txt;5300"; var option = new ResponseFromFileOption(); option.LoadFromString(input); option.GetStringValue().ShouldBe(input); }
public void LoadFromString_WithValidInput_ValueShouldNotBeNull() { const string input = "ContentRootPath;file.txt;5300"; var option = new ResponseFromFileOption(); option.LoadFromString(input); option.Value.ShouldNotBeNull(); }
public void LoadFromString_WithValidRetryTimeout_RetryTimeoutInValueShouldMatch(string input, int expectedTimeout) { var option = new ResponseFromFileOption(); option.LoadFromString(input); option.Value.Code503RetryInterval .ShouldBe(expectedTimeout); }
public void LoadFromString_WithDirrefectLetterCasing_CasingInValueShouldMatchInput(string input, string path, bool shouldBeEqual) { var option = new ResponseFromFileOption(); option.LoadFromString(input); bool isPathEqual = option.Value.File.Path == path; isPathEqual.ShouldBe(shouldBeEqual); }
public void LoadFromString_WithVariousEnvDirectory_EnvDirectoryInValueShouldMatchInput(string input, EnvDirectory baseDir, bool shouldBeEqual) { var option = new ResponseFromFileOption(); option.LoadFromString(input); bool isDirEqual = option.Value.File.BaseDir == baseDir; isDirEqual.ShouldBe(shouldBeEqual); }
public void LoadFromString_WithValidFileType_ShouldSucceed(string input, string fileName) { var option = new ResponseFromFileOption(); string filePath = Path.Combine(_webHostEnvironment.ContentRootPath, fileName); File.Create(filePath); option.LoadFromString(input); option.Value.File.Path .ShouldEndWith(fileName); }
public void ParametrizedConstructor_WithValidParams_ValueShouldEqualParams() { string filePath = "some.txt"; EnvDirectory baseDir = EnvDirectory.ContentRootPath; int code503RetryInterval = 2000; ResponseFromFileOption opt = new ResponseFromFileOption(filePath, baseDir, code503RetryInterval); opt.Value.ShouldNotBeNull(); opt.Value.File.Path.ShouldBe(filePath); opt.Value.File.BaseDir.ShouldBe(baseDir); opt.Value.Code503RetryInterval.ShouldBe(code503RetryInterval); }
public void LoadFromString_WithInvalidFileType_ShouldThrow(string input, string fileName, Type expectedExceptionType) { var option = new ResponseFromFileOption(); string filePath = Path.Combine(_webHostEnvironment.ContentRootPath, fileName); File.Create(filePath); Action testAction = () => { option.LoadFromString(input); }; testAction.ShouldThrow(expectedExceptionType); }
public void UseResponseFile_WithValidData_GetOptionsValueShouldEqualInput(string relativePath, EnvDirectory baseDir) { MiddlewareOptionsBuilder builder = new MiddlewareOptionsBuilder(_dirMapperSvc); string filePath = Path.Combine(_dirMapperSvc.GetAbsolutePath(baseDir), relativePath); File.Create(filePath); builder.UseResponseFromFile(relativePath, baseDir); ResponseFromFileOption option = builder .GetOptions() .GetSingleOrDefault <ResponseFromFileOption>(); option.Value.ShouldNotBeNull(); option.Value.File.Path.ShouldBe(relativePath); option.Value.File.BaseDir.ShouldBe(baseDir); }