Пример #1
0
        public void UploadCaptha(Stream streamImage)
        {
            var up = new Uploading();
              byte[] res;
              using (var stream = streamImage)
              {
            var files = new[]
                {
                    new UploadFile
                    {
                        Name = "file",
                        Filename = "captcha",
                        ContentType = "image/jpeg",
                        Stream = stream
                    }
                };

            var values = new NameValueCollection();
            values.Add("method", "post");
            values.Add("key", key);
            res = up.UploadFiles("http://antigate.com/in.php", files, values, "");
              }

              string resText = ByteArrayToString(res);
              indexCaptha = InfoPage.GetDatafromText(resText, "\\d+");
        }
Пример #2
0
        public void BuildAMultipleSelectPriceRangeFacetViewModelWithNoConstraintsApplied()
        {
            var results =
                SolrNetFacetTestFramework.RunSolrGetResults(
                    "<?xml version=\"1.0\" encoding=\"UTF-8\"?><response><lst name=\"responseHeader\"><int name=\"status\">0</int><int name=\"QTime\">1</int><lst name=\"params\"><str name=\"facet\">true</str><arr name=\"facet.query\"><str>{!label=*-99.99}unitprice:[* TO 99.99]</str><str>{!label=100-499.99}unitprice:[100 TO 499.99]</str></arr><str name=\"q\">*:*</str><str name=\"version\">2.2</str><str name=\"rows\">100000000</str></lst></lst><result name=\"response\" numFound=\"15\" start=\"0\"><doc><str name=\"id\">65547</str><str name=\"categoryid\">32772</str><float name=\"unitprice\">1699.99</float><str name=\"unitprice_c\">1699.9900,USD</str><str name=\"name\">19\" D450 HD LCD TV</str><str name=\"url\">home/electronics/televisions/19-d450-hd-lcd-tv</str><long name=\"_version_\">1435991846184550400</long></doc><doc><str name=\"id\">65545</str><str name=\"categoryid\">32772</str><float name=\"unitprice\">1399.99</float><str name=\"unitprice_c\">1399.9900,USD</str><str name=\"name\">32'' ES6800 Series 6 SMART 3D Full HD LED TV</str><str name=\"url\">home/electronics/televisions/32-es6800-series-6-smart-3d-full-hd-led-tv</str><long name=\"_version_\">1435991846228590592</long></doc><doc><str name=\"id\">65550</str><str name=\"categoryid\">32772</str><float name=\"unitprice\">1299.99</float><str name=\"unitprice_c\">1299.9900,USD</str><str name=\"name\">51\" E6500 Series 6 Smart Full HD LED TV</str><str name=\"url\">home/electronics/televisions/51-e6500-series-6-smart-full-hd-led-tv</str><long name=\"_version_\">1435991846231736320</long></doc><doc><str name=\"id\">65546</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">127.99</float><str name=\"unitprice_c\">127.9900,USD</str><str name=\"name\">Curvy Simplicity</str><str name=\"url\">home/electronics/phones/curvy-simplicity</str><long name=\"_version_\">1435991846235930624</long></doc><doc><str name=\"id\">65538</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">523.0</float><str name=\"unitprice_c\">523.0000,USD</str><str name=\"name\">Galaxy Note</str><str name=\"url\">home/electronics/phones/galaxy-note</str><long name=\"_version_\">1435991846240124928</long></doc><doc><str name=\"id\">65542</str><str name=\"categoryid\">32771</str><float name=\"unitprice\">250.0</float><str name=\"unitprice_c\">250.0000,USD</str><str name=\"name\">iPad</str><str name=\"url\">home/electronics/tablets/ipad</str><long name=\"_version_\">1435991846244319232</long></doc><doc><str name=\"id\">65543</str><str name=\"categoryid\">32771</str><float name=\"unitprice\">350.0</float><str name=\"unitprice_c\">350.0000,USD</str><str name=\"name\">iPad2</str><str name=\"url\">home/electronics/tablets/ipad2</str><long name=\"_version_\">1435991846248513536</long></doc><doc><str name=\"id\">65544</str><str name=\"categoryid\">32771</str><float name=\"unitprice\">500.0</float><str name=\"unitprice_c\">500.0000,USD</str><str name=\"name\">iPad3</str><str name=\"url\">home/electronics/tablets/ipad3</str><long name=\"_version_\">1435991846252707840</long></doc><doc><str name=\"id\">65536</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">100.0</float><str name=\"unitprice_c\">100.0000,USD</str><str name=\"name\">iPhone</str><str name=\"url\">home/electronics/phones/iphone</str><long name=\"_version_\">1435991846256902144</long></doc><doc><str name=\"id\">65537</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">200.0</float><str name=\"unitprice_c\">200.0000,USD</str><str name=\"name\">iPhone3G</str><str name=\"url\">home/electronics/phones/iphone3g</str><long name=\"_version_\">1435991846263193600</long></doc><doc><str name=\"id\">65540</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">250.0</float><str name=\"unitprice_c\">250.0000,USD</str><str name=\"name\">iPhone3GS</str><str name=\"url\">home/electronics/phones/iphone3gs</str><long name=\"_version_\">1435991846267387904</long></doc><doc><str name=\"id\">65541</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">350.0</float><str name=\"unitprice_c\">350.0000,USD</str><str name=\"name\">iPhone4</str><str name=\"url\">home/electronics/phones/iphone4</str><long name=\"_version_\">1435991846272630784</long></doc><doc><str name=\"id\">65539</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">550.0</float><str name=\"unitprice_c\">550.0000,USD</str><str name=\"name\">iPhone4S</str><str name=\"url\">home/electronics/phones/iphone4s</str><long name=\"_version_\">1435991846277873664</long></doc><doc><str name=\"id\">65548</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">270.0</float><str name=\"unitprice_c\">270.0000,USD</str><str name=\"name\">Omina W</str><str name=\"url\">home/electronics/phones/omina-w</str><long name=\"_version_\">1435991846282067968</long></doc><doc><str name=\"id\">65549</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">78.99</float><str name=\"unitprice_c\">78.9900,USD</str><str name=\"name\">Solid Xcover</str><str name=\"url\">home/electronics/phones/solid-xcover</str><long name=\"_version_\">1435991846286262272</long></doc></result><lst name=\"facet_counts\"><lst name=\"facet_queries\"><int name=\"{!label=*-99.99}unitprice:[* TO 99.99]\">1</int><int name=\"{!label=100-499.99}unitprice:[100 TO 499.99]\">8</int></lst><lst name=\"facet_fields\"/><lst name=\"facet_dates\"/><lst name=\"facet_ranges\"/></lst></response>",
                    @"http://localhost:8983/solr/select?q=*:*&rows=100000000&facet=true&facet.query={!label=*-99.99}unitprice:[* TO 99.99]&facet.query={!label=100-499.99}unitprice:[100 TO 499.99]&version=2.2");

            var priceFacet = new PriceFacet(new NameValueCollection(), false, new RangeQuery("*", "99.99"), new RangeQuery("100", "499.99"));

            var priceFacetViewModel = priceFacet.BuildViewModel(results);

            var expectedPriceValues = new[] {
                new { IsApplied = false, IsDisabled = false, Count = 1, Name = string.Format("Up to {0}99.99", NumberFormatInfo.CurrentInfo.CurrencySymbol), Url = "/?fps=*&fpl=99.99" },
                new { IsApplied = false, IsDisabled = false, Count = 8, Name = string.Format("{0}100.00 - {0}499.99", NumberFormatInfo.CurrentInfo.CurrencySymbol), Url = "/?fps=100&fpl=499.99" }
            };

            Assert.AreEqual(2, priceFacetViewModel.Constraints.Length);

            for (var index = 0; index < priceFacetViewModel.Constraints.Length; index++)
            {
                Assert.AreEqual(expectedPriceValues[index].IsApplied, priceFacetViewModel.Constraints[index].IsApplied);
                Assert.AreEqual(expectedPriceValues[index].IsDisabled, priceFacetViewModel.Constraints[index].IsDisabled);
                Assert.AreEqual(expectedPriceValues[index].Count, priceFacetViewModel.Constraints[index].Count);
                Assert.AreEqual(expectedPriceValues[index].Name, priceFacetViewModel.Constraints[index].Name);
                Assert.AreEqual(expectedPriceValues[index].Url, priceFacetViewModel.Constraints[index].Url);
            }
        }
 public void Can_iterate_over_a_collection()
 {
     var items = new[] { 1, 1, 1, 1, 1 };
     var sum = 0;
     items.ForEach(x => sum = sum + x );
     sum.Should().Be(5);
 }
