@@ -119,13 +119,14 @@ - (FSTTransactionTester *)runWithStages:(NSArray<TransactionStage> *)stages;
119
119
- (void )expectDoc : (NSObject *)expected ;
120
120
- (void )expectNoDoc ;
121
121
- (void )expectError : (FIRFirestoreErrorCode)expected ;
122
+
123
+ @property (atomic , strong , readwrite ) NSArray <TransactionStage> *stages;
124
+ @property (atomic , strong , readwrite ) FIRDocumentReference *docRef;
125
+ @property (atomic , assign , readwrite ) BOOL fromExistingDoc;
122
126
@end
123
127
124
128
@implementation FSTTransactionTester {
125
129
FIRFirestore *_db;
126
- FIRDocumentReference *_docRef;
127
- BOOL _fromExistingDoc;
128
- NSArray <TransactionStage> *_stages;
129
130
FSTTransactionTests *_testCase;
130
131
NSMutableArray <XCTestExpectation *> *_testExpectations;
131
132
}
@@ -141,17 +142,17 @@ - (instancetype)initWithDb:(FIRFirestore *)db testCase:(FSTTransactionTests *)te
141
142
}
142
143
143
144
- (FSTTransactionTester *)withExistingDoc {
144
- _fromExistingDoc = YES ;
145
+ self. fromExistingDoc = YES ;
145
146
return self;
146
147
}
147
148
148
149
- (FSTTransactionTester *)withNonexistentDoc {
149
- _fromExistingDoc = NO ;
150
+ self. fromExistingDoc = NO ;
150
151
return self;
151
152
}
152
153
153
154
- (FSTTransactionTester *)runWithStages : (NSArray <TransactionStage> *)stages {
154
- _stages = stages;
155
+ self. stages = stages;
155
156
return self;
156
157
}
157
158
@@ -160,7 +161,7 @@ - (void)expectDoc:(NSObject *)expected {
160
161
[self runSuccessfulTransaction ];
161
162
162
163
XCTestExpectation *expectation = [_testCase expectationWithDescription: @" expectDoc" ];
163
- [_docRef getDocumentWithCompletion: ^(FIRDocumentSnapshot *snapshot, NSError *error) {
164
+ [self .docRef getDocumentWithCompletion: ^(FIRDocumentSnapshot *snapshot, NSError *error) {
164
165
[self ->_testCase assertSnapshot: snapshot equalsObject: expected error: error];
165
166
[expectation fulfill ];
166
167
}];
@@ -174,7 +175,7 @@ - (void)expectNoDoc {
174
175
[self runSuccessfulTransaction ];
175
176
176
177
XCTestExpectation *expectation = [_testCase expectationWithDescription: @" expectNoDoc" ];
177
- [_docRef getDocumentWithCompletion: ^(FIRDocumentSnapshot *snapshot, NSError *error) {
178
+ [self .docRef getDocumentWithCompletion: ^(FIRDocumentSnapshot *snapshot, NSError *error) {
178
179
[self ->_testCase assertDoesNotExistWithSnapshot: snapshot error: error];
179
180
[expectation fulfill ];
180
181
}];
@@ -191,9 +192,9 @@ - (void)expectError:(FIRFirestoreErrorCode)expected {
191
192
}
192
193
193
194
- (void )prepareDoc {
194
- _docRef = [[_db collectionWithPath: @" nonexistent" ] documentWithAutoID ];
195
+ self. docRef = [[_db collectionWithPath: @" nonexistent" ] documentWithAutoID ];
195
196
if (_fromExistingDoc) {
196
- NSError *setError = [self writeDocumentRef: _docRef data: @{@" foo" : @" bar" }];
197
+ NSError *setError = [self writeDocumentRef: self .docRef data: @{@" foo" : @" bar" }];
197
198
NSString *message = [NSString stringWithFormat: @" Failed set at %@ " , [self stageNames ]];
198
199
[_testCase assertNilError: setError message: message];
199
200
}
@@ -217,8 +218,8 @@ - (void)runSuccessfulTransaction {
217
218
[_testCase expectationWithDescription: @" runSuccessfulTransaction" ];
218
219
[_db
219
220
runTransactionWithBlock: ^id _Nullable (FIRTransaction *transaction, NSError **) {
220
- for (TransactionStage stage in self-> _stages ) {
221
- stage (transaction, self-> _docRef );
221
+ for (TransactionStage stage in self. stages ) {
222
+ stage (transaction, self. docRef );
222
223
}
223
224
return @YES ;
224
225
}
@@ -239,8 +240,8 @@ - (void)runFailingTransactionWithError:(FIRFirestoreErrorCode)expected {
239
240
[_testCase expectationWithDescription: @" runFailingTransactionWithError" ];
240
241
[_db
241
242
runTransactionWithBlock: ^id _Nullable (FIRTransaction *transaction, NSError **) {
242
- for (TransactionStage stage in self-> _stages ) {
243
- stage (transaction, self-> _docRef );
243
+ for (TransactionStage stage in self. stages ) {
244
+ stage (transaction, self. docRef );
244
245
}
245
246
return @YES ;
246
247
}
@@ -256,14 +257,14 @@ - (void)runFailingTransactionWithError:(FIRFirestoreErrorCode)expected {
256
257
}
257
258
258
259
- (void )cleanupTester {
259
- _stages = [NSArray array ];
260
+ self. stages = [NSArray array ];
260
261
// Set the docRef to something else to lose the original reference.
261
- _docRef = [[self ->_db collectionWithPath: @" reset" ] documentWithAutoID ];
262
+ self. docRef = [[self ->_db collectionWithPath: @" reset" ] documentWithAutoID ];
262
263
}
263
264
264
265
- (NSString *)stageNames {
265
266
NSMutableArray <NSString *> *seqList = [NSMutableArray array ];
266
- for (TransactionStage stage in _stages ) {
267
+ for (TransactionStage stage in self. stages ) {
267
268
if (stage == delete1) {
268
269
[seqList addObject: @" delete" ];
269
270
} else if (stage == update1 || stage == update2) {
0 commit comments