public void TestInitialize()
 {
     var testApiKey = Environment.GetEnvironmentVariable("ALGOLIA_API_KEY");
     var testApplicationID = Environment.GetEnvironmentVariable("ALGOLIA_APPLICATION_ID");
     _client = new AlgoliaClient(testApplicationID, testApiKey);
     _indexHelper = new IndexHelper<TestModel>(_client, GetSafeName("àlgol?à-csharp"));
 }
 public void TestInitialize()
 {
     _testApiKey = Environment.GetEnvironmentVariable("ALGOLIA_API_KEY");
     _testApplicationID = Environment.GetEnvironmentVariable("ALGOLIA_APPLICATION_ID");
     _client = new AlgoliaClient(_testApplicationID, _testApiKey);
     _index = _client.InitIndex(safe_name("àlgol?à-csharp"));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Create a new IndexHelper.
 /// </summary>
 /// <param name="client">The AlgoliaClient to use for index management.</param>
 /// <param name="indexName">The name of the Algolia index.</param>
 /// <param name="objectIdField">The name of the field to use for mapping to the Algolia objectID.</param>
 public IndexHelper(AlgoliaClient client, string indexName, string objectIdField = "Id")
     : base(client, indexName)
 {
     // Save
     _client        = client;
     _indexName     = indexName;
     _objectIdField = objectIdField;
 }
Ejemplo n.º 4
0
        public MainPage()
        {
            this.InitializeComponent();

            this.NavigationCacheMode = NavigationCacheMode.Required;

            algoliaClient = new AlgoliaClient("<APPLICATION_ID>", "<SEARCH_ONLY_API_KEY>");
            algoliaIndex = algoliaClient.InitIndex("packages");
        }
 public void BadClientCreation()
 {
     string[] _hosts = new string[] { "localhost.algolia.com:8080", "" };
     try
     {
         new AlgoliaClient("", _testApiKey);
         Assert.Fail();
     }
     catch (Exception)
     { }
     try
     {
         new AlgoliaClient(_testApplicationID, "");
         Assert.Fail();
     }
     catch (Exception)
     { }
     try
     {
         new AlgoliaClient(_testApplicationID, "", _hosts);
         Assert.Fail();
     }
     catch (Exception)
     { }
     try
     {
         new AlgoliaClient("", _testApiKey, _hosts);
         Assert.Fail();
     }
     catch (Exception)
     { }
     try
     {
         var badClient = new AlgoliaClient(_testApplicationID, _testApiKey, null);
         Assert.Fail();
     }
     catch (Exception)
     { }
     try
     {
         var badClient = new AlgoliaClient(_testApplicationID, _testApiKey, _hosts);
         badClient.ListIndexes();
         Assert.Fail();
     }
     catch (Exception)
     { }
 }
Ejemplo n.º 6
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Create our Algolia client
            var algoliaClient = new AlgoliaClient("<APPLICATION_ID>", "<ADMIN_API_KEY>");

            // Create our index helper
            var indexHelper = new IndexHelper<Package>(algoliaClient, "packages", "Id");

            // Store our index helper in an application variable.
            // We don't want to create a new one each time
            // because it will impact performance.
            Application.Add("PackageIndexHelper", indexHelper);
        }
Ejemplo n.º 7
0
 public Analytics(AlgoliaClient client)
 {
     _client = client;
 }
 public void TestCleanup()
 {
     _client.DeleteIndex(safe_name("àlgol?à-csharp"));
     _client = null;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Index initialization (You should not call this constructor yourself).
 /// </summary>
 public Index(AlgoliaClient client, string indexName)
 {
     _client       = client;
     _indexName    = indexName;
     _urlIndexName = Uri.EscapeDataString(indexName);
 }
Ejemplo n.º 10
0
 public void TestClientWithMock()
 {
     var client = new AlgoliaClient("test", "test", null, getEmptyHandler());
     Assert.AreEqual(JObject.Parse("{\"items\":[]}").ToString(), client.ListIndexes().ToString());
     Assert.AreEqual(JObject.Parse("{\"results\":[]}").ToString(), client.InitIndex("{indexName}").GetObjects(new string[] { "myID" }).ToString());
 }