Esempio n. 1
0
        public void Create_RequesterThrows_WorkerSuppresses()
        {
            // Arrange
            var fixture          = new Fixture();
            var expectedFeedback = new SentryUserFeedback();
            var expectedDsn      = new Dsn(TestHelper.DsnUri);

            var requesterMock = Substitute.For <IRequester>();

            requesterMock
            .When(e => e.RequestAsync())
            .Do(_ => throw new Exception("Sending to sentry failed."));

            fixture.Queue = new ConcurrentQueue <IRequester>();
            fixture.RequesterFactory.Create(expectedFeedback, expectedDsn).Returns(requesterMock);

            var factory = fixture.GetSut();

            // Act
            var requester = factory.Create(expectedFeedback, expectedDsn);

            requester.Request();

            factory.Dispose();

            // Assert
            requesterMock.Received(1).RequestAsync();
            Assert.That(factory.QueueConsumer.Status, Is.EqualTo(TaskStatus.RanToCompletion));
        }
Esempio n. 2
0
        public void Create_RequesterInvoked()
        {
            // Arrange
            var fixture          = new Fixture();
            var expectedFeedback = new SentryUserFeedback();
            var expectedDsn      = new Dsn(TestHelper.DsnUri);

            var actualId      = "not set";
            var requesterMock = Substitute.For <IRequester>();

            requesterMock
            .When(r => r.UseEventId(Arg.Any <string>()))
            .Do(info => actualId = info.Arg <string>());

            fixture.Queue = new ConcurrentQueue <IRequester>();
            fixture.RequesterFactory.Create(expectedFeedback, expectedDsn).Returns(requesterMock);

            var factory = fixture.GetSut();

            // Act
            var requester = factory.Create(expectedFeedback, expectedDsn);
            var id        = requester.Request();

            factory.Dispose();

            // Assert
            requesterMock.Received(1).RequestAsync();
            Assert.That(id, Is.EqualTo(actualId));
            Assert.That(factory.QueueConsumer.Status, Is.EqualTo(TaskStatus.RanToCompletion));
        }
Esempio n. 3
0
        public static Task SendUserFeedback(string comments)
        {
            var feedback = new SentryUserFeedback
            {
                Comments = comments,
                Name     = "Anonymous User",
                Email    = "*****@*****.**"
            };

            return(RavenClient.SendUserFeedbackAsync(feedback));
        }
Esempio n. 4
0
        /// <summary>Sends the specified user feedback to Sentry</summary>
        /// <returns>An empty string if succesful, otherwise the server response</returns>
        /// <param name="feedback">The user feedback to send</param>
        public string SendUserFeedback(SentryUserFeedback feedback)
        {
            IRequester requester = null;

            try
            {
                requester = CreateRequester(feedback);

                if (BeforeSend != null)
                {
                    requester = BeforeSend(requester);
                }

                return(requester.SendFeedback());
            }
            catch (Exception exception)
            {
                return(HandleException(exception, requester));
            }
        }
        /// <summary>Sends the specified user feedback to Sentry</summary>
        /// <returns>An empty string if succesful, otherwise the server response</returns>
        /// <param name="feedback">The user feedback to send</param>
        public async Task <string> SendUserFeedbackAsync(SentryUserFeedback feedback)
        {
            Requester requester = null;

            try
            {
                requester = new Requester(feedback, this);

                if (BeforeSend != null)
                {
                    requester = BeforeSend(requester);
                }

                return(await requester.SendFeedbackAsync());
            }
            catch (Exception exception)
            {
                return(HandleException(exception, requester));
            }
        }
Esempio n. 6
0
 protected virtual IRequester CreateRequester(SentryUserFeedback feedback)
 {
     return(this.requesterFactory.Create(feedback, CurrentDsn));
 }
 /// <summary>Sends the specified user feedback to Sentry</summary>
 /// <returns>An empty string if succesful, otherwise the server response</returns>
 /// <param name="feedback">The user feedback to send</param>
 public async Task <string> SendUserFeedbackAsync(SentryUserFeedback feedback)
 {
     return(await Task.FromResult(string.Empty));
 }
Esempio n. 8
0
 /// <summary>Sends the specified user feedback to Sentry</summary>
 /// <returns>An empty string if succesful, otherwise the server response</returns>
 /// <param name="feedback">The user feedback to send</param>
 public string SendUserFeedback(SentryUserFeedback feedback)
 {
     return(string.Empty);
 }