Пример #4
0
        public void BuildAMultipleSelectPriceRangeFacetViewModelWithMultipleConstraintsApplied()
        {
            var results =
                SolrNetFacetTestFramework.RunSolrGetResults(
                    "<?xml version=\"1.0\" encoding=\"UTF-8\"?><response><lst name=\"responseHeader\"><int name=\"status\">0</int><int name=\"QTime\">76</int><lst name=\"params\"><str name=\"facet\">true</str><arr name=\"facet.query\"><str>{!label=*-99.99 ex=unitpricefilter}unitprice:[* TO 99.99]</str><str>{!label=100-499.99 ex=unitpricefilter}unitprice:[100 TO 499.99]</str></arr><str name=\"q\">*:*</str><str name=\"fq\">{!tag=unitpricefilter}unitprice:([* TO 99.99] OR [100 TO 499.99])</str><str name=\"version\">2.2</str><str name=\"rows\">100000000</str></lst></lst><result name=\"response\" numFound=\"9\" start=\"0\"><doc><str name=\"id\">65546</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">127.99</float><str name=\"unitprice_c\">127.9900,USD</str><str name=\"name\">Curvy Simplicity</str><str name=\"url\">home/electronics/phones/curvy-simplicity</str><long name=\"_version_\">1435991846235930624</long></doc><doc><str name=\"id\">65542</str><str name=\"categoryid\">32771</str><float name=\"unitprice\">250.0</float><str name=\"unitprice_c\">250.0000,USD</str><str name=\"name\">iPad</str><str name=\"url\">home/electronics/tablets/ipad</str><long name=\"_version_\">1435991846244319232</long></doc><doc><str name=\"id\">65543</str><str name=\"categoryid\">32771</str><float name=\"unitprice\">350.0</float><str name=\"unitprice_c\">350.0000,USD</str><str name=\"name\">iPad2</str><str name=\"url\">home/electronics/tablets/ipad2</str><long name=\"_version_\">1435991846248513536</long></doc><doc><str name=\"id\">65536</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">100.0</float><str name=\"unitprice_c\">100.0000,USD</str><str name=\"name\">iPhone</str><str name=\"url\">home/electronics/phones/iphone</str><long name=\"_version_\">1435991846256902144</long></doc><doc><str name=\"id\">65537</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">200.0</float><str name=\"unitprice_c\">200.0000,USD</str><str name=\"name\">iPhone3G</str><str name=\"url\">home/electronics/phones/iphone3g</str><long name=\"_version_\">1435991846263193600</long></doc><doc><str name=\"id\">65540</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">250.0</float><str name=\"unitprice_c\">250.0000,USD</str><str name=\"name\">iPhone3GS</str><str name=\"url\">home/electronics/phones/iphone3gs</str><long name=\"_version_\">1435991846267387904</long></doc><doc><str name=\"id\">65541</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">350.0</float><str name=\"unitprice_c\">350.0000,USD</str><str name=\"name\">iPhone4</str><str name=\"url\">home/electronics/phones/iphone4</str><long name=\"_version_\">1435991846272630784</long></doc><doc><str name=\"id\">65548</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">270.0</float><str name=\"unitprice_c\">270.0000,USD</str><str name=\"name\">Omina W</str><str name=\"url\">home/electronics/phones/omina-w</str><long name=\"_version_\">1435991846282067968</long></doc><doc><str name=\"id\">65549</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">78.99</float><str name=\"unitprice_c\">78.9900,USD</str><str name=\"name\">Solid Xcover</str><str name=\"url\">home/electronics/phones/solid-xcover</str><long name=\"_version_\">1435991846286262272</long></doc></result><lst name=\"facet_counts\"><lst name=\"facet_queries\"><int name=\"{!label=*-99.99 ex=unitpricefilter}unitprice:[* TO 99.99]\">1</int><int name=\"{!label=100-499.99 ex=unitpricefilter}unitprice:[100 TO 499.99]\">8</int></lst><lst name=\"facet_fields\"/><lst name=\"facet_dates\"/><lst name=\"facet_ranges\"/></lst></response>",
                    @"http://localhost:8983/solr/select?q=*:*&rows=100000000&fq={!tag=unitpricefilter}unitprice:([* TO 99.99] OR [100 TO 499.99])&facet=true&facet.query={!label=*-99.99 ex=unitpricefilter}unitprice:[* TO 99.99]&facet.query={!label=100-499.99 ex=unitpricefilter}unitprice:[100 TO 499.99]&version=2.2");

            var querystring = new NameValueCollection
                        {
                            {"fps", "*"},
                            {"fpl", "99.99"},
                            {"fps", "100"},
                            {"fpl", "499.99"}
                        };

            var priceFacet = new PriceFacet(querystring, false, new RangeQuery("*", "99.99"), new RangeQuery("100", "499.99"));

            var priceFacetViewModel = priceFacet.BuildViewModel(results);

            var expectedPriceValues = new[] {
                new { IsApplied = true, IsDisabled = false, Count = 1, Name = string.Format("Up to {0}99.99", NumberFormatInfo.CurrentInfo.CurrencySymbol), Url = "/?fps=100&fpl=499.99" },
                new { IsApplied = true, IsDisabled = false, Count = 8, Name = string.Format("{0}100.00 - {0}499.99", NumberFormatInfo.CurrentInfo.CurrencySymbol), Url = "/?fps=*&fpl=99.99" }
            };

            Assert.AreEqual(2, priceFacetViewModel.Constraints.Length);

            for (var index = 0; index < priceFacetViewModel.Constraints.Length; index++)
            {
                Assert.AreEqual(expectedPriceValues[index].IsApplied, priceFacetViewModel.Constraints[index].IsApplied);
                Assert.AreEqual(expectedPriceValues[index].IsDisabled, priceFacetViewModel.Constraints[index].IsDisabled);
                Assert.AreEqual(expectedPriceValues[index].Count, priceFacetViewModel.Constraints[index].Count);
                Assert.AreEqual(expectedPriceValues[index].Name, priceFacetViewModel.Constraints[index].Name);
                Assert.AreEqual(expectedPriceValues[index].Url, priceFacetViewModel.Constraints[index].Url);
            }
        }
Пример #5
0
        public void Callback_For_Is_Invoked()
        {
            var expected = new[] { "test" };

            _proxy.CallbackFor(r => r.AcceptTypes, () => expected);

            _proxy.Object.AcceptTypes.ShouldBeTheSameAs(expected);
        }
        public void TestInvalidParameters()
        {
            string[] names = new[]
            {
                ParameterNames.GroupIds
            };

            foreach (string name in names)
            {
                NameValueCollection nameValues = GetValidParameters();
                nameValues.Remove(name);
                Assert.IsFalse(new GroupDataAtDataPointParameters(nameValues).AreValid);
            }
        }
        public void TestInvalid()
        {
            string[] parameterNames = new[] {ParameterNames.AgeId,
            ParameterNames.YearTypeId, LabelParameters.ParameterComparatorMethod};
            foreach (var parameter in parameterNames)
            {
                AssertInvalid(parameter, "");
                AssertInvalid(parameter, "-1");
                AssertInvalid(parameter, "0");
                AssertInvalid(parameter, null);
                AssertInvalid(parameter, "a");
            }

            LabelParameters parameters = new LabelParameters(new NameValueCollection());
            Assert.IsFalse(parameters.AreValid);
        }
        public void ProgramArguments_Constructor_OverrideAppSetting()
        {
            using (ShimsContext.Create())
            {
                // Need to shim the AppSettings collection since previous tests may have wrote particular values to
                // the collection, which is statically shared across tests.
                var appSettings = new NameValueCollection {{"savetemplate", "false"}};
                ShimConfigurationManager.AppSettingsGet = () => appSettings;

                var args = new [] { "/savetemplate", "true" };

                var programArgs = new ProgramArguments(args);

                CollectionAssert.Contains(programArgs.ArgumentMap.Keys, "savetemplate");
                Assert.AreEqual(programArgs.ArgumentMap["savetemplate"], "true");
            }
        }
Пример #9
0
 public static string FormatLog(HttpRequest request)
 {
     string url = request.Url.ToString();
     string client = string.Format("{0} ({1})", request.UserHostAddress, request.UserHostName);
     string httpMethod = request.HttpMethod;
     string result = string.Format("HTTP Request\n" +
     "Requested URL: {0}\n" +
     "Client: {1}\n" +
     "HTTP method: {2}",
     url, client, httpMethod);
     if (httpMethod.Equals("POST"))
     {
         StringBuilder received = new StringBuilder("\n{ \n");
         NameValueCollection form = request.Form;
         bool first = true;
         foreach (string key in form.Keys)
         {
             if (!first)
             {
                 received.Append(",\n");
             }
             else
             {
                 first = false;
             }
             string val = form[key];
             var secrets = new[] {
                 "password", "passwd", "pass",
                 "confirmpassword", "confirmpasswd", "confirmpass",
                 "confpassword", "confpasswd", "confpass",
                 "confirm", "conf",
                 "newpassword", "oldpassword"
             };
             if (secrets.Contains(key.ToLower()))
             {
                 val = new string('*', val.Length);
             }
             received.Append(string.Format("\t{0}: \"{1}\"", key, val));
         }
         received.Append("\n}");
         return result + received;
     }
     return result;
 }
        public void ProgramArguments_Constructor_BasicProcessingSuccess()
        {
            using (ShimsContext.Create())
            {
                // Need to shim the AppSettings collection since previous tests may have wrote particular values to
                // the collection, which is statically shared across tests.
                ShimConfigurationManager.AppSettingsGet = () => new NameValueCollection();

                var args = new [] {"/action", "someaction", "/savetemplate", "false"};

                var programArgs = new ProgramArguments(args);

                CollectionAssert.Contains(programArgs.ArgumentMap.Keys, "action");
                CollectionAssert.Contains(programArgs.ArgumentMap.Keys, "savetemplate");
                CollectionAssert.DoesNotContain(programArgs.ArgumentMap.Keys, "someaction");
                CollectionAssert.DoesNotContain(programArgs.ArgumentMap.Keys, "false");
                Assert.AreEqual(programArgs.ArgumentMap["action"], "someaction");
                Assert.AreEqual(programArgs.ArgumentMap["savetemplate"], "false");
            }
        }
        public async Task AddRange()
        {
            var list = new SortedListReactiveCollectionSource<int>();

            var notificationsTask = list.ReactiveCollection.Changes
                .Skip(1)
                .FirstAsync()
                .ToTask();

            var range = new[] { 3, 1, 2 };
            list.AddRange(range);

            var notification = await notificationsTask;

            notification.Index.Should().Be(0);
            notification.Action.Should().Be(NotifyCollectionChangedAction.Add);
            notification.OldItems.Should().BeEmpty();
            notification.NewItems.Should().Equal(1, 2, 3);
            notification.Current.Should().Equal(1, 2, 3);
        }
        public void TestPolylineZValues()
        {
            Rectangular[] positions = new[]
                                          {
                                              new Rectangular(0.0, 0.0),
                                              new Rectangular(1.0, 1.0),
                                              new Rectangular(2.0, 2.0),
                                              new Rectangular(3.0, 3.0)
                                          };

            double[] zValues = new[] { 0.0, 1.0, 2.0, 3.0 };
            CartographicExtent extent = new CartographicExtent(0.0, 0.0, 3.0, 3.0);
            int[] parts = new[] { 0 };
            double[] measures = new[] { 0.0, 0.0, 0.0, 0.0 };

            PolylineZShape polylineZShape = new PolylineZShape(0, new StringDictionary(), extent, parts, positions, 1.0, 8.0, zValues, 0.0, 0.0, measures);
            Polyline polyline = new Polyline(polylineZShape, m_document, Color.Blue);
            polyline.Write();
            string result = m_stringWriter.ToString();
            Assert.IsTrue(Regex.IsMatch(result, m_polylinePattern));
        }
        /// <summary> Submitts the new password for the associated sitecore membership account </summary>
        /// <param name="formid"> The formid. </param>
        /// <param name="fields"> The fields. </param>
        /// <exception cref="ValidatorException">The password information provided is incorrect.</exception>
        public void Submit(ID formid, AdaptedResultList fields)
        {
            NameValueCollection form = new NameValueCollection();
              ActionHelper.FillFormData(form, fields, null);

              if (!string.IsNullOrEmpty(form["CreatePassword"]))
              {
            ICustomerManager<CustomerInfo> customerManager = Context.Entity.Resolve<ICustomerManager<CustomerInfo>>();
            string customerId = customerManager.CurrentUser.NickName;

            MembershipUser membershipUser = Membership.GetUser(customerId);

            // Checks that the user information is correct for the user who want's to change password
            if (AuthenticationManager.Login(customerId, form["OldPassword"]) && !string.IsNullOrEmpty(customerId) && !string.IsNullOrEmpty(form["OldPassword"]))
            {
              // We can continue if the information is correct
              if (membershipUser != null)
              {
            string email = customerManager.CurrentUser.Email;

            if (!MainUtil.IsValidEmailAddress(email))
            {
              email = membershipUser.Email;
            }

            if (membershipUser.ChangePassword(form["OldPassword"], form["CreatePassword"]))
            {
              var param = new { Recipient = email };

              IMail mailProvider = Context.Entity.Resolve<IMail>();
              mailProvider.SendMail(MailTemplateNamePasswordChanged, param, string.Empty);
            }
              }
            }
            else
            {
              throw new ValidatorException("The password information provided is incorrect.");
            }
              }
        }
Пример #14
0
        public void BuildAMultipleSelectFacetViewModelWithMultipleConstraintsApplied()
        {
            var results =
                SolrNetFacetTestFramework.RunSolrGetResults(
                    "<?xml version=\"1.0\" encoding=\"UTF-8\"?><response><lst name=\"responseHeader\"><int name=\"status\">0</int><int name=\"QTime\">2</int><lst name=\"params\"><str name=\"facet\">true</str><str name=\"q\">*:*</str><str name=\"facet.field\">{!key=brands ex=brandsfilter}brand_f</str><str name=\"fq\">{!tag=brandsfilter}brand_f:(iPhone OR LCD televisions OR LED televisions OR Smartphones)</str><str name=\"version\">2.2</str><str name=\"rows\">100000000</str></lst></lst><result name=\"response\" numFound=\"7\" start=\"0\"><doc><str name=\"id\">65538</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">523.0</float><str name=\"unitprice_c\">523.0000,USD</str><str name=\"name\">Galaxy Note</str><str name=\"url\">home/electronics/phones/galaxy-note</str><long name=\"_version_\">1435991846240124928</long></doc><doc><str name=\"id\">65536</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">100.0</float><str name=\"unitprice_c\">100.0000,USD</str><str name=\"name\">iPhone</str><str name=\"url\">home/electronics/phones/iphone</str><long name=\"_version_\">1435991846256902144</long></doc><doc><str name=\"id\">65537</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">200.0</float><str name=\"unitprice_c\">200.0000,USD</str><str name=\"name\">iPhone3G</str><str name=\"url\">home/electronics/phones/iphone3g</str><long name=\"_version_\">1435991846263193600</long></doc><doc><str name=\"id\">65540</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">250.0</float><str name=\"unitprice_c\">250.0000,USD</str><str name=\"name\">iPhone3GS</str><str name=\"url\">home/electronics/phones/iphone3gs</str><long name=\"_version_\">1435991846267387904</long></doc><doc><str name=\"id\">65541</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">350.0</float><str name=\"unitprice_c\">350.0000,USD</str><str name=\"name\">iPhone4</str><str name=\"url\">home/electronics/phones/iphone4</str><long name=\"_version_\">1435991846272630784</long></doc><doc><str name=\"id\">65539</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">550.0</float><str name=\"unitprice_c\">550.0000,USD</str><str name=\"name\">iPhone4S</str><str name=\"url\">home/electronics/phones/iphone4s</str><long name=\"_version_\">1435991846277873664</long></doc><doc><str name=\"id\">65548</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">270.0</float><str name=\"unitprice_c\">270.0000,USD</str><str name=\"name\">Omina W</str><str name=\"url\">home/electronics/phones/omina-w</str><long name=\"_version_\">1435991846282067968</long></doc></result><lst name=\"facet_counts\"><lst name=\"facet_queries\"/><lst name=\"facet_fields\"><lst name=\"brands\"><int name=\"iPhone\">5</int><int name=\"iPad\">3</int><int name=\"Mobile phones\">2</int><int name=\"Smartphones\">2</int><int name=\"LCD televisions\">1</int><int name=\"LED televisions\">1</int><int name=\"Plasma televisions\">1</int></lst></lst><lst name=\"facet_dates\"/><lst name=\"facet_ranges\"/></lst></response>",
                    @"http://localhost:8983/solr/select?q=*:*&rows=100000000&fq={!tag=brandsfilter}brand_f:(iPhone+OR+LCD+televisions+OR+LED+televisions+OR+Smartphones)&facet=true&facet.field={!key=brands+ex=brandsfilter}brand_f&version=2.2");

            var brandFacet = new BrandFacet(new NameValueCollection
                {
                    {"fb", "Smartphones"},
                    {"fb", "iPhone"},
                    {"fb", "LCD televisions"},
                    {"fb", "LED televisions"}
                });

            var facetViewModel = brandFacet.BuildViewModel(results);

            var expectedValues = new[] {
                new { IsApplied = false, IsDisabled = false, Count = 3, Name = "iPad", Url = "/?fb=iPad&fb=iPhone&fb=LCD+televisions&fb=LED+televisions&fb=Smartphones" },
                new { IsApplied = true, IsDisabled = false, Count = 5, Name = "iPhone", Url = "/?fb=LCD+televisions&fb=LED+televisions&fb=Smartphones" },
                new { IsApplied = true, IsDisabled = false, Count = 1, Name = "LCD televisions", Url = "/?fb=iPhone&fb=LED+televisions&fb=Smartphones" },
                new { IsApplied = true, IsDisabled = false, Count = 1, Name = "LED televisions", Url = "/?fb=iPhone&fb=LCD+televisions&fb=Smartphones" },
                new { IsApplied = false, IsDisabled = false, Count = 2, Name = "Mobile phones", Url = "/?fb=iPhone&fb=LCD+televisions&fb=LED+televisions&fb=Mobile+phones&fb=Smartphones" },
                new { IsApplied = false, IsDisabled = false, Count = 1, Name = "Plasma televisions", Url = "/?fb=iPhone&fb=LCD+televisions&fb=LED+televisions&fb=Plasma+televisions&fb=Smartphones" },
                new { IsApplied = true, IsDisabled = false, Count = 2, Name = "Smartphones", Url = "/?fb=iPhone&fb=LCD+televisions&fb=LED+televisions" }
            };

            Assert.AreEqual(7, facetViewModel.Constraints.Length);

            for (var index = 0; index < facetViewModel.Constraints.Length; index++)
            {
                Assert.AreEqual(expectedValues[index].IsApplied, facetViewModel.Constraints[index].IsApplied);
                Assert.AreEqual(expectedValues[index].IsDisabled, facetViewModel.Constraints[index].IsDisabled);
                Assert.AreEqual(expectedValues[index].Count, facetViewModel.Constraints[index].Count);
                Assert.AreEqual(expectedValues[index].Name, facetViewModel.Constraints[index].Name);
                Assert.AreEqual(expectedValues[index].Url, facetViewModel.Constraints[index].Url);
            }
        }
Пример #15
0
        /// <summary>
        ///   Adds a file attachment using a byte[] array
        /// </summary>
        /// <param name = "path">The full path to the file to attach</param>
        /// <param name = "contentType">ContentID for inline images.</param>
        public void AddAttachment(byte[] content, string contentType, string attachmentName)
        {
            ValidateAttachmentLength(Convert.ToBase64String(content));

            var attachment = new PostmarkMessageAttachment
            {
                Name = attachmentName,
                ContentType = contentType,
            #if !WINDOWS_PHONE
                Content = Convert.ToBase64String(content, Base64FormattingOptions.InsertLineBreaks)
            #else
                    Content = Convert.ToBase64String(content)
            #endif
            };

            Attachments.Add(attachment);
        }
Пример #16
0
        /// <summary>
        ///   Adds a file attachment.
        /// </summary>
        /// <param name = "path">The full path to the file to attach</param>
        /// <param name = "contentType">The content type.</param>
        public void AddAttachment(string path, string contentType)
        {
            ValidateAttachmentPath(path);

            using (var stream = File.OpenRead(path))
            {
                var content = ReadStream(stream, 8067);

                ValidateAttachmentLength(Convert.ToBase64String(content));

                var attachment = new PostmarkMessageAttachment
                {
                    Name = new FileInfo(path).Name,
                    ContentType = contentType,
            #if !WINDOWS_PHONE
                    Content = Convert.ToBase64String(content, Base64FormattingOptions.InsertLineBreaks)
            #else
                    Content = Convert.ToBase64String(content)
            #endif
                };

                Attachments.Add(attachment);
            }
        }
        public void SendSetsContentTypeAndWritesSerializedResponse()
        {
            var obj = new { A = 1 };
            var context = new Mock<HttpContextBase>();
            var request = new Mock<HttpRequestBase>();
            var response = new Mock<HttpResponseBase>();
            request.Setup(m => m.Path).Returns("/foo/");
            request.Setup(m => m["clientId"]).Returns("1");
            context.Setup(m => m.Response).Returns(response.Object);
            context.Setup(m => m.Request).Returns(request.Object);
            var json = new Mock<IJsonStringifier>();
            json.Setup(m => m.Stringify(obj)).Returns("A=1");
            var heartBeat = new Mock<ITransportHeartBeat>();
            var transport = new LongPollingTransport(context.Object, json.Object, heartBeat.Object);
            var connection = new Mock<IConnection>();
            transport.Send(obj);

            response.VerifySet(m => m.ContentType = "application/json");
            response.Verify(m => m.Write("A=1"), Times.Once());
        }
        public void TestMultipatchConversionWithTriangleStrip()
        {
            Rectangular[] positions = new[]
                                          {
                                              new Rectangular(0.0, 0.0),
                                              new Rectangular(0.0, 1.0),
                                              new Rectangular(1.0, 0.0),
                                              new Rectangular(1.0, 1.0),
                                              new Rectangular(2.0, 0.0),
                                              new Rectangular(2.0, 1.0),
                                              new Rectangular(3.0, 0.0)
                                          };

            CartographicExtent extent = new CartographicExtent(0.0, 0.0, 3.0, 1.0);
            int[] parts = new[] { 0 };
            MultiPatchPartType[] partTypes = new[] { MultiPatchPartType.TriangleStrip };

            double[] zValues = new[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 };
            double[] measures = new[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

            MultiPatchShape multipatch = new MultiPatchShape(0, m_metadata, extent, parts, partTypes, positions, 0.0, 0.0, zValues, 0.0, 0.0, measures);
            MultiPatch patch = new MultiPatch(multipatch, m_document, Color.Blue);
            patch.Write();
            string result = m_stringWriter.ToString();
            Regex trianglePattern = new Regex(m_trianglePattern);
            Assert.AreEqual(5, trianglePattern.Matches(result).Count);
        }
Пример #19
0
        public void BuildAPriceFacetViewModelWhichPerformsAFreeSearchEvenThoughMultipleSelectionSearchIsDefinedButIsNotPartOfTheSelection()
        {
            var results =
                SolrNetFacetTestFramework.RunSolrGetResults(
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?><response><lst name=\"responseHeader\"><int name=\"status\">0</int><int name=\"QTime\">3</int><lst name=\"params\"><str name=\"facet\">true</str><str name=\"facet.query\">{!label=10.96-56.87 ex=unitpricefilter}unitprice:[10.96 TO 56.87]</str><str name=\"q\">*:*</str><str name=\"fq\">{!tag=unitpricefilter}unitprice:([10.96 TO 56.87])</str><str name=\"version\">2.2</str><str name=\"rows\">100000000</str></lst></lst><result name=\"response\" numFound=\"0\" start=\"0\"></result><lst name=\"facet_counts\"><lst name=\"facet_queries\"><int name=\"{!label=10.96-56.87 ex=unitpricefilter}unitprice:[10.96 TO 56.87]\">0</int></lst><lst name=\"facet_fields\"/><lst name=\"facet_dates\"/><lst name=\"facet_ranges\"/></lst></response>",
                @"http://localhost:8983/solr/select?q=*:*&rows=100000000&fq={!tag=unitpricefilter}unitprice:([10.96 TO 56.87])&facet=true&facet.query={!label=10.96-56.87 ex=unitpricefilter}unitprice:[10.96 TO 56.87]&version=2.2");

            var querystring = new NameValueCollection
            {
                {"fps", "*"},
                {"fpl", "88.88"},
                {"fps", "200"},
                {"fpl", "499.99"},
                {"fpfs", "10.96"},
                {"fpfl", "56.87"}
            };

            var priceFacet = new PriceFacet(querystring, false, new RangeQuery("100", "499.99"), new RangeQuery("*", "99.99"));

            var priceFacetViewModel = priceFacet.BuildViewModel(results);

            var expectedPriceValues = new[] {
                new { IsApplied = true, IsDisabled = true, Count = 0, Name = string.Format("{0}10.96 - {0}56.87", NumberFormatInfo.CurrentInfo.CurrencySymbol), Url = string.Empty }
            };

            Assert.AreEqual(1, priceFacetViewModel.Constraints.Length);

            for (var index = 0; index < priceFacetViewModel.Constraints.Length; index++)
            {
                Assert.AreEqual(expectedPriceValues[index].IsApplied, priceFacetViewModel.Constraints[index].IsApplied);
                Assert.AreEqual(expectedPriceValues[index].IsDisabled, priceFacetViewModel.Constraints[index].IsDisabled);
                Assert.AreEqual(expectedPriceValues[index].Count, priceFacetViewModel.Constraints[index].Count);
                Assert.AreEqual(expectedPriceValues[index].Name, priceFacetViewModel.Constraints[index].Name);
                Assert.AreEqual(expectedPriceValues[index].Url, priceFacetViewModel.Constraints[index].Url);
            }
        }
        public void GetEnumerator()
        {
            var list = new SortedListReactiveCollectionSource<int>();

            var range = new[] { 1, 2, 3 };
            list.AddRange(range);

            using (var enumerator = list.GetEnumerator())
            {
                enumerator.MoveNext().Should().BeTrue();
                enumerator.Current.Should().Be(1);
                enumerator.MoveNext().Should().BeTrue();
                enumerator.Current.Should().Be(2);
                enumerator.MoveNext().Should().BeTrue();
                enumerator.Current.Should().Be(3);
                enumerator.MoveNext().Should().BeFalse();
            }
        }
Пример #21
0
        public void BuildUrlAppendsMultipleAnonymousObjectsToQueryString()
        {
            // Arrange
            var page = "home";
            var queryString1 = new { sort = "FName", dir = "desc" };
            var queryString2 = new { view = "Activities", page = 7 };

            // Act
            string query;
            var path = UrlUtil.BuildUrl(page, out query, queryString1, queryString2);

            // Assert
            Assert.Equal(path + query, page + "?sort=FName&dir=desc&view=Activities&page=7");
        }
Пример #22
0
        public void BuildUrlAppendsAnonymousObjectsToQueryString()
        {
            // Arrange
            var page = "home";
            var queryString = new { sort = "FName", dir = "desc" };

            // Act
            string query;
            var path = UrlUtil.BuildUrl(page, out query, queryString);

            // Assert
            Assert.Equal(path + query, page + "?sort=FName&dir=desc");
        }
Пример #23
0
        public void BuildFacetViewModelThatWillOnlyApplyTheFirstConstraintWhenMultipleConstraintsHaveBeenPassedInToBeApplied()
        {
            var results =
                SolrNetFacetTestFramework.RunSolrGetResults(
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?><response><lst name=\"responseHeader\"><int name=\"status\">0</int><int name=\"QTime\">40</int><lst name=\"params\"><str name=\"facet\">true</str><arr name=\"facet.query\"><str>{!label=*-99.99 ex=unitpricefilter}unitprice:[* TO 99.99]</str><str>{!label=100-499.99 ex=unitpricefilter}unitprice:[100 TO 499.99]</str></arr><str name=\"q\">*:*</str><str name=\"fq\">{!tag=unitpricefilter}unitprice:([* TO 99.99])</str><str name=\"version\">2.2</str><str name=\"rows\">100000000</str></lst></lst><result name=\"response\" numFound=\"1\" start=\"0\"><doc><str name=\"id\">65549</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">78.99</float><str name=\"unitprice_c\">78.9900,USD</str><str name=\"name\">Solid Xcover</str><str name=\"url\">home/electronics/phones/solid-xcover</str><long name=\"_version_\">1435991846286262272</long></doc></result><lst name=\"facet_counts\"><lst name=\"facet_queries\"><int name=\"{!label=*-99.99 ex=unitpricefilter}unitprice:[* TO 99.99]\">1</int><int name=\"{!label=100-499.99 ex=unitpricefilter}unitprice:[100 TO 499.99]\">8</int></lst><lst name=\"facet_fields\"/><lst name=\"facet_dates\"/><lst name=\"facet_ranges\"/></lst></response>",
                @"http://localhost:8983/solr/select?q=*:*&rows=100000000&fq={!tag=unitpricefilter}unitprice:([* TO 99.99])&facet=true&facet.query={!label=*-99.99 ex=unitpricefilter}unitprice:[* TO 99.99]&facet.query={!label=100-499.99 ex=unitpricefilter}unitprice:[100 TO 499.99]&version=2.2");

            var querystring = new NameValueCollection
                    {
                        {"fps", "*"},
                        {"fpl", "99.99"},
                        {"fps", "100"},
                        {"fpl", "499.99"},
                    };

            var priceFacet = new PriceFacet(querystring, true, new RangeQuery("*", "99.99"), new RangeQuery("100", "499.99"));

            var priceFacetViewModel = priceFacet.BuildViewModel(results);

            var expectedPriceValues = new[] {
                new { IsApplied = true, IsDisabled = false, Count = 1, Name = string.Format("Up to {0}99.99", NumberFormatInfo.CurrentInfo.CurrencySymbol), Url = "/" },
                new { IsApplied = false, IsDisabled = true, Count = 8, Name = string.Format("{0}100.00 - {0}499.99", NumberFormatInfo.CurrentInfo.CurrencySymbol), Url = string.Empty }
            };

            Assert.AreEqual(2, priceFacetViewModel.Constraints.Length);

            for (var index = 0; index < priceFacetViewModel.Constraints.Length; index++)
            {
                Assert.AreEqual(expectedPriceValues[index].IsApplied, priceFacetViewModel.Constraints[index].IsApplied);
                Assert.AreEqual(expectedPriceValues[index].IsDisabled, priceFacetViewModel.Constraints[index].IsDisabled);
                Assert.AreEqual(expectedPriceValues[index].Count, priceFacetViewModel.Constraints[index].Count);
                Assert.AreEqual(expectedPriceValues[index].Name, priceFacetViewModel.Constraints[index].Name);
                Assert.AreEqual(expectedPriceValues[index].Url, priceFacetViewModel.Constraints[index].Url);
            }
        }
Пример #24
0
        public void BuildAPriceRangeFacetViewThatWillPerformAFreeSearchWithAMaximumSetToStarIfMaximumIsNotSupplied()
        {
            var results =
                SolrNetFacetTestFramework.RunSolrGetResults(
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?><response><lst name=\"responseHeader\"><int name=\"status\">0</int><int name=\"QTime\">2</int><lst name=\"params\"><str name=\"facet\">true</str><str name=\"facet.query\">{!label=112.87-* ex=unitpricefilter}unitprice:[112.87 TO *]</str><str name=\"q\">*:*</str><str name=\"fq\">{!tag=unitpricefilter}unitprice:([112.87 TO *])</str><str name=\"version\">2.2</str><str name=\"rows\">100000000</str></lst></lst><result name=\"response\" numFound=\"13\" start=\"0\"><doc><str name=\"id\">65547</str><str name=\"categoryid\">32772</str><float name=\"unitprice\">1699.99</float><str name=\"unitprice_c\">1699.9900,USD</str><str name=\"name\">19\" D450 HD LCD TV</str><str name=\"url\">home/electronics/televisions/19-d450-hd-lcd-tv</str><long name=\"_version_\">1435991846184550400</long></doc><doc><str name=\"id\">65545</str><str name=\"categoryid\">32772</str><float name=\"unitprice\">1399.99</float><str name=\"unitprice_c\">1399.9900,USD</str><str name=\"name\">32'' ES6800 Series 6 SMART 3D Full HD LED TV</str><str name=\"url\">home/electronics/televisions/32-es6800-series-6-smart-3d-full-hd-led-tv</str><long name=\"_version_\">1435991846228590592</long></doc><doc><str name=\"id\">65550</str><str name=\"categoryid\">32772</str><float name=\"unitprice\">1299.99</float><str name=\"unitprice_c\">1299.9900,USD</str><str name=\"name\">51\" E6500 Series 6 Smart Full HD LED TV</str><str name=\"url\">home/electronics/televisions/51-e6500-series-6-smart-full-hd-led-tv</str><long name=\"_version_\">1435991846231736320</long></doc><doc><str name=\"id\">65546</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">127.99</float><str name=\"unitprice_c\">127.9900,USD</str><str name=\"name\">Curvy Simplicity</str><str name=\"url\">home/electronics/phones/curvy-simplicity</str><long name=\"_version_\">1435991846235930624</long></doc><doc><str name=\"id\">65538</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">523.0</float><str name=\"unitprice_c\">523.0000,USD</str><str name=\"name\">Galaxy Note</str><str name=\"url\">home/electronics/phones/galaxy-note</str><long name=\"_version_\">1435991846240124928</long></doc><doc><str name=\"id\">65542</str><str name=\"categoryid\">32771</str><float name=\"unitprice\">250.0</float><str name=\"unitprice_c\">250.0000,USD</str><str name=\"name\">iPad</str><str name=\"url\">home/electronics/tablets/ipad</str><long name=\"_version_\">1435991846244319232</long></doc><doc><str name=\"id\">65543</str><str name=\"categoryid\">32771</str><float name=\"unitprice\">350.0</float><str name=\"unitprice_c\">350.0000,USD</str><str name=\"name\">iPad2</str><str name=\"url\">home/electronics/tablets/ipad2</str><long name=\"_version_\">1435991846248513536</long></doc><doc><str name=\"id\">65544</str><str name=\"categoryid\">32771</str><float name=\"unitprice\">500.0</float><str name=\"unitprice_c\">500.0000,USD</str><str name=\"name\">iPad3</str><str name=\"url\">home/electronics/tablets/ipad3</str><long name=\"_version_\">1435991846252707840</long></doc><doc><str name=\"id\">65537</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">200.0</float><str name=\"unitprice_c\">200.0000,USD</str><str name=\"name\">iPhone3G</str><str name=\"url\">home/electronics/phones/iphone3g</str><long name=\"_version_\">1435991846263193600</long></doc><doc><str name=\"id\">65540</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">250.0</float><str name=\"unitprice_c\">250.0000,USD</str><str name=\"name\">iPhone3GS</str><str name=\"url\">home/electronics/phones/iphone3gs</str><long name=\"_version_\">1435991846267387904</long></doc><doc><str name=\"id\">65541</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">350.0</float><str name=\"unitprice_c\">350.0000,USD</str><str name=\"name\">iPhone4</str><str name=\"url\">home/electronics/phones/iphone4</str><long name=\"_version_\">1435991846272630784</long></doc><doc><str name=\"id\">65539</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">550.0</float><str name=\"unitprice_c\">550.0000,USD</str><str name=\"name\">iPhone4S</str><str name=\"url\">home/electronics/phones/iphone4s</str><long name=\"_version_\">1435991846277873664</long></doc><doc><str name=\"id\">65548</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">270.0</float><str name=\"unitprice_c\">270.0000,USD</str><str name=\"name\">Omina W</str><str name=\"url\">home/electronics/phones/omina-w</str><long name=\"_version_\">1435991846282067968</long></doc></result><lst name=\"facet_counts\"><lst name=\"facet_queries\"><int name=\"{!label=112.87-* ex=unitpricefilter}unitprice:[112.87 TO *]\">13</int></lst><lst name=\"facet_fields\"/><lst name=\"facet_dates\"/><lst name=\"facet_ranges\"/></lst></response>",
                @"http://localhost:8983/solr/select?q=*:*&rows=100000000&fq={!tag=unitpricefilter}unitprice:([112.87 TO *])&facet=true&facet.query={!label=112.87-* ex=unitpricefilter}unitprice:[112.87 TO *]&version=2.2");

            var querystring = new NameValueCollection
            {
                {"fpfs", "112.87"}
            };

            var priceFacet = new PriceFacet(querystring, false, new RangeQuery("*", "99.99"), new RangeQuery("100", "499.99"));

            var priceFacetViewModel = priceFacet.BuildViewModel(results);

            var expectedPriceValues = new[] {
                new { IsApplied = true, IsDisabled = false, Count = 13, Name = string.Format("Over {0}112.87", NumberFormatInfo.CurrentInfo.CurrencySymbol), Url = "/" }
            };

            Assert.AreEqual(1, priceFacetViewModel.Constraints.Length);

            for (var index = 0; index < priceFacetViewModel.Constraints.Length; index++)
            {
                Assert.AreEqual(expectedPriceValues[index].IsApplied, priceFacetViewModel.Constraints[index].IsApplied);
                Assert.AreEqual(expectedPriceValues[index].IsDisabled, priceFacetViewModel.Constraints[index].IsDisabled);
                Assert.AreEqual(expectedPriceValues[index].Count, priceFacetViewModel.Constraints[index].Count);
                Assert.AreEqual(expectedPriceValues[index].Name, priceFacetViewModel.Constraints[index].Name);
                Assert.AreEqual(expectedPriceValues[index].Url, priceFacetViewModel.Constraints[index].Url);
            }

            Assert.IsTrue(priceFacetViewModel.IsFreeFormSearch);
            Assert.AreEqual("112.87", priceFacetViewModel.FreeSearchMinimumValue);
            Assert.AreEqual(string.Empty, priceFacetViewModel.FreeSearchMaximumValue);
        }
Пример #25
0
        public void SetDataSourceForeignKeyStringArray()
        {
            Grid mastergrid = new Grid();

            mastergrid.ID = "test";
            mastergrid.Page = Testpage;

            mastergrid.DisplayView = DisplayView.Detail;
            Testpage.Controls.Add(mastergrid);

            Foreignkey column = new Foreignkey("ForeignkeyItems", mastergrid.MasterTable);
            column.NullText = "Select Category";
            column.Required = true;
            mastergrid.MasterTable.Columns.Add(column);

            WebGrid.Data.Table fktable = new WebGrid.Data.Table(mastergrid, true);
            string[] names = new[] { "Tom", "Dick", "Harry", "Thomas", "Anders", "Carl", "Trond", "Eli", "Eva" };
            fktable.DataSource = names;

            ((Foreignkey)mastergrid["ForeignkeyItems"]).Table = fktable;

            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
            mastergrid.RenderControl(gridwriter);

            Assert.AreEqual(mastergrid.MasterTable.Rows.Count, 1);
            Assert.IsTrue(mastergrid.MasterTable.GotSchema);
            Assert.AreEqual(((Foreignkey)mastergrid["ForeignkeyItems"]).Table.Rows.Count, names.Length);
        }
Пример #26
0
        public void BuildUrlEncodesQueryStringKeysAndValues()
        {
            // Arrange
            var page = "home";
            var queryString = new { ζ = "my=value&", mykey = "<π" };

            // Act
            string query;
            var path = UrlUtil.BuildUrl(page, out query, queryString);

            // Assert
            Assert.Equal(path + query, page + "?%ce%b6=my%3dvalue%26&mykey=%3c%cf%80");
        }
        public void CopyTo()
        {
            var list = new SortedListReactiveCollectionSource<int>();

            var range = new[] { 1, 2, 3 };
            list.AddRange(range);

            var target = new int[5];
            list.CopyTo(target, 2);

            target.Should().Equal(0, 0, 1, 2, 3);
        }
 public void TestMultiPoint()
 {
     Cartographic[] points = new[]
                                 {
                                     new Cartographic(0.0, 0.0, 0.0),
                                     new Cartographic(1.0, 1.0, 1.0),
                                     new Cartographic(2.0, 2.0, 2.0)
                                 };
     CartographicExtent extent = new CartographicExtent(0.0, 0.0, 2.0, 2.0);
     MultiPointShape multipoint = new MultiPointShape(0, m_metadata, extent, points);
     MultiPoint mp = new MultiPoint(multipoint, m_document, Color.Blue);
     mp.Write();
     string result = m_stringWriter.ToString();
     Regex pointPattern = new Regex(m_pointPattern);
     Assert.AreEqual(3, pointPattern.Matches(result).Count);
 }
Пример #29
0
        public void BuildFacetViewModelsForTwoFacetsWithOneBeingARangeFacetThatBothHaveMultipleConstraintsApplied()
        {
            var results =
                SolrNetFacetTestFramework.RunSolrGetResults(
                    "<?xml version=\"1.0\" encoding=\"UTF-8\"?><response><lst name=\"responseHeader\"><int name=\"status\">0</int><int name=\"QTime\">25</int><lst name=\"params\"><str name=\"facet\">true</str><arr name=\"facet.query\"><str>{!label=*-99.99 ex=unitpricefilter}unitprice:[* TO 99.99]</str><str>{!label=100-499.99 ex=unitpricefilter}unitprice:[100 TO 499.99]</str><str>{!label=*-99.99-ruledout ex=brandsfilter,unitpricefilter}unitprice:[* TO 99.99]</str><str>{!label=100-499.99-ruledout ex=brandsfilter,unitpricefilter}unitprice:[100 TO 499.99]</str></arr><str name=\"q\">*:*</str><arr name=\"facet.field\"><str>{!key=brands ex=brandsfilter}brand_f</str><str>{!key=brandsruledout ex=unitpricefilter,brandsfilter}brand_f</str></arr><arr name=\"fq\"><str>{!tag=unitpricefilter}unitprice:([* TO 99.99] OR [100 TO 499.99])</str><str>{!tag=brandsfilter}brand_f:(iPhone OR LCD televisions OR LED televisions OR Smartphones)</str></arr><str name=\"version\">2.2</str><str name=\"rows\">100000000</str></lst></lst><result name=\"response\" numFound=\"5\" start=\"0\"><doc><str name=\"id\">65536</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">100.0</float><str name=\"unitprice_c\">100.0000,USD</str><str name=\"name\">iPhone</str><str name=\"url\">home/electronics/phones/iphone</str><long name=\"_version_\">1435991846256902144</long></doc><doc><str name=\"id\">65537</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">200.0</float><str name=\"unitprice_c\">200.0000,USD</str><str name=\"name\">iPhone3G</str><str name=\"url\">home/electronics/phones/iphone3g</str><long name=\"_version_\">1435991846263193600</long></doc><doc><str name=\"id\">65540</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">250.0</float><str name=\"unitprice_c\">250.0000,USD</str><str name=\"name\">iPhone3GS</str><str name=\"url\">home/electronics/phones/iphone3gs</str><long name=\"_version_\">1435991846267387904</long></doc><doc><str name=\"id\">65541</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">350.0</float><str name=\"unitprice_c\">350.0000,USD</str><str name=\"name\">iPhone4</str><str name=\"url\">home/electronics/phones/iphone4</str><long name=\"_version_\">1435991846272630784</long></doc><doc><str name=\"id\">65548</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">270.0</float><str name=\"unitprice_c\">270.0000,USD</str><str name=\"name\">Omina W</str><str name=\"url\">home/electronics/phones/omina-w</str><long name=\"_version_\">1435991846282067968</long></doc></result><lst name=\"facet_counts\"><lst name=\"facet_queries\"><int name=\"{!label=*-99.99 ex=unitpricefilter}unitprice:[* TO 99.99]\">0</int><int name=\"{!label=100-499.99 ex=unitpricefilter}unitprice:[100 TO 499.99]\">5</int><int name=\"{!label=*-99.99-ruledout ex=brandsfilter,unitpricefilter}unitprice:[* TO 99.99]\">1</int><int name=\"{!label=100-499.99-ruledout ex=brandsfilter,unitpricefilter}unitprice:[100 TO 499.99]\">8</int></lst><lst name=\"facet_fields\"><lst name=\"brands\"><int name=\"iPhone\">4</int><int name=\"Mobile phones\">2</int><int name=\"iPad\">2</int><int name=\"Smartphones\">1</int><int name=\"LCD televisions\">0</int><int name=\"LED televisions\">0</int><int name=\"Plasma televisions\">0</int></lst><lst name=\"brandsruledout\"><int name=\"iPhone\">5</int><int name=\"iPad\">3</int><int name=\"Mobile phones\">2</int><int name=\"Smartphones\">2</int><int name=\"LCD televisions\">1</int><int name=\"LED televisions\">1</int><int name=\"Plasma televisions\">1</int></lst></lst><lst name=\"facet_dates\"/><lst name=\"facet_ranges\"/></lst></response>",
                    @"http://localhost:8983/solr/select?q=*:*&rows=100000000&fq={!tag=unitpricefilter}unitprice:([* TO 99.99] OR [100 TO 499.99])&fq={!tag=brandsfilter}brand_f:(iPhone OR LCD televisions OR LED televisions OR Smartphones)&facet=true&facet.query={!label=*-99.99 ex=unitpricefilter}unitprice:[* TO 99.99]&facet.query={!label=100-499.99 ex=unitpricefilter}unitprice:[100 TO 499.99]&facet.query={!label=*-99.99-ruledout ex=brandsfilter,unitpricefilter}unitprice:[* TO 99.99]&facet.query={!label=100-499.99-ruledout ex=brandsfilter,unitpricefilter}unitprice:[100 TO 499.99]&facet.field={!key=brands ex=brandsfilter}brand_f&facet.field={!key=brandsruledout ex=unitpricefilter,brandsfilter}brand_f&version=2.2");

            var querystring = new NameValueCollection
                            {
                                {"fps", "*"},
                                {"fpl", "99.99"},
                                {"fps", "100"},
                                {"fpl", "499.99"},
                                {"fb", "Smartphones"},
                                {"fb", "iPhone"},
                                {"fb", "LCD televisions"},
                                {"fb", "LED televisions"}
                            };

            var brandFacet = new BrandFacet(querystring);
            var priceFacet = new PriceFacet(querystring, false, new RangeQuery("*", "99.99"), new RangeQuery("100", "499.99"));

            var facets = new IFacet[]
                {
                    brandFacet,
                    priceFacet
                };

            brandFacet.BuildDependencies(facets);
            priceFacet.BuildDependencies(facets);

            var brandFacetViewModel = brandFacet.BuildViewModel(results);
            var priceFacetViewModel = priceFacet.BuildViewModel(results);

            var expectedBrandValues = new[] {
                new { IsApplied = false, IsDisabled = false, Count = 2, Name = "iPad", Url = "/?fps=*&fps=100&fpl=99.99&fpl=499.99&fb=iPad&fb=iPhone&fb=LCD+televisions&fb=LED+televisions&fb=Smartphones" },
                new { IsApplied = true, IsDisabled = false, Count = 4, Name = "iPhone", Url = "/?fps=*&fps=100&fpl=99.99&fpl=499.99&fb=LCD+televisions&fb=LED+televisions&fb=Smartphones" },
                new { IsApplied = true, IsDisabled = true, Count = 1, Name = "LCD televisions", Url = string.Empty },
                new { IsApplied = true, IsDisabled = true, Count = 1, Name = "LED televisions", Url = string.Empty },
                new { IsApplied = false, IsDisabled = false, Count = 2, Name = "Mobile phones", Url = "/?fps=*&fps=100&fpl=99.99&fpl=499.99&fb=iPhone&fb=LCD+televisions&fb=LED+televisions&fb=Mobile+phones&fb=Smartphones" },
                new { IsApplied = false, IsDisabled = true, Count = 1, Name = "Plasma televisions", Url = string.Empty },
                new { IsApplied = true, IsDisabled = false, Count = 1, Name = "Smartphones", Url = "/?fps=*&fps=100&fpl=99.99&fpl=499.99&fb=iPhone&fb=LCD+televisions&fb=LED+televisions" }
            };

            Assert.AreEqual(7, brandFacetViewModel.Constraints.Length);

            for (var index = 0; index < brandFacetViewModel.Constraints.Length; index++)
            {
                Assert.AreEqual(expectedBrandValues[index].IsApplied, brandFacetViewModel.Constraints[index].IsApplied);
                Assert.AreEqual(expectedBrandValues[index].IsDisabled, brandFacetViewModel.Constraints[index].IsDisabled);
                Assert.AreEqual(expectedBrandValues[index].Count, brandFacetViewModel.Constraints[index].Count);
                Assert.AreEqual(expectedBrandValues[index].Name, brandFacetViewModel.Constraints[index].Name);
                Assert.AreEqual(expectedBrandValues[index].Url, brandFacetViewModel.Constraints[index].Url);
            }

            var expectedPriceValues = new[] {
                new { IsApplied = true, IsDisabled = true, Count = 1, Name = string.Format("Up to {0}99.99", NumberFormatInfo.CurrentInfo.CurrencySymbol), Url = string.Empty },
                new { IsApplied = true, IsDisabled = false, Count = 5, Name = string.Format("{0}100.00 - {0}499.99", NumberFormatInfo.CurrentInfo.CurrencySymbol), Url = "/?fb=iPhone&fb=LCD+televisions&fb=LED+televisions&fb=Smartphones&fps=*&fpl=99.99" }
            };

            Assert.AreEqual(2, priceFacetViewModel.Constraints.Length);

            for (var index = 0; index < priceFacetViewModel.Constraints.Length; index++)
            {
                Assert.AreEqual(expectedPriceValues[index].IsApplied, priceFacetViewModel.Constraints[index].IsApplied);
                Assert.AreEqual(expectedPriceValues[index].IsDisabled, priceFacetViewModel.Constraints[index].IsDisabled);
                Assert.AreEqual(expectedPriceValues[index].Count, priceFacetViewModel.Constraints[index].Count);
                Assert.AreEqual(expectedPriceValues[index].Name, priceFacetViewModel.Constraints[index].Name);
                Assert.AreEqual(expectedPriceValues[index].Url, priceFacetViewModel.Constraints[index].Url);
            }
        }
        public void GetValue_NonValidating_WithArraysInCollection(
                            string name, string value, string index, string expectedAttemptedValue)
        {
            // Arrange
            string[] expectedRawValue = new[] { expectedAttemptedValue };
            NameValueCollection unvalidatedCollection = new NameValueCollection();
            unvalidatedCollection.Add(name, value);

            CultureInfo culture = CultureInfo.GetCultureInfo("fr-FR");
            NameValueCollectionValueProvider valueProvider = 
                    new NameValueCollectionValueProvider(_backingStore, unvalidatedCollection, culture, true);

            // Act
            ValueProviderResult vpResult = valueProvider.GetValue(index, skipValidation: true);
            
            // Asserts
            Assert.NotNull(vpResult);
            Assert.Equal(culture, vpResult.Culture);
            Assert.Equal(expectedRawValue, (string[])vpResult.RawValue);
            Assert.Equal(expectedAttemptedValue, vpResult.AttemptedValue);
        }