public void Plugin_registration_helper_should_accept_custom_ILogger_parameter() { var context = new XrmFakedContext(); var orgService = context.GetOrganizationService(); context.Initialize(new List <Entity>() { UpdateSdkMessage, CreateSdkMessage, UpdateContactMessageFilter, UpdateAccountMessageFilter, CreateContactMessageFilter }); var logger = new StubLogger(); var pluginWrapper = new PluginWrapper(); pluginWrapper.RegisterPlugins(SampleFullPluginManifest, orgService, logger); var postRegisteredAssemblies = (from a in context.CreateQuery <PluginAssembly>() where a.Name == "SamplePluginAssembly" select a).ToList(); // Stub logger only stores the last call logger.ResponseMessage.Should().Be("Exiting PluginWrapper.RegisterPlugins"); logger.ResponseLogLevel.Should().Be(LogLevel.Debug); postRegisteredAssemblies.Should().HaveCount(1); }
internal ActionsManagerFixture WithValidLogger() { this._logger = new StubLogger(); var shimLogger = new ShimLogger(this._logger); shimLogger.LogRegisterActionBoardAction = (action) => { }; return(this); }
public void TestCritical() { var loggerStub = new StubLogger(); var t = new TracingHelper(loggerStub); t.Critical(_logMessage); Assert.AreEqual(_logMessage, loggerStub.ResponseMessage); Assert.AreEqual(LogLevel.Critical, loggerStub.ResponseLogLevel); }
public void TestLog(LogLevel logLevel) { var loggerStub = new StubLogger(); var t = new TracingHelper(loggerStub); t.Log(logLevel, _logMessage); Assert.AreEqual(_logMessage, loggerStub.ResponseMessage); Assert.AreEqual(logLevel, loggerStub.ResponseLogLevel); }
public void TestInfo() { var loggerStub = new StubLogger(); var t = new TracingHelper(loggerStub); t.Info(_logMessage); Assert.AreEqual(_logMessage, loggerStub.ResponseMessage); Assert.AreEqual(LogLevel.Information, loggerStub.ResponseLogLevel); }
public void IsValidFileName_ShouldThrowArgumentNullException_WhenNameIsNull() { //Arrange IExtensionManager extensionManager = new StubExtensionManager(); ILogger logger = new StubLogger(); var logAnalyzer = new LogAnalyzer(extensionManager, logger); //Act + Assert logAnalyzer.IsValidFileName(null); }
public static StubLogger GetLogger() { lock (_lock) { if (_stubLogger == null) { _stubLogger = new StubLogger(); } } return(_stubLogger); }
public BotsAirstripServiceTest() { dbContext = InMemoryDatabaseFactory.Create(); var logger = new StubLogger(); var accessCheckService = new AccessCheckService(dbContext); var monitorNegotiatorService = new MonitorNegotiatorService(); var forestNegotiatorService = new DichStubForestNegotiatorService(dbContext); botsAirstripService = new BotsAirstripService(logger, accessCheckService, monitorNegotiatorService, forestNegotiatorService, dbContext); }
public async Task CheckQueryReturnsAsIQueryable() { // Arrange ILogger log = new StubLogger(); // Act IQueryable query = await _storageProvider.Query(); // Assert Assert.IsAssignableFrom <IQueryable>(query); }
public async Task CreateAsyncWithNullObjectThrowsArgumentNullException() { // Arrange // Use existing records from constructor ILogger log = new StubLogger(); // Act Exception exception = await Record.ExceptionAsync(() => _storageProvider.CreateAsync(null)); //Assert Assert.IsType <System.NullReferenceException>(exception); }
public void setup_before_each_test() { _baseAddress = new Uri("http://localhost:8080"); _request = new HttpRequestMessage(HttpMethod.Get, "/ping"); _response = new HttpResponseMessage(HttpStatusCode.Accepted) { RequestMessage = _request }; _logger = new StubLogger <JsonLoggingHttpClientEventCallback>(); _testSubject = new JsonLoggingHttpClientEventCallback(_logger); }
public void setup_once_before_all_tests() { _logger = new StubLogger <LoggingMetricSink>(); var loggingMetricSink = new LoggingMetricSink(_logger); var metric = new Counter { Name = "foo" }; loggingMetricSink.Push(metric); }
public void IsValidFileName_ShouldBeValid_WhenNameStartsWithProperPrefix() { //Arrange IExtensionManager extensionManager = new StubExtensionManager(); ILogger logger = new StubLogger(); var logAnalyzer = new LogAnalyzer(extensionManager, logger); //Act var result = logAnalyzer.IsValidFileName("Log_LGO.json"); //Assert result.Should().BeTrue("The file name must always starts with the prefix Log_"); }
public void setup_once_before_all_tests() { _logger = new StubLogger <LoggingMetricSink>(); var loggingMetricSink = new LoggingMetricSink(_logger); var metric = new Counter { Name = "foo", Dimensions = new Dictionary <string, object> { { "a", 1 }, { "b", 2 } } }; loggingMetricSink.Push(metric); }
public async Task ExecuteAsync_NullResult_LogsNull() { // Arrange var expected = "Executing JsonResult, writing value of type 'null'."; var context = GetActionContext(); var logger = new StubLogger(); var executer = CreateExecutor(logger); var result = new JsonResult(null); // Act await executer.ExecuteAsync(context, result); // Assert Assert.Equal(expected, logger.MostRecentMessage); }
public async Task CannotCreateAsyncForValuesWithExistingKey() { // Arrange ILogger log = new StubLogger(); // Act Exception _insert = await Record.ExceptionAsync(() => _storageProvider.CreateAsync(new TestObject { Id = "2", InnerObject = "hello" })); // Assert Assert.IsAssignableFrom <Exception>(_insert); }
public override void Init() { base.Init(); _lockFileManager = _container.Resolve <ILockFileManager>(); _provider = _container.Resolve <IIndexProvider>(); _indexTaskExecutor = _container.Resolve <IIndexingTaskExecutor>(); _contentManager = _container.Resolve <IContentManager>(); ((IndexingTaskExecutor)_indexTaskExecutor).Logger = _logger = new StubLogger(); var thingType = new ContentTypeDefinitionBuilder() .Named(ThingDriver.ContentTypeName) .WithSetting("TypeIndexing.Indexes", "Search") .Build(); _contentDefinitionManager .Setup(x => x.GetTypeDefinition(ThingDriver.ContentTypeName)) .Returns(thingType); }
public void setup_before_each_test() { IHeaderDictionary headers = new HeaderDictionary(new Dictionary <string, StringValues> { { "User-Agent", new StringValues("my-user-agent") } }); var httpRequest = new StubHttpRequest(headers) { Method = "GET", Path = "/ping", QueryString = new QueryString("?v=1") }; var httpResponse = new StubHttpResponse { StatusCode = 23 }; _httpContext = new StubHttpContext(httpRequest, httpResponse); _logger = new StubLogger <JsonLoggingHttpServerEventCallback>(); _testSubject = new JsonLoggingHttpServerEventCallback(_logger); }
public async Task CanCreateAsyncWithValidData() { // Arrange ILogger log = new StubLogger(); // Act await _storageProvider.CreateAsync(new TestObject { Id = "3", InnerObject = "hello" }); // Assert IQueryable <TestObject> query = await _storageProvider.Query(); Assert.Equal(3, query.Select(e => e.Id).ToList <String>().Count); }
public async Task CannotCreateAsyncForValuesWithMissingInnerObject() { // Arrange ILogger log = new StubLogger(); // Act var exception = await Record.ExceptionAsync(() => _storageProvider.CreateAsync(new TestObject() { Id = "3" })); // Assert Assert.IsType <Exception>(exception); Assert.Equal("There was at least one validation error. Please provide the appropriate information.", exception.Message); IQueryable <TestObject> query = await _storageProvider.Query(); Assert.Equal(2, query.Count()); }
public async Task UpsertAsyncFailsToUpdateObjectWithExistingKeyAndMissingInnerObject(string reference) { // Arrange // Use existing records from constructor ILogger log = new StubLogger(); TestObject _object = new TestObject() { Id = reference }; // Act var exception = await Record.ExceptionAsync(() => _storageProvider.UpsertAsync(_object)); // Assert Assert.IsType <Exception>(exception); Assert.Equal("There was at least one validation error. Please provide the appropriate information.", exception.Message); IQueryable <TestObject> query = await _storageProvider.Query(); Assert.Equal(2, query.Count()); }
public async Task CanCreateAsyncWithValidData() { // Arrange ILogger log = new StubLogger(); // Act await _storageProvider.CreateAsync(new PartitionedTestObject { Id = "3", Partition = "partition", InnerObject = "hello", Doctype = "show" }); // Assert IQueryable <PartitionedTestObject> query = await _storageProvider.Query(); Assert.Equal(3, query.Where(doc => doc.Partition == "partition").Select(e => e.Id).ToList <String>().Count); }
public async Task UpsertAsyncUpdatesObjectWithExistingKey(string reference) { // Arrange // Use existing records from constructor ILogger log = new StubLogger(); TestObject _object = new TestObject() { Id = reference, InnerObject = "myNewString" }; // Act await _storageProvider.UpsertAsync(_object); // Assert IQueryable <TestObject> query = (IQueryable <TestObject>) await _storageProvider.Query(); Assert.Equal(2, query.Count()); Assert.Single(query.Where(e => e.InnerObject == "myNewString")); Assert.Equal(reference, query.Where(e => e.InnerObject == "myNewString").Take(1).ToList().First().Id); }
public async Task CannotCreateAsyncForValuesWithMissingId() { // Arrange ILogger log = new StubLogger(); // Act var exception = await Record.ExceptionAsync(() => _storageProvider.CreateAsync(new PartitionedTestObject { Partition = "partition", Doctype = "show", InnerObject = "hello" })); // Assert Assert.IsType <Exception>(exception); Assert.Equal("There was at least one validation error. Please provide the appropriate information.", exception.Message); IQueryable <PartitionedTestObject> query = await _storageProvider.Query(); Assert.Equal(2, query.Where(doc => doc.Partition == "partition").Count()); }
public async Task WhenEventTypesExist_ExpectedEventTypesAreReturned() { var ExpectedOwner = "ExpectedOwner"; var ExpectedRepositoryName = "ExpectedRepositoryName"; var mockLogger = new StubLogger(); var expectedSearchCodeRequest = new SearchCodeRequest("EventType", ExpectedOwner, ExpectedRepositoryName) { In = new[] { CodeInQualifier.Path }, Extension = "json" }; var expectedPathToEventTypeDictionary = new Dictionary <string, EventType> { { "firstExpectedPath", new EventType() { Id = 11, Name = "firstExpectedEventType" } }, { "secondExpectedPath", new EventType() { Id = 12, Name = "secondExpectedEventType" } } }; var mockConfig = MockGithubConfigFactory.Create( expectedSearchCodeRequest, expectedPathToEventTypeDictionary, 1, ExpectedRepositoryName, ExpectedOwner ); var resultObject = new Dictionary <long, EventType>(); await resultObject .AddSeedDataFromGitHub(mockLogger, mockConfig, "EventType") .ConfigureAwait(continueOnCapturedContext: false); Assert.IsTrue(resultObject.TryGetValue(11, out var eventTypeFromLoadedDictionary)); Assert.AreEqual("firstExpectedEventType", eventTypeFromLoadedDictionary.Name); }
public async Task UpsertAsyncCannotCreateNewObjectWithNewKeyAndMissingDoctype(string reference) { // Arrange // Use existing records from constructor ILogger log = new StubLogger(); PartitionedTestObject _object = new PartitionedTestObject() { Id = reference, Partition = "partition", InnerObject = "myNewString" }; // Act var exception = await Record.ExceptionAsync(() => _storageProvider.UpsertAsync(_object)); // Assert Assert.IsType <Exception>(exception); Assert.Equal("There was at least one validation error. Please provide the appropriate information.", exception.Message); IQueryable <PartitionedTestObject> query = await _storageProvider.Query(); Assert.Equal(2, query.Where(doc => doc.Partition == "partition").Count()); }
public async Task UpdateAsyncSucceedsWithValidKeyAndData(string reference) { // Arrange // Use existing records from constructor ILogger log = new StubLogger(); TestObject _object = new TestObject() { Id = reference, InnerObject = "myNewString" }; // Act var update = await _storageProvider.UpdateAsync(_object); // Assert IQueryable <TestObject> query = (IQueryable <TestObject>) await _storageProvider.Query(); Assert.True(update); Assert.Equal(2, query.Count()); Assert.Equal("myNewString", query.Where(e => e.Id == reference).Take(1).ToList().First().InnerObject); Assert.Single(query.Where(e => e.InnerObject == "myNewString")); }
public async Task UpsertAsyncCreatesNewObjectWithNewKeyAndValidData(string reference) { // Arrange // Use existing records from constructor ILogger log = new StubLogger(); PartitionedTestObject _object = new PartitionedTestObject() { Id = reference, Partition = "partition", InnerObject = "myNewString", Doctype = "show" }; // Act await _storageProvider.UpsertAsync(_object); // Assert IQueryable <PartitionedTestObject> query = await _storageProvider.Query() as IQueryable <PartitionedTestObject>; Assert.Equal(3, query.Where(e => e.Partition == "partition").Count()); Assert.Single(query.Where(e => e.InnerObject == "myNewString" && e.Partition == "partition")); Assert.Equal(reference, query.Where(e => e.InnerObject == "myNewString" && e.Partition == "partition").Take(1).ToList().First().Id); }
public async Task PersistAsync_WhenCalledWithMultiEventSinksAndOneThrowsAnException_WillRaiseToAllEventSinks() { // Arrange var sink1 = new StubSink(); var sink2 = new StubSink(); var sink3 = new StubSinkThrowsException(); var logger = new StubLogger(); var sut = new EventSinkAggregator(logger); sut.EventSinks.Add(sink1); sut.EventSinks.Add(sink2); sut.EventSinks.Add(sink3); // Act await sut.PersistAsync(new StubEvent()); // Assert Assert.Equal(1, sink1.WasCalled); Assert.Equal(1, sink2.WasCalled); Assert.Equal(1, sink3.WasCalled); Assert.Equal(1, logger.TimesErrored); }
private void RegisterLocalServices() { ServiceContainer.Register <INativeLogService>("nativeLogService", new AndroidLogService()); #if FDROID var logger = new StubLogger(); #elif DEBUG var logger = DebugLogger.Instance; #else var logger = Logger.Instance; #endif ServiceContainer.Register("logger", logger); // Note: This might cause a race condition. Investigate more. Task.Run(() => { FFImageLoading.Forms.Platform.CachedImageRenderer.Init(true); FFImageLoading.ImageService.Instance.Initialize(new FFImageLoading.Config.Configuration { FadeAnimationEnabled = false, FadeAnimationForCachedImages = false, HttpClient = new HttpClient(new AndroidClientHandler() { AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate }) }); ZXing.Net.Mobile.Forms.Android.Platform.Init(); }); CrossFingerprint.SetCurrentActivityResolver(() => CrossCurrentActivity.Current.Activity); var preferencesStorage = new PreferencesStorageService(null); var documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); var liteDbStorage = new LiteDbStorageService(Path.Combine(documentsPath, "bitwarden.db")); var localizeService = new LocalizeService(); var broadcasterService = new BroadcasterService(logger); var messagingService = new MobileBroadcasterMessagingService(broadcasterService); var i18nService = new MobileI18nService(localizeService.GetCurrentCultureInfo()); var secureStorageService = new SecureStorageService(); var cryptoPrimitiveService = new CryptoPrimitiveService(); var mobileStorageService = new MobileStorageService(preferencesStorage, liteDbStorage); var stateService = new StateService(mobileStorageService, secureStorageService, messagingService); var stateMigrationService = new StateMigrationService(liteDbStorage, preferencesStorage, secureStorageService); var clipboardService = new ClipboardService(stateService); var deviceActionService = new DeviceActionService(clipboardService, stateService, messagingService, broadcasterService, () => ServiceContainer.Resolve <IEventService>("eventService")); var platformUtilsService = new MobilePlatformUtilsService(deviceActionService, clipboardService, messagingService, broadcasterService); var biometricService = new BiometricService(); var cryptoFunctionService = new PclCryptoFunctionService(cryptoPrimitiveService); var cryptoService = new CryptoService(stateService, cryptoFunctionService); var passwordRepromptService = new MobilePasswordRepromptService(platformUtilsService, cryptoService); ServiceContainer.Register <IBroadcasterService>("broadcasterService", broadcasterService); ServiceContainer.Register <IMessagingService>("messagingService", messagingService); ServiceContainer.Register <ILocalizeService>("localizeService", localizeService); ServiceContainer.Register <II18nService>("i18nService", i18nService); ServiceContainer.Register <ICryptoPrimitiveService>("cryptoPrimitiveService", cryptoPrimitiveService); ServiceContainer.Register <IStorageService>("storageService", mobileStorageService); ServiceContainer.Register <IStorageService>("secureStorageService", secureStorageService); ServiceContainer.Register <IStateService>("stateService", stateService); ServiceContainer.Register <IStateMigrationService>("stateMigrationService", stateMigrationService); ServiceContainer.Register <IClipboardService>("clipboardService", clipboardService); ServiceContainer.Register <IDeviceActionService>("deviceActionService", deviceActionService); ServiceContainer.Register <IPlatformUtilsService>("platformUtilsService", platformUtilsService); ServiceContainer.Register <IBiometricService>("biometricService", biometricService); ServiceContainer.Register <ICryptoFunctionService>("cryptoFunctionService", cryptoFunctionService); ServiceContainer.Register <ICryptoService>("cryptoService", cryptoService); ServiceContainer.Register <IPasswordRepromptService>("passwordRepromptService", passwordRepromptService); ServiceContainer.Register <IAvatarImageSourcePool>("avatarImageSourcePool", new AvatarImageSourcePool()); // Push #if FDROID ServiceContainer.Register <IPushNotificationListenerService>( "pushNotificationListenerService", new NoopPushNotificationListenerService()); ServiceContainer.Register <IPushNotificationService>( "pushNotificationService", new NoopPushNotificationService()); #else var notificationListenerService = new PushNotificationListenerService(); ServiceContainer.Register <IPushNotificationListenerService>( "pushNotificationListenerService", notificationListenerService); var androidPushNotificationService = new AndroidPushNotificationService( stateService, notificationListenerService); ServiceContainer.Register <IPushNotificationService>( "pushNotificationService", androidPushNotificationService); #endif }