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

33 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 Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Infrastructure.Http;
2024-03-26 20:15:59 +00:00
using NUnit.Framework.Legacy;
2021-02-22 05:45:28 +00:00
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";
2024-03-26 20:15:59 +00:00
ClassicAssert.AreEqual(Http.WebProxy.Address, new Uri($"http://{proxy.Server}:{proxy.Port}"));
ClassicAssert.IsNull(Http.WebProxy.Credentials);
2021-02-22 05:45:28 +00:00
proxy.UserName = "test";
2024-03-26 20:15:59 +00:00
ClassicAssert.NotNull(Http.WebProxy.Credentials);
ClassicAssert.AreEqual(Http.WebProxy.Credentials.GetCredential(Http.WebProxy.Address, "Basic").UserName, proxy.UserName);
ClassicAssert.AreEqual(Http.WebProxy.Credentials.GetCredential(Http.WebProxy.Address, "Basic").Password, "");
2021-02-22 05:45:28 +00:00
proxy.Password = "test password";
2024-03-26 20:15:59 +00:00
ClassicAssert.AreEqual(Http.WebProxy.Credentials.GetCredential(Http.WebProxy.Address, "Basic").Password, proxy.Password);
2021-02-22 05:45:28 +00:00
}
}
}