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); } }
public void ToStringBlackTest() { RgbColor color = new RgbColor(255, 255, 255); string result = color.ToString(); Assert.AreEqual("FFFFFF", result); }
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); }
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); }
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); } }
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); }
/// <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); } }
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); }
/// <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; }
public void ToStringBlueTest() { RgbColor color = new RgbColor(0, 0, 255); string result = color.ToString(); Assert.AreEqual("0000FF", result); }
public void ToStringWhiteTest() { RgbColor color = new RgbColor(0, 0, 0); string result = color.ToString(); Assert.AreEqual("000000", result); }
public void ToStringRedTest() { RgbColor color = new RgbColor(255, 0, 0); string result = color.ToString(); Assert.AreEqual("FF0000", result); }
public void ToStringGreenTest() { RgbColor color = new RgbColor(0, 255, 0); string result = color.ToString(); Assert.AreEqual("00FF00", result); }