// Test public async Task Register_FormsNotInitialized_HooksNotInvoked() { //Assert var mockDiagnostic = new MockDiagnosticLogger(SentryLevel.Debug); var options = new SentryXamarinOptions() { Debug = true, DiagnosticLogger = mockDiagnostic, GetCurrentApplicationDelay = 1, GetCurrentApplicationMaxRetries = 1 }; var integration = new FormsApplicationListener(options); var mockHub = new MockHub(); Action <Application> badListener = (_) => throw null; integration.AddListener(badListener); //Act integration.Invoke(); await Task.Delay(options.GetCurrentApplicationDelay + 100); //Assert Assert.True(mockDiagnostic.Contains("Sentry.Xamarin.Forms timeout for tracking Application.Current. Navigation tracking is going to be disabled")); }
public void Test_AuthenticationSuccess() { // Arrange MockHub hub = new MockHub { Context = GetHubCallerContext(true) }; AuthorizeAttribute attr = new AuthorizeAttribute(); // Assert Assert.IsTrue(attr.AuthorizeHubMethodInvocation(new MockHubInvoker() { Hub = hub }, false)); }
public void Test_AuthenticationFail() { // Arrange AuthorizeAttribute attr = new AuthorizeAttribute(); MockHub hub = new MockHub { Context = GetHubCallerContext(false) }; // Assert Assert.IsFalse(attr.AuthorizeHubConnection(new HubDescriptor(), hub.Context.Request)); Assert.IsFalse(attr.AuthorizeHubMethodInvocation(new MockHubInvoker() { Hub = hub }, false)); }
public void Handle_RegisterUnhandleException() { //Arrange var integration = new NativeIntegration(new SentryXamarinOptions()); var hub = new MockHub(); integration.Register(hub, new SentryOptions()); //Act try { integration.Handle(new Exception()); } finally { integration.Unregister(); } //Assert Assert.Equal(1, hub.CaptureEventCount); Assert.Equal(1, hub.FlushAsyncCount); }