add Unit test for Http.cs setting

This commit is contained in:
弘韬 张 2021-02-22 13:45:28 +08:00
parent cfbdf294bb
commit f940e695a1

View file

@ -0,0 +1,33 @@
using NUnit.Framework;
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]
public void TestSettingUpdate()
{
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);
}
}
}