anchor.diff:  
   import 'package:flutter_tools/src/base/io.dart';
   import 'package:flutter_tools/src/base/logger.dart';
  +import 'package:flutter_tools/src/build_info.dart';
   import 'package:flutter_tools/src/device.dart';
  +import 'package:flutter_tools/src/ios/devices.dart';
   import 'package:flutter_tools/src/mdns_discovery.dart';
  +import 'package:flutter_tools/src/project.dart';
   import 'package:flutter_tools/src/reporting/reporting.dart';
  -import 'package:mockito/mockito.dart';
   import 'package:multicast_dns/multicast_dns.dart';
  +import 'package:test/fake.dart';
   
   import '../src/common.dart';
  -import '../src/mocks.dart';
   
   void main() {
     group('mDNS Discovery', () {
  
positive.code:       resetNetworkInterfaceLister();
      });
  
      MDnsClient getMockClient(
        List<PtrResourceRecord> ptrRecords,
        Map<String, List<SrvResourceRecord>> srvResponse, {
        Map<String, List<TxtResourceRecord>> txtResponse = const <String, List<TxtResourceRecord>>{},
      }) {
        final MDnsClient client = MockMDnsClient();
  
        when(client.lookup<PtrResourceRecord>(
          ResourceRecordQuery.serverPointer(MDnsObservatoryDiscovery.dartObservatoryName),
        )).thenAnswer((_) => Stream<PtrResourceRecord>.fromIterable(ptrRecords));
  
        for (final MapEntry<String, List<SrvResourceRecord>> entry in srvResponse.entries) {
          when(client.lookup<SrvResourceRecord>(
            ResourceRecordQuery.service(entry.key),
          )).thenAnswer((_) => Stream<SrvResourceRecord>.fromIterable(entry.value));
        }
  
        for (final MapEntry<String, List<TxtResourceRecord>> entry in txtResponse.entries) {
          when(client.lookup<TxtResourceRecord>(
            ResourceRecordQuery.text(entry.key),
          )).thenAnswer((_) => Stream<TxtResourceRecord>.fromIterable(entry.value));
        }
        return client;
      }
  
      testWithoutContext('No ports available', () async {
        final MDnsClient client = getMockClient(<PtrResourceRecord>[], <String, List<SrvResourceRecord>>{});
  
        final MDnsObservatoryDiscovery portDiscovery = MDnsObservatoryDiscovery(
          mdnsClient: client,
  
negative.code:     });
  
      testWithoutContext('Correctly builds Observatory URI with hostVmservicePort == 0', () async {
        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 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();
  }
  