anchor.diff:      });
   
       testWithoutContext('Correctly builds Observatory URI with hostVmservicePort == 0', () async {
  -      final MDnsClient client = getMockClient(
  -        <PtrResourceRecord>[
  -          PtrResourceRecord('foo', year3000, domainName: 'bar'),
  -        ],
  -        <String, List<SrvResourceRecord>>{
  -          'bar': <SrvResourceRecord>[
  -            SrvResourceRecord('bar', year3000, port: 123, weight: 1, priority: 1, target: 'appId'),
  -          ],
  -        },
  -      );
  -
  -      final MockIOSDevice mockDevice = MockIOSDevice();
  -      when(mockDevice.portForwarder).thenReturn(const NoOpDevicePortForwarder());
  -      final MDnsObservatoryDiscovery portDiscovery = MDnsObservatoryDiscovery(
  -        mdnsClient: client,
  -        logger: BufferLogger.test(),
  -        flutterUsage: TestUsage(),
  -      );
  -      final Uri uri = await portDiscovery.getObservatoryUri('bar', mockDevice, hostVmservicePort: 0);
  +      final MDnsClient client = FakeMDnsClient(
  +        <PtrResourceRecord>[
  +          PtrResourceRecord('foo', year3000, domainName: 'bar'),
  +        ],
  +        <String, List<SrvResourceRecord>>{
  +          'bar': <SrvResourceRecord>[
  +            SrvResourceRecord('bar', year3000, port: 123, weight: 1, priority: 1, target: 'appId'),
  +          ],
  +        },
  +      );
  +
  +      final FakeIOSDevice device = FakeIOSDevice();
  +      final MDnsObservatoryDiscovery portDiscovery = MDnsObservatoryDiscovery(
  +        mdnsClient: client,
  +        logger: BufferLogger.test(),
  +        flutterUsage: TestUsage(),
  +      );
  +      final Uri uri = await portDiscovery.getObservatoryUri('bar', device, hostVmservicePort: 0);
         expect(uri.toString(), 'http://127.0.0.1:123/');
       });
     });
   }
   
  -class MockMDnsClient extends Mock implements MDnsClient {}
  +class FakeMDnsClient extends Fake implements MDnsClient {
  +  FakeMDnsClient(this.ptrRecords, this.srvResponse, {
  +    this.txtResponse = const <String, List<TxtResourceRecord>>{},
  +    this.osErrorOnStart = false,
  +  });
  +
  +  final List<PtrResourceRecord> ptrRecords;
  +  final Map<String, List<SrvResourceRecord>> srvResponse;
  +  final Map<String, List<TxtResourceRecord>> txtResponse;
  +  final bool osErrorOnStart;
  +
  +  @override
  +  Future<void> start({
  +    InternetAddress listenAddress,
  +    NetworkInterfacesFactory interfacesFactory,
  +    int mDnsPort = 5353,
  +    InternetAddress mDnsAddress,
  +  }) async {
  +    if (osErrorOnStart) {
  +      throw const OSError('Operation not suppoted on socket', 102);
  +    }
  +  }
  +
  +  @override
  +  Stream<T> lookup<T extends ResourceRecord>(
  +    ResourceRecordQuery query, {
  +    Duration timeout = const Duration(seconds: 5),
  +  }) {
  +    if (T == PtrResourceRecord && query.fullyQualifiedName == MDnsObservatoryDiscovery.dartObservatoryName) {
  +      return Stream<PtrResourceRecord>.fromIterable(ptrRecords) as Stream<T>;
  +    }
  +    if (T == SrvResourceRecord) {
  +      final String key = query.fullyQualifiedName;
  +      return Stream<SrvResourceRecord>.fromIterable(srvResponse[key] ?? <SrvResourceRecord>[]) as Stream<T>;
  +    }
  +    if (T == TxtResourceRecord) {
  +      final String key = query.fullyQualifiedName;
  +      return Stream<TxtResourceRecord>.fromIterable(txtResponse[key] ?? <TxtResourceRecord>[]) as Stream<T>;
  +    }
  +    throw UnsupportedError('Unsupported query type $T');
  +  }
  +
  +  @override
  +  void stop() {}
  +}
  +
  +class FakeIOSDevice extends Fake implements IOSDevice {
  +  @override
  +  Future<TargetPlatform> get targetPlatform async => TargetPlatform.ios;
  +
  +  @override
  +  bool isSupported() => true;
  +
  +  @override
  +  bool isSupportedForProject(FlutterProject flutterProject) => true;
  +
  +  @override
  +  DevicePortForwarder get portForwarder => const NoOpDevicePortForwarder();
  +}
  
positive.code:     });
  
      testWithoutContext('Multiple ports available per process, with appId', () async {
        final MDnsClient client = getMockClient(
          <PtrResourceRecord>[
            PtrResourceRecord('foo', year3000, domainName: 'bar'),
            PtrResourceRecord('baz', year3000, domainName: 'fiz'),
  
negative.code:     });
  
      testWithoutContext('Multiple ports available, without appId', () async {
        final MDnsClient client = FakeMDnsClient(
          <PtrResourceRecord>[
            PtrResourceRecord('foo', year3000, domainName: 'bar'),
            PtrResourceRecord('baz', year3000, domainName: 'fiz'),
  