Пример #1
0
            public async Task DoesntAuthenticeWithoutPermission()
            {
                var coreSettings = new CoreSettings { EnableAutomaticReports = false };

                var client = new AnalyticsClient(Substitute.For<IAnalyticsEndpoint>());
                await client.InitializeAsync(coreSettings);

                Assert.False(client.IsAuthenticated);
            }
            public void InitializesEndpoint()
            {
                var coreSettings = new CoreSettings { EnableAutomaticReports = true };
                var endpoint = Substitute.For<IAnalyticsEndpoint>();
                var client = new AnalyticsClient(endpoint);

                client.Initialize(coreSettings);

                endpoint.Received().Initialize();
            }
Пример #3
0
            public async Task RecordDeviceInformation()
            {
                var coreSettings = new CoreSettings { EnableAutomaticReports = true, AnalyticsToken = null };

                var endpoint = Substitute.For<IAnalyticsEndpoint>();
                var client = new AnalyticsClient(endpoint);

                await client.InitializeAsync(coreSettings);

                endpoint.Received().RecordDeviceInformationAsync();
            }
Пример #4
0
            public async Task DoesntCreateUserIfAnalyticsTokenIsSaved()
            {
                var coreSettings = new CoreSettings { EnableAutomaticReports = true, AnalyticsToken = "cooltoken", BuddyAnalyticsUpgraded = true };

                var endpoint = Substitute.For<IAnalyticsEndpoint>();
                var client = new AnalyticsClient(endpoint);

                await client.InitializeAsync(coreSettings);

                endpoint.DidNotReceive().CreateUserAsync();
            }
Пример #5
0
            public async Task CreatesUserIfAnalyticsTokenIsNull()
            {
                var coreSettings = new CoreSettings { EnableAutomaticReports = true, AnalyticsToken = null };

                var endpoint = Substitute.For<IAnalyticsEndpoint>();
                var client = new AnalyticsClient(endpoint);

                await client.InitializeAsync(coreSettings);

                endpoint.Received().CreateUserAsync();
            }
            public void SendsReport()
            {
                var coreSettings = new CoreSettings { EnableAutomaticReports = true };
                var endpoint = Substitute.For<IAnalyticsEndpoint>();
                var client = new AnalyticsClient(endpoint);
                client.Initialize(coreSettings);

                client.RecordNonFatalError(new Exception());

                endpoint.ReceivedWithAnyArgs().ReportNonFatalException(null);
            }
            public void UpdatesEmailIfSet()
            {
                var coreSettings = new CoreSettings { EnableAutomaticReports = true };
                var endpoint = Substitute.For<IAnalyticsEndpoint>();
                var client = new AnalyticsClient(endpoint);
                client.Initialize(coreSettings);

                client.RecordBugReport("blabla", "*****@*****.**");

                endpoint.Received().UpdateEmail("*****@*****.**");
            }
Пример #8
0
            public async Task RecreatesAnalyticsTokenIfNecessacry()
            {
                var coreSettings = new CoreSettings { EnableAutomaticReports = true, AnalyticsToken = "cooltoken", BuddyAnalyticsUpgraded = false };

                var endpoint = Substitute.For<IAnalyticsEndpoint>();
                var client = new AnalyticsClient(endpoint);

                await client.InitializeAsync(coreSettings);

                Assert.NotEqual("cooltoken", coreSettings.AnalyticsToken);
            }
Пример #9
0
            public async Task Authenticates()
            {
                var coreSettings = new CoreSettings { EnableAutomaticReports = true, AnalyticsToken = "cooltoken", BuddyAnalyticsUpgraded = true };

                var endpoint = Substitute.For<IAnalyticsEndpoint>();
                var client = new AnalyticsClient(endpoint);

                await client.InitializeAsync(coreSettings);

                Assert.True(client.IsAuthenticated);
                endpoint.Received().AuthenticateUserAsync(Arg.Any<string>());
            }
Пример #10
0
            public void IgnoresEmailIfNullOrEmpty()
            {
                var coreSettings = new CoreSettings { EnableAutomaticReports = true };
                var endpoint = Substitute.For<IAnalyticsEndpoint>();
                var client = new AnalyticsClient(endpoint);
                client.Initialize(coreSettings);

                client.RecordBugReport("blabla");

                endpoint.DidNotReceiveWithAnyArgs().UpdateEmail(Arg.Any<string>());

                client.RecordBugReport("blabla", String.Empty);

                endpoint.DidNotReceiveWithAnyArgs().UpdateEmail(Arg.Any<string>());

                client.RecordBugReport("blabla", "  ");

                endpoint.DidNotReceiveWithAnyArgs().UpdateEmail(null);
            }
Пример #11
0
            public async Task SendsReport()
            {
                var coreSettings = new CoreSettings { EnableAutomaticReports = true };
                var endpoint = Substitute.For<IAnalyticsEndpoint>();
                var client = new AnalyticsClient(endpoint);

                await client.InitializeAsync(coreSettings);

                await client.RecordErrorAsync(new Exception());

                endpoint.ReceivedWithAnyArgs().RecordErrorAsync(null);
            }
Пример #12
0
            public async Task RespectsDisabledReports()
            {
                var coreSettings = new CoreSettings { EnableAutomaticReports = false };
                var endpoint = Substitute.For<IAnalyticsEndpoint>();
                var client = new AnalyticsClient(endpoint);

                await client.InitializeAsync(coreSettings);

                await client.RecordErrorAsync(new Exception());

                Assert.False(client.IsAuthenticated);
                endpoint.DidNotReceiveWithAnyArgs().RecordErrorAsync(null, null);
            }
Пример #13
0
            public async Task UpdatesEmailIfSet()
            {
                var coreSettings = new CoreSettings { EnableAutomaticReports = true };
                var endpoint = Substitute.For<IAnalyticsEndpoint>();
                var client = new AnalyticsClient(endpoint);
                await client.InitializeAsync(coreSettings);

                await client.RecordBugReportAsync("blabla", "*****@*****.**");

                endpoint.Received().UpdateUserEmailAsync("*****@*****.**");
            }
Пример #14
0
            public async Task IgnoresEmailIfNullOrEmpty()
            {
                var coreSettings = new CoreSettings { EnableAutomaticReports = true };
                var endpoint = Substitute.For<IAnalyticsEndpoint>();
                var client = new AnalyticsClient(endpoint);
                await client.InitializeAsync(coreSettings);

                await client.RecordBugReportAsync("blabla");

                endpoint.DidNotReceiveWithAnyArgs().UpdateUserEmailAsync(null);

                await client.RecordBugReportAsync("blabla", String.Empty);

                endpoint.DidNotReceiveWithAnyArgs().UpdateUserEmailAsync(null);

                await client.RecordBugReportAsync("blabla", "  ");

                endpoint.DidNotReceiveWithAnyArgs().UpdateUserEmailAsync(null);
            }
Пример #15
0
            public async Task ForcesAuthentication()
            {
                var coreSettings = new CoreSettings { EnableAutomaticReports = false };
                var endpoint = Substitute.For<IAnalyticsEndpoint>();
                var client = new AnalyticsClient(endpoint);

                // This won't authenticate because automatic reports are disabled
                await client.InitializeAsync(coreSettings);

                // This will force an authentication even if automatic reports are disabled
                await client.RecordBugReportAsync("blabla");

                Assert.True(client.IsAuthenticated);
                endpoint.Received().RecordErrorAsync(Arg.Is<Exception>(x => x.Message == "blabla"), null);
            }
Пример #16
0
            public async Task StoresAnalyticsToken()
            {
                var coreSettings = new CoreSettings { EnableAutomaticReports = true, AnalyticsToken = null };

                var client = new AnalyticsClient(Substitute.For<IAnalyticsEndpoint>());

                await client.InitializeAsync(coreSettings);

                Assert.NotNull(coreSettings.AnalyticsToken);
            }
Пример #17
0
            public async Task ForcesAuthentication()
            {
                var coreSettings = new CoreSettings { EnableAutomaticReports = false };
                var endpoint = Substitute.For<IAnalyticsEndpoint>();
                var client = new AnalyticsClient(endpoint);

                // This won't authenticate because automatic reports are disabled
                await client.InitializeAsync(coreSettings);

                // This will force an authentication even if automatic reports are disabled
                await client.RecordCrashAsync(new Exception());

                Assert.True(client.IsAuthenticated);
                endpoint.ReceivedWithAnyArgs().RecordErrorAsync(null, null);
            }