Implementation of the Feedback service
Inheritance: IFeedbackService
        public void GetFeedbackAsBuyerByNameApiKeyInvalidTest()
        {
            // ARRANGE
            using (AutoResetEvent waitEvent = new AutoResetEvent(false))
            {
                ResultEventArgs<Feedbacks> result = null;
                IFeedbackService feedbackService = new FeedbackService(new EtsyContext("InvalidKey"));
                feedbackService.GetFeedbackAsBuyerCompleted += (s, e) =>
                {
                    result = e;
                    waitEvent.Set();
                };

                // ACT
                feedbackService.GetFeedbackAsBuyer(NetsyData.TestUserName, 0, 10);
                bool signalled = waitEvent.WaitOne(NetsyData.WaitTimeout);

                // ASSERT
                // check that the event was fired, did not time out
                Assert.IsTrue(signalled, "Not signalled");

                // check the data - should fail
                Assert.IsNotNull(result);
                Assert.IsNotNull(result.ResultStatus);
                Assert.IsFalse(result.ResultStatus.Success);
                Assert.AreEqual(WebExceptionStatus.ProtocolError, result.ResultStatus.WebStatus);
            }
        }
        public void GetFeedbackTest()
        {
            EtsyContext etsyContext = new EtsyContext(Constants.DummyEtsyApiKey);
            MockFixedDataRequestGenerator requestGenerator = new MockFixedDataRequestGenerator(GetFeedbackRawResults);
            DataRetriever dataRetriever = new DataRetriever(new NullDataCache(), requestGenerator);
            IFeedbackService etsyShopsService = new FeedbackService(etsyContext, dataRetriever);

            using (AutoResetEvent waitEvent = new AutoResetEvent(false))
            {
                ResultEventArgs<Feedbacks> result = null;
                etsyShopsService.GetFeedbackCompleted += (s, e) =>
                {
                    result = e;
                    waitEvent.Set();
                };

                // ACT
                etsyShopsService.GetFeedback(Constants.TestId);
                bool signalled = waitEvent.WaitOne(Constants.WaitTimeout);

                // ASSERT

                // check that the event was fired, did not time out
                Assert.IsTrue(signalled, "Not signalled");

                TestHelpers.CheckResultSuccess(result);
            }
        }
Example #3
0
        public void GetFeedbackGetTest()
        {
            // ARRANGE
            using (AutoResetEvent waitEvent = new AutoResetEvent(false))
            {
                ResultEventArgs<Feedbacks> result = null;
                IFeedbackService feedbackService = new FeedbackService(new EtsyContext(NetsyData.EtsyApiKey));
                feedbackService.GetFeedbackCompleted += (s, e) =>
                {
                    result = e;
                    waitEvent.Set();
                };

                // ACT
                feedbackService.GetFeedback(NetsyData.TestFeedbackId);
                bool signalled = waitEvent.WaitOne(NetsyData.WaitTimeout);

                // ASSERT
                // check that the event was fired, did not time out
                Assert.IsTrue(signalled, "Not signalled");

                TestHelpers.CheckResultSuccess(result);
                Assert.AreEqual(1, result.ResultValue.Count);
            }
        }
        public void CreateWithMockRequestTest()
        {
            EtsyContext etsyContext = new EtsyContext(string.Empty);
            IRequestGenerator requestGenerator = new MockFixedDataRequestGenerator(string.Empty);
            DataRetriever dataRetriever = new DataRetriever(new NullDataCache(), requestGenerator);
            IFeedbackService service = new FeedbackService(etsyContext, dataRetriever);

            Assert.IsNotNull(service);
        }
        public void GetFeedbackForOthersNegativeOffsetTest()
        {
            // ARRANGE
            IFeedbackService feedbackService = new FeedbackService(new EtsyContext(Constants.DummyEtsyApiKey));
            ResultEventArgs<Feedbacks> result = null;
            feedbackService.GetFeedbackForOthersCompleted += (s, e) => result = e;

            // ACT
            feedbackService.GetFeedbackForOthers(Constants.TestId, -1, 10);

            // check the data
            TestHelpers.CheckResultFailure(result, "Negative offset of -1");
        }
        public void GetFeedbackForOthersMissingApiKeyTest()
        {
            // ARRANGE
            IFeedbackService feedbackService = new FeedbackService(new EtsyContext(string.Empty));
            ResultEventArgs<Feedbacks> result = null;
            feedbackService.GetFeedbackForOthersCompleted += (s, e) => result = e;

            // ACT
            feedbackService.GetFeedbackForOthers(Constants.TestId, 0, 10);

            // check the data
            TestHelpers.CheckResultFailure(result, Constants.EmptyApiKeyErrorMessage);
        }
        public void GetFeedbackAsBuyerByNameGetTest()
        {
            // ARRANGE
            using (AutoResetEvent waitEvent = new AutoResetEvent(false))
            {
                ResultEventArgs<Feedbacks> result = null;
                IFeedbackService feedbackService = new FeedbackService(new EtsyContext(NetsyData.EtsyApiKey));
                feedbackService.GetFeedbackAsBuyerCompleted += (s, e) =>
                {
                    result = e;
                    waitEvent.Set();
                };

                // ACT
                feedbackService.GetFeedbackAsBuyer(NetsyData.TestUserName, 0, 10);
                bool signalled = waitEvent.WaitOne(NetsyData.WaitTimeout);

                // ASSERT
                // check that the event was fired, did not time out
                Assert.IsTrue(signalled, "Not signalled");

                // check the data - should suceed
                TestHelpers.CheckResultSuccess(result);
            }
        }
        public void GetFeedbackAsBuyerMissingApiKeyTest()
        {
            // ARRANGE
            ResultEventArgs<Feedbacks> result = null;
            IFeedbackService feedbackService = new FeedbackService(new EtsyContext(string.Empty));
            feedbackService.GetFeedbackAsBuyerCompleted += (s, e) => result = e;

            // ACT
            feedbackService.GetFeedbackAsBuyer(NetsyData.TestUserId, 0, 10);

            // check the data
            TestHelpers.CheckResultFailure(result);
        }
        public void GetFeedbackForOthersZeroLimitTest()
        {
            // ARRANGE
            IFeedbackService feedbackService = new FeedbackService(new EtsyContext(Constants.DummyEtsyApiKey));
            ResultEventArgs<Feedbacks> result = null;
            feedbackService.GetFeedbackForOthersCompleted += (s, e) => result = e;

            // ACT
            feedbackService.GetFeedbackForOthers(Constants.TestId, -0, 0);

            // check the data
            TestHelpers.CheckResultFailure(result, "Bad limit of 0");
        }