2021-08-11 11:06:46 +03:00
|
|
|
#if !__WATCHOS__
|
2022-09-08 17:55:52 +03:00
|
|
|
using System;
|
2019-10-08 04:53:04 +03:00
|
|
|
using Foundation;
|
|
|
|
using Network;
|
|
|
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
|
|
namespace MonoTouchFixtures.Network {
|
|
|
|
[TestFixture]
|
|
|
|
[Preserve (AllMembers = true)]
|
|
|
|
public class NWBrowserDescriptorTest {
|
|
|
|
|
|
|
|
NWBrowserDescriptor descriptor;
|
|
|
|
string type = "_ftp._tcp";
|
|
|
|
string domain = "MonoTouchFixtures.Network";
|
|
|
|
|
2020-07-15 19:14:22 +03:00
|
|
|
[OneTimeSetUp]
|
2019-10-08 04:53:04 +03:00
|
|
|
public void Init () => TestRuntime.AssertXcodeVersion (11, 0);
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
public void SetUp ()
|
|
|
|
{
|
|
|
|
descriptor = NWBrowserDescriptor.CreateBonjourService (type, domain);
|
|
|
|
}
|
|
|
|
|
|
|
|
[TearDown]
|
|
|
|
public void TearDown ()
|
|
|
|
{
|
|
|
|
descriptor.Dispose ();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestIncludeTxtRecordProperty ()
|
|
|
|
{
|
|
|
|
Assert.IsFalse (descriptor.IncludeTxtRecord, "Get default value.");
|
|
|
|
descriptor.IncludeTxtRecord = true;
|
|
|
|
Assert.IsTrue (descriptor.IncludeTxtRecord, "Get new value.");
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestCreateNullDomain ()
|
|
|
|
{
|
2022-11-10 19:59:26 +03:00
|
|
|
using (var newDescriptor = NWBrowserDescriptor.CreateBonjourService (type)) {
|
2019-10-08 04:53:04 +03:00
|
|
|
Assert.AreEqual (type, descriptor.BonjourType, "service type");
|
|
|
|
Assert.IsNull (newDescriptor.BonjourDomain);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestBonjourTypeProperty () => Assert.AreEqual (type, descriptor.BonjourType);
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestBonjourDomainProperty () => Assert.AreEqual (domain, descriptor.BonjourDomain);
|
2022-09-08 17:55:52 +03:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestApplicationServiceConstructor ()
|
|
|
|
{
|
|
|
|
TestRuntime.AssertXcodeVersion (14, 0);
|
|
|
|
Assert.Throws<ArgumentNullException> (() => {
|
|
|
|
using var appServiceDescriptor = NWBrowserDescriptor.CreateApplicationServiceName (null);
|
|
|
|
}, "App service is null");
|
2022-11-10 19:59:26 +03:00
|
|
|
|
|
|
|
var appName = "myService";
|
2022-09-08 17:55:52 +03:00
|
|
|
using var appServiceDescriptor = NWBrowserDescriptor.CreateApplicationServiceName (appName);
|
|
|
|
Assert.AreEqual (appName, appServiceDescriptor.ApplicationServiceName);
|
|
|
|
}
|
2019-10-08 04:53:04 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|