anchor.diff:          );
           final expectedDate = startedAtDayUtc.millisecondsSinceEpoch;
   
  -        whenDocumentSnapshotData().thenReturn(DocumentData.fromMap(buildJson));
  -
  -        await onBuildAddedHandler(documentSnapshotMock, null);
  +        whenDocument().thenReturn(documentReference);
  +        when(documentSnapshot.data).thenReturn(
  +          DocumentData.fromMap(buildJson),
  +        );
  +
  +        await onBuildAddedHandler(documentSnapshot, null);
   
           expect(
  -          verify(firestoreMock.document(captureAny)).captured.single,
  +          verify(firestore.document(captureAny)).captured.single,
             contains(expectedDate.toString()),
           );
         },
  
positive.code:           buildStatus: BuildStatus.inProgress,
          );
  
          whenDocumentSnapshotData().thenReturn(DocumentData.fromMap(buildJson));
  
          await onBuildAddedHandler(documentSnapshotMock, null);
  
          final countMatcher = predicate<DocumentData>((data) {
            final count =
                data.getNestedData(buildDayStatusFieldName).getInt('operand');
  
            return count == 1;
          });
  
          verify(
            documentReferenceMock.setData(
              argThat(countMatcher),
              any,
            ),
          ).called(1);
  
negative.code: // ignore_for_file: avoid_redundant_argument_values
  
  void main() {
    const tasksCollectionName = 'tasks';
    const projectId = 'projectId';
    const durationInMilliseconds = 123;
    const buildStatus = BuildStatus.successful;
  
    final startedAt = DateTime.now();
    final startedAtDayUtc = startedAt.toUtc().date;
    final testDataGenerator = BuildTestDataGenerator(
      projectId: projectId,
    );
    final buildJson = testDataGenerator.generateBuildJson();
    final buildDocumentData = DocumentData.fromMap(buildJson);
  
    final firestore = FirestoreMock();
    final collectionReference = CollectionReferenceMock();
    final documentReference = DocumentReferenceMock();
    final documentSnapshot = DocumentSnapshotMock();
  
    Matcher documentFieldIncrementMatcher(String fieldName, int expectedCount) {
      return predicate<DocumentData>((data) {
        final count = data.getNestedData(fieldName).getInt('operand');
  
        return count == expectedCount;
      });
    }
  
    PostExpectation<Firestore> whenFirestore() {
      return when(documentSnapshot.firestore);
    }
  
    PostExpectation<DocumentReference> whenDocument() {
      whenFirestore().thenReturn(firestore);
  
      return when(firestore.document(any));
    }
  
    PostExpectation<Future<DocumentReference>> whenCreateTaskDocument({
      Exception exception,
    }) {
      when(documentReference.setData(any, any))
          .thenAnswer((_) => Future.error(exception));
  
      when(firestore.collection(tasksCollectionName))
          .thenReturn(collectionReference);
  
      return when(collectionReference.add(any));
    }
  
    tearDown(() {
      reset(documentSnapshot);
      reset(firestore);
      reset(collectionReference);
      reset(documentReference);
    });
  
    group("onBuildAddedHandler", () {
      test(
        "does not increment the successful builds duration if the build document snapshot's duration is null",
        () async {
  