예제 #1
0
        public void ValidateDsn_Empty_CreatesNoError()
        {
            LogAssert.ignoreFailingMessages = true; // mandatory

            // arrange
            var validationErrors = new List <ValidationError>();

            // act

            // Do the 'act' phase inside 'using', not outside. There is no window 'outside'.
            using (var window = SentryTestWindow.Open())
            {
                window.OnValidationError += error => validationErrors.Add(error);
                window.Options.Dsn        = "";
            }

            // assert
            Assert.AreEqual(0, validationErrors.Count);
        }
예제 #2
0
        public void ValidateDsn_WrongFormat_CreatesError()
        {
            LogAssert.ignoreFailingMessages = true; // mandatory

            // arrange
            var validationErrors = new List <ValidationError>();

            // act

            // Do the 'act' phase inside 'using', not outside. There is no window 'outside'.
            using (var window = SentryTestWindow.Open())
            {
                window.OnValidationError += error => validationErrors.Add(error);
                window.Options.Dsn        = "qwerty";
            }

            // assert
            Assert.GreaterOrEqual(validationErrors.Count, 1, "Expected at least 1 error");
            Assert.NotNull(validationErrors.FirstOrDefault(e => e.PropertyName.Contains(nameof(SentryTestWindow.Options.Dsn))));
        }
예제 #3
0
        public void ValidateDsn_CorrectFormat_CreatesNoError()
        {
            LogAssert.ignoreFailingMessages = true; // mandatory

            // arrange
            var validationErrors = new List <ValidationError>();

            // act

            // Do the 'act' phase inside 'using', not outside. There is no window 'outside'.
            using (var window = SentryTestWindow.Open())
            {
                window.OnValidationError += error => validationErrors.Add(error);

                Uri.TryCreate("https://sentryTest.io", UriKind.Absolute, out Uri testUri);
                window.Options.Dsn = testUri.ToString();
            }

            // assert
            Assert.AreEqual(0, validationErrors.Count);
        }