public async Task add_entry_to_index_that_is_in_conflict_throws_exception_if_exception_enabled() { var customer = new Customer { Email = "*****@*****.**", FirstName = "Bill", LastName = "Gates", Id = "2000" }; var index = new TrieSearch <Customer>("trieUnitTestsConflictTest", "UseDevelopmentStorage=true", c => c.Id, options: new TrieSearchOptions { ThrowOnConflict = true }); bool exceptionThrown = false; try { await index.IndexAsync(customer, "Gates"); await index.IndexAsync(customer, "Gates"); } catch (Exception ex) { exceptionThrown = true; } finally { await index.DropIndexAsync(); } Assert.IsTrue(exceptionThrown); }
public async Task add_entry_to_index_beyond_maximum_length_throws_exception_if_exceptions_enabled() { var customer = new Customer { Email = "*****@*****.**", FirstName = "Bill", LastName = "Gates", Id = "2000" }; var index = new TrieSearch <Customer>("trieUnitTestsMaxLenTest", "UseDevelopmentStorage=true", c => c.Id, options: new TrieSearchOptions { MaximumIndexLength = 3, ThrowOnMaximumIndexLengthExceeded = true }); bool exceptionThrown = false; try { await index.IndexAsync(customer, "Gates"); } catch (ArgumentException ex) { exceptionThrown = true; } finally { await index.DropIndexAsync(); } Assert.IsTrue(exceptionThrown); }
public async Task add_entry_to_index_beyond_maximum_length_does_not_get_indexed_beyond_maximum_if_exceptions_are_disabled() { var customer = new Customer { Email = "*****@*****.**", FirstName = "Bill", LastName = "Gates", Id = "2000" }; var index = new TrieSearch <Customer>("trieUnitTestsMaxLenTest", "UseDevelopmentStorage=true", c => c.Id, options: new TrieSearchOptions { MaximumIndexLength = 3 }); try { await index.IndexAsync(customer, "Gates"); var results = await index.FindAsync("gat"); Assert.AreEqual(1, results.Count()); results = await index.FindAsync("gates"); Assert.AreEqual(0, results.Count()); } finally { await index.DropIndexAsync(); } }
public async Task add_entry_to_index_throws_exception_when_minumum_not_met_and_exceptions_are_enabled() { var customer = new Customer { Email = "*****@*****.**", FirstName = "Bill", LastName = "Gates", Id = "2000" }; var failIndex = new TrieSearch <Customer>("trieUnitTestsFailTest", "UseDevelopmentStorage=true", c => c.Id, options: new TrieSearchOptions { ThrowOnMinimumIndexLengthNotMet = true, MinimumIndexLength = 3 }); bool exceptionThrown = false; try { await failIndex.IndexAsync(customer, "b"); } catch (ArgumentException e) { exceptionThrown = true; } finally { await failIndex.DropIndexAsync(); } Assert.IsTrue(exceptionThrown); }
public async Task add_entry_to_index_succeeds() { var customer = new Customer { Email = "*****@*****.**", FirstName = "Bill", LastName = "Gates", Id = "2000" }; await _fullNameIndex.IndexAsync(customer, "Bill Gates"); var results = await _fullNameIndex.FindAsync("Bill"); Assert.AreEqual(1, results.Count()); Assert.IsTrue(results.Any(c => c.Id == "2000")); }
public async Task add_entry_to_index_fails_silently_when_minimum_length_not_met_and_exceptions_are_disabled() { var customer = new Customer { Email = "*****@*****.**", FirstName = "Bill", LastName = "Gates", Id = "2000" }; await _emailIndex.IndexAsync(customer, "b"); var results = await _fullNameIndex.FindAsync("Bill"); Assert.AreEqual(0, results.Count()); }