Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added instance method on unit test provider to clear events

  • Loading branch information...
commit d2c409639f87abe41e0973a4007fff923011f2a5 1 parent a3d708d
@thuss thuss authored
Showing with 17 additions and 6 deletions.
  1. +4 −1 AnalyticsKitUnitTestProvider.h
  2. +13 −5 AnalyticsKitUnitTestProvider.m
View
5 AnalyticsKitUnitTestProvider.h
@@ -7,6 +7,7 @@
//
#import <Foundation/Foundation.h>
+#import "AnalyticsKit.h"
#import "AnalyticsKitEvent.h"
@interface AnalyticsKitUnitTestProvider : NSObject<AnalyticsKitProvider>
@@ -14,9 +15,11 @@
@property(nonatomic,strong)NSMutableArray *events;
+ (AnalyticsKitUnitTestProvider *)setUp;
-+ (void)clearEvents; // also called by tearDown
+ (void)tearDown;
++ (AnalyticsKitUnitTestProvider *)unitTestProvider; // setup must be called first, returns the instance
++ (void)clearEvents; // also called by tearDown; does same thing as instance method
+- (void)clearEvents;
- (BOOL)hasEventLoggedWithName:(NSString *)eventName;
- (AnalyticsKitEvent *)firstEventLoggedWithName:(NSString *)eventName;
- (NSArray *)eventsLoggedWithName:(NSString *)eventName;
View
18 AnalyticsKitUnitTestProvider.m
@@ -17,14 +17,18 @@ + (AnalyticsKitUnitTestProvider *)setUp {
return provider;
}
-+ (void)clearEvents {
- // Remove the events stored in the unit test provider
++ (AnalyticsKitUnitTestProvider *)unitTestProvider {
+ AnalyticsKitUnitTestProvider *unitProvider = nil;
NSArray *loggers = [AnalyticsKit loggers];
for (AnalyticsKitUnitTestProvider *provider in loggers) {
- if ([provider isKindOfClass:[AnalyticsKitUnitTestProvider class]]) {
- provider.events = nil;
- }
+ if ([provider isKindOfClass:[AnalyticsKitUnitTestProvider class]]) unitProvider = provider;
}
+ return unitProvider;
+}
+
++ (void)clearEvents {
+ // Remove the events stored in the unit test provider
+ [[self unitTestProvider] clearEvents];
}
+ (void)tearDown {
@@ -33,6 +37,10 @@ + (void)tearDown {
[AnalyticsKit initialize];
}
+- (void)clearEvents {
+ [self setEvents:[NSMutableArray arrayWithCapacity:20]];
+}
+
- (BOOL)hasEventLoggedWithName:(NSString *)eventName {
return [self firstEventLoggedWithName:eventName] != nil;
}
Please sign in to comment.
Something went wrong with that request. Please try again.