private void CreateTargetUriTestWithPath(InputArg input) { using (var memory = new MemoryStream()) using (var writer = new StreamWriter(memory)) { writer.Write(input.ToString()); writer.Flush(); memory.Seek(0, SeekOrigin.Begin); var oparg = new OperationArguments.Impl(memory); oparg.UseHttpPath = true; Assert.NotNull(oparg); Assert.Equal(input.Protocol ?? string.Empty, oparg.QueryProtocol); Assert.Equal(input.Host ?? string.Empty, oparg.QueryHost); Assert.Equal(input.Path, oparg.QueryPath); Assert.Equal(input.Username, oparg.CredUsername); Assert.Equal(input.Password, oparg.CredPassword); // file or unc paths are treated specially if (oparg.QueryUri.Scheme != System.Uri.UriSchemeFile) { Assert.Equal("/" + input.Path, oparg.QueryUri.AbsolutePath); } } }
private void CreateTargetUriTestDefault(InputArg input) { using (var memory = new MemoryStream()) using (var writer = new StreamWriter(memory)) { writer.Write(input.ToString()); writer.Flush(); memory.Seek(0, SeekOrigin.Begin); var oparg = new OperationArguments(memory); Assert.IsNotNull(oparg); Assert.AreEqual(input.Protocol ?? string.Empty, oparg.QueryProtocol); Assert.AreEqual(input.Host ?? string.Empty, oparg.QueryHost); Assert.AreEqual(input.Path, oparg.QueryPath); Assert.AreEqual(input.Username, oparg.CredUsername); Assert.AreEqual(input.Password, oparg.CredPassword); // file or unc paths are treated specially if (oparg.QueryUri.Scheme != "file") { Assert.AreEqual("/", oparg.QueryUri.AbsolutePath); } } }
public void SpecialCharacters() { var input = new InputArg { Host = "example.visualstudio.com", Password = "******", Path = "path", Protocol = Uri.UriSchemeHttps, Username = "******" }; OperationArguments cut; using (var memory = new MemoryStream()) using (var writer = new StreamWriter(memory)) { writer.Write(input.ToString()); writer.Flush(); memory.Seek(0, SeekOrigin.Begin); cut = new OperationArguments(RuntimeContext.Default, memory); } Assert.Equal(input.Protocol, cut.QueryProtocol, StringComparer.Ordinal); Assert.Equal(input.Host, cut.QueryHost, StringComparer.Ordinal); Assert.Equal(input.Path, cut.QueryPath, StringComparer.Ordinal); Assert.Equal(input.Username, cut.Username, StringComparer.Ordinal); Assert.Equal(input.Password, cut.Password, StringComparer.Ordinal); Assert.Equal("https://userNamể@example.visualstudio.com/path", cut.TargetUri.ToString(), StringComparer.Ordinal); var expected = input.ToString(); var actual = cut.ToString(); Assert.Equal(expected, actual, StringComparer.Ordinal); }
public void Typical() { var input = new InputArg { Host = "example.visualstudio.com", Password = "******", Path = "path", Protocol = "https", Username = "******", }; OperationArguments cut; using (var memory = new MemoryStream()) using (var writer = new StreamWriter(memory)) { writer.Write(input.ToString()); writer.Flush(); memory.Seek(0, SeekOrigin.Begin); cut = new OperationArguments(RuntimeContext.Default, memory); } Assert.Equal(input.Protocol, cut.QueryProtocol); Assert.Equal(input.Host, cut.QueryHost); Assert.Equal(input.Path, cut.QueryPath); Assert.Equal(input.Username, cut.Username); Assert.Equal(input.Password, cut.Password); Assert.Equal("https://[email protected]/path", cut.TargetUri.ToString()); var expected = ReadLines(input.ToString()); var actual = ReadLines(cut.ToString()); Assert.Equal(expected, actual); }
public void UsernameWithDomain() { var input = new InputArg { Host = "example.visualstudio.com", Password = "******", Path = "path", Protocol = Uri.UriSchemeHttps, Username = @"DOMAIN\username" }; var cut = CreateTargetUriTestDefault(input); Assert.Equal(@"https://DOMAIN\[email protected]/path", cut.TargetUri.ToString(), StringComparer.Ordinal); Assert.Equal(input.ToString(), cut.ToString(), StringComparer.Ordinal); }
public void EmailAsUserName() { var input = new InputArg { Host = "example.visualstudio.com", Password = "******", Path = "path", Protocol = Uri.UriSchemeHttps, Username = "******" }; var cut = CreateTargetUriTestDefault(input); Assert.Equal("https://[email protected]@example.visualstudio.com/path", cut.TargetUri.ToString(), StringComparer.Ordinal); Assert.Equal(input.ToString(), cut.ToString(), StringComparer.Ordinal); }
public void Typical() { var input = new InputArg { Host = "example.visualstudio.com", Password = "******", Path = "path", Protocol = "https", Username = "******", }; var cut = CreateTargetUriTestDefault(input); Assert.Equal("https://[email protected]/path", cut.TargetUri.ToString()); Assert.Equal(input.ToString(), cut.ToString(), StringComparer.Ordinal); }
public async Task SpecialCharacters() { var input = new InputArg { Host = "example.visualstudio.com", Password = "******", Path = "path", Protocol = Uri.UriSchemeHttps, Username = "******" }; var cut = await CreateTargetUriTestDefault(input); Assert.Equal("https://userNamể@example.visualstudio.com/path", cut.TargetUri.ToString(), StringComparer.Ordinal); Assert.Equal(input.ToString(), cut.ToString(), StringComparer.Ordinal); }
private void CreateTargetUriTestDefault(InputArg input) { using (var memory = new MemoryStream()) using (var writer = new StreamWriter(memory)) { writer.Write(input.ToString()); writer.Flush(); memory.Seek(0, SeekOrigin.Begin); var oparg = new OperationArguments(RuntimeContext.Default, memory); Assert.NotNull(oparg); Assert.Equal(input.Protocol ?? string.Empty, oparg.QueryProtocol, StringComparer.Ordinal); Assert.Equal(input.Host ?? string.Empty, oparg.QueryHost, StringComparer.Ordinal); Assert.Equal(input.Path, oparg.QueryPath, StringComparer.Ordinal); Assert.Equal(input.Username, oparg.Username, StringComparer.Ordinal); Assert.Equal(input.Password, oparg.Password, StringComparer.Ordinal); } }
private void CreateTargetUriTestWithPath(InputArg input) { using (var memory = new MemoryStream()) using (var writer = new StreamWriter(memory)) { writer.Write(input.ToString()); writer.Flush(); memory.Seek(0, SeekOrigin.Begin); var oparg = new OperationArguments(memory); oparg.UseHttpPath = true; Assert.IsNotNull(oparg); Assert.AreEqual(input.Protocol ?? string.Empty, oparg.QueryProtocol); Assert.AreEqual(input.Host ?? string.Empty, oparg.QueryHost); Assert.AreEqual(input.Path, oparg.QueryPath); Assert.AreEqual(input.Username, oparg.CredUsername); Assert.AreEqual(input.Password, oparg.CredPassword); // file or unc paths are treated specially if (oparg.QueryUri.Scheme != "file") { Assert.AreEqual("/" + input.Path, oparg.QueryUri.AbsolutePath); } } }