A color value as RGB (red, green and blue)
Inheritance: EtsyColor
コード例 #1
0
        public void GetListingsByColorApiKeyInvalidTest()
        {
            // ARRANGE
            using (AutoResetEvent waitEvent = new AutoResetEvent(false))
            {
                ResultEventArgs<Listings> result = null;
                IListingsService listingsService = new ListingsService(new EtsyContext("InvalidKey"));
                listingsService.GetListingsByColorCompleted += (s, e) =>
                {
                    result = e;
                    waitEvent.Set();
                };

                RgbColor testColor = new RgbColor("76B3DF");

                // ACT
                listingsService.GetListingsByColor(testColor, 10, 0, 10, DetailLevel.Low);
                bool signalled = waitEvent.WaitOne(Constants.WaitTimeout);

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

                // check the data
                Assert.IsNotNull(result);

                // check the data - should fail
                Assert.IsNotNull(result);
                Assert.IsNotNull(result.ResultStatus);
                Assert.IsFalse(result.ResultStatus.Success);
                Assert.AreEqual(WebExceptionStatus.ProtocolError, result.ResultStatus.WebStatus);
            }
        }
コード例 #2
0
        public void ToStringBlackTest()
        {
            RgbColor color = new RgbColor(255, 255, 255);
            string result = color.ToString();

            Assert.AreEqual("FFFFFF", result);
        }
コード例 #3
0
 public void RGBColorStringCreateTest()
 {
     RgbColor color = new RgbColor("123456");
     Assert.IsNotNull(color);
     Assert.AreEqual(18, color.Red);
     Assert.AreEqual(52, color.Green);
     Assert.AreEqual(86, color.Blue);
 }
コード例 #4
0
 public void RgbColorNumericCreateTest()
 {
     RgbColor color = new RgbColor(34, 45, 67);
     Assert.IsNotNull(color);
     Assert.AreEqual(34, color.Red);
     Assert.AreEqual(45, color.Green);
     Assert.AreEqual(67, color.Blue);
 }
コード例 #5
0
        public void GetListingsByColorCallTest()
        {
            // ARRANGE
            using (AutoResetEvent waitEvent = new AutoResetEvent(false))
            {
                ResultEventArgs<Listings> result = null;
                IListingsService listingsService = new ListingsService(new EtsyContext(NetsyData.EtsyApiKey));
                listingsService.GetListingsByColorCompleted += (s, e) =>
                {
                    result = e;
                    waitEvent.Set();
                };

                RgbColor testColor = new RgbColor("76B3DF");

                // ACT
                listingsService.GetListingsByColor(testColor, 10, 0, 10, DetailLevel.Low);
                bool signalled = waitEvent.WaitOne(Constants.WaitTimeout);

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

                // check the data
                Assert.IsNotNull(result);
                TestHelpers.CheckResultSuccess(result);

                Assert.IsTrue(result.ResultValue.Count > 1, "No results retreived");
                Assert.AreEqual(10, result.ResultValue.Results.Length);
                Assert.IsNotNull(result.ResultValue.Params);
            }
        }
コード例 #6
0
        public void GetListingsByColorAndKeywordsApiKeyMissingTest()
        {
            // ARRANGE
            ResultEventArgs<Listings> result = null;
            IListingsService listingsService = new ListingsService(new EtsyContext(string.Empty));
            listingsService.GetListingsByColorAndKeywordsCompleted += (s, e) => result = e;

            RgbColor testColor = new RgbColor("76B3DF");

            // ACT
            listingsService.GetListingsByColorAndKeywords(TestKeywords(), testColor, DefaultWiggle, 0, 10, DetailLevel.Low);

            // check the data
            TestHelpers.CheckResultFailure(result);
        }
コード例 #7
0
        /// <summary>
        /// Test retrieving listing details at the given detail level
        /// </summary>
        /// <param name="detailLevel">the given detail level</param>
        private static void TestGetListings(DetailLevel detailLevel)
        {
            TestHelpers.WaitABit();

            // ARRANGE
            using (AutoResetEvent waitEvent = new AutoResetEvent(false))
            {
                ResultEventArgs<Listings> result = null;
                IListingsService listingsService = new ListingsService(new EtsyContext(NetsyData.EtsyApiKey));
                listingsService.GetListingsByColorAndKeywordsCompleted += (s, e) =>
                {
                    result = e;
                    waitEvent.Set();
                };

                RgbColor testColor = new RgbColor("76B3DF");

                // ACT
                listingsService.GetListingsByColorAndKeywords(TestKeywords(), testColor, DefaultWiggle, 0, 10, detailLevel);
                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
                Assert.IsNotNull(result);
                TestHelpers.CheckResultSuccess(result);

                Assert.IsTrue(result.ResultValue.Count > 0, "No listings found");
                Assert.IsNotNull(result.ResultValue.Params);
            }
        }
コード例 #8
0
        public void GetListingsByColorWiggleTooLargeTest()
        {
            // ARRANGE
            ResultEventArgs<Listings> result = null;
            IListingsService listingsService = new ListingsService(new EtsyContext(string.Empty));
            listingsService.GetListingsByColorCompleted += (s, e) => result = e;

            RgbColor testColor = new RgbColor("76B3DF");

            // ACT
            listingsService.GetListingsByColor(testColor, 100, 0, 10, DetailLevel.Low);

            // check the data
            TestHelpers.CheckResultFailure(result);
        }
コード例 #9
0
        /// <summary>
        /// Get the color data object
        /// </summary>
        /// <returns>the color data object</returns>
        private RgbColor ConvertColor()
        {
            RgbColor rgbColor = null;
            string trimedColor = string.Empty;
            if (! string.IsNullOrEmpty(this.ColorText))
            {
                trimedColor = this.ColorText.Trim();
            }

            if (!string.IsNullOrEmpty(trimedColor))
            {
                rgbColor = new RgbColor(trimedColor);
            }

            return rgbColor;
        }
コード例 #10
0
        public void ToStringBlueTest()
        {
            RgbColor color = new RgbColor(0, 0, 255);
            string result = color.ToString();

            Assert.AreEqual("0000FF", result);
        }
コード例 #11
0
        public void ToStringWhiteTest()
        {
            RgbColor color = new RgbColor(0, 0, 0);
            string result = color.ToString();

            Assert.AreEqual("000000", result);
        }
コード例 #12
0
        public void ToStringRedTest()
        {
            RgbColor color = new RgbColor(255, 0, 0);
            string result = color.ToString();

            Assert.AreEqual("FF0000", result);
        }
コード例 #13
0
        public void ToStringGreenTest()
        {
            RgbColor color = new RgbColor(0, 255, 0);
            string result = color.ToString();

            Assert.AreEqual("00FF00", result);
        }