Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions tests/unittests/obj-c/ODWLogConfigurationTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#import <XCTest/XCTest.h>
#import "ODWLogConfiguration.h"
#import "ODWLogConfiguration_private.h"
#include "LogManager.hpp"

using namespace Microsoft::Applications::Events;
Expand Down Expand Up @@ -61,4 +62,22 @@ - (void)testSetHost {
XCTAssertEqualObjects(config.host, @"testHost");
}

- (void)testConfigurationCopiesRemainIndependent {
ODWLogConfiguration *first = [ODWLogConfiguration getLogConfigurationCopy];
[first set:@"copyIsolation" withValue:@"first"];
[first setHost:@"firstHost"];

ODWLogConfiguration *second = [ODWLogConfiguration getLogConfigurationCopy];
[second set:@"copyIsolation" withValue:@"second"];
[second setHost:@"secondHost"];

XCTAssertEqualObjects([first valueForKey:@"copyIsolation"], @"first");
XCTAssertEqualObjects(first.host, @"firstHost");
XCTAssertEqualObjects([second valueForKey:@"copyIsolation"], @"second");
XCTAssertEqualObjects(second.host, @"secondHost");

ODWLogConfiguration *third = [ODWLogConfiguration getLogConfigurationCopy];
XCTAssertFalse([third getWrappedConfiguration]->HasConfig("copyIsolation"));
}

@end
9 changes: 6 additions & 3 deletions wrappers/obj-c/ODWLogConfiguration.mm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#import "ODWLogConfiguration_private.h"
#import "ODWLogger_private.h"
#import "LogManager.hpp"
#include <memory>

using namespace Microsoft::Applications::Events;

Expand Down Expand Up @@ -293,24 +294,26 @@ The minimum time (ms) between storage full notifications.
NSString *const ODWCFG_BOOL_SESSION_RESET_ENABLED = @"sessionResetEnabled";

@implementation ODWLogConfiguration
{
std::unique_ptr<ILogConfiguration> _wrappedConfiguration;
}
static bool _enableTrace;
static bool _enableConsoleLogging;
static bool _enableSessionReset;
static bool _surfaceCppExceptions;
ILogConfiguration* _wrappedConfiguration;

-(instancetype)initWithILogConfiguration:(ILogConfiguration*)config
{
self = [super init];
if(self) {
_wrappedConfiguration = config;
_wrappedConfiguration.reset(config);
}
return self;
}

-(nullable ILogConfiguration*)getWrappedConfiguration
{
return _wrappedConfiguration;
return _wrappedConfiguration.get();
}

+(nullable ODWLogConfiguration *)getLogConfigurationCopy
Expand Down
2 changes: 1 addition & 1 deletion wrappers/obj-c/ODWLogConfiguration_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ using namespace MAT;
@interface ODWLogConfiguration (Private)

/*!
@brief Constructs an ODWLogConfiguration object, taking internal API config pointer. This method might be only used internally by wrapper.
@brief Constructs an ODWLogConfiguration object, taking ownership of the internal API config pointer. This method might be only used internally by wrapper.
*/
-(instancetype)initWithILogConfiguration:(ILogConfiguration*)config;

Expand Down
Loading