Flow.Launcher/Flow.Launcher.Test/HttpTest.cs

34 lines
1.2 KiB
C#
Raw Permalink Normal View History

2021-02-22 10:27:36 +00:00
using NUnit.Framework;
2021-02-22 05:45:28 +00:00
using System;
using System.Collections.Generic;
using System.Text;
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Infrastructure.Http;
namespace Flow.Launcher.Test
{
[TestFixture]
class HttpTest
{
[Test]
2021-02-22 10:27:36 +00:00
public void GivenHttpProxy_WhenUpdated_ThenWebProxyShouldAlsoBeUpdatedToTheSame()
2021-02-22 05:45:28 +00:00
{
HttpProxy proxy = new HttpProxy();
Http.Proxy = proxy;
proxy.Enabled = true;
proxy.Server = "127.0.0.1";
Assert.AreEqual(Http.WebProxy.Address, new Uri($"http://{proxy.Server}:{proxy.Port}"));
Assert.IsNull(Http.WebProxy.Credentials);
proxy.UserName = "test";
Assert.NotNull(Http.WebProxy.Credentials);
Assert.AreEqual(Http.WebProxy.Credentials.GetCredential(Http.WebProxy.Address, "Basic").UserName, proxy.UserName);
Assert.AreEqual(Http.WebProxy.Credentials.GetCredential(Http.WebProxy.Address, "Basic").Password, "");
proxy.Password = "test password";
Assert.AreEqual(Http.WebProxy.Credentials.GetCredential(Http.WebProxy.Address, "Basic").Password, proxy.Password);
}
}
}