public void DeleteItemFromCacheById_Id_ItemIsNoLongerInResultSet() { PalasoTestItem itemToDelete = dataMapper.CreateItem(); itemToDelete.StoredString = "Item 6"; dataMapper.SaveItem(itemToDelete); //_results = dataMapper.GetItemsMatching(_queryToCache); ResultSetCache <PalasoTestItem> resultSetCacheUnderTest = new ResultSetCache <PalasoTestItem>(dataMapper, _sortDefinitions, _results, _queryToCache); QueryAdapter <PalasoTestItem> secondQueryToCache = new QueryAdapter <PalasoTestItem>(); secondQueryToCache.In("Child").Show("StoredString"); ResultSet <PalasoTestItem> results = dataMapper.GetItemsMatching(secondQueryToCache); resultSetCacheUnderTest.Add(results, secondQueryToCache); resultSetCacheUnderTest.DeleteItemFromCache(itemToDelete); //Would be a better test but ResultSets don't support equality checks //Assert.AreEqual(resultsBeforeUpdate, resultsAfterUpdate); Assert.AreEqual(6, resultSetCacheUnderTest.GetResultSet().Count); Assert.AreEqual("Item 0", resultSetCacheUnderTest.GetResultSet()[0]["StoredString"]); Assert.AreEqual("Item 1", resultSetCacheUnderTest.GetResultSet()[1]["StoredString"]); Assert.AreEqual("Item 2", resultSetCacheUnderTest.GetResultSet()[2]["StoredString"]); Assert.AreEqual("Item 3", resultSetCacheUnderTest.GetResultSet()[3]["StoredString"]); Assert.AreEqual("Item 4", resultSetCacheUnderTest.GetResultSet()[4]["StoredString"]); Assert.AreEqual("Item 5", resultSetCacheUnderTest.GetResultSet()[5]["StoredString"]); }
public void UpdateItemInCache_ItemExists_ResultSetIsUpdatedAndSorted() { PalasoTestItem itemToModify = dataMapper.CreateItem(); itemToModify.StoredString = "Item 6"; dataMapper.SaveItem(itemToModify); ResultSetCache <PalasoTestItem> resultSetCacheUnderTest = new ResultSetCache <PalasoTestItem>(dataMapper, _sortDefinitions, _results, _queryToCache); QueryAdapter <PalasoTestItem> secondQueryToCache = new QueryAdapter <PalasoTestItem>(); secondQueryToCache.In("Child").Show("StoredString"); ResultSet <PalasoTestItem> results = dataMapper.GetItemsMatching(secondQueryToCache); resultSetCacheUnderTest.Add(results, secondQueryToCache); itemToModify.StoredString = "Item 7"; dataMapper.SaveItem(itemToModify); resultSetCacheUnderTest.UpdateItemInCache(itemToModify); Assert.AreEqual(8, resultSetCacheUnderTest.GetResultSet().Count); Assert.AreEqual(null, resultSetCacheUnderTest.GetResultSet()[0]["StoredString"]); Assert.AreEqual("Item 0", resultSetCacheUnderTest.GetResultSet()[1]["StoredString"]); Assert.AreEqual("Item 1", resultSetCacheUnderTest.GetResultSet()[2]["StoredString"]); Assert.AreEqual("Item 2", resultSetCacheUnderTest.GetResultSet()[3]["StoredString"]); Assert.AreEqual("Item 3", resultSetCacheUnderTest.GetResultSet()[4]["StoredString"]); Assert.AreEqual("Item 4", resultSetCacheUnderTest.GetResultSet()[5]["StoredString"]); Assert.AreEqual("Item 5", resultSetCacheUnderTest.GetResultSet()[6]["StoredString"]); Assert.AreEqual("Item 7", resultSetCacheUnderTest.GetResultSet()[7]["StoredString"]); }
public void UpdateItemInCache_ItemHasNotChanged_ResultSetIsNotChanged() { PalasoTestItem unmodifiedItem = dataMapper.CreateItem(); unmodifiedItem.StoredString = "Item 6"; dataMapper.SaveItem(unmodifiedItem); //_results = dataMapper.GetItemsMatching(_queryToCache); ResultSetCache <PalasoTestItem> resultSetCacheUnderTest = new ResultSetCache <PalasoTestItem>(dataMapper, _sortDefinitions, _results, _queryToCache); QueryAdapter <PalasoTestItem> secondQueryToCache = new QueryAdapter <PalasoTestItem>(); secondQueryToCache.In("Child").Show("StoredString"); ResultSet <PalasoTestItem> results = dataMapper.GetItemsMatching(secondQueryToCache); resultSetCacheUnderTest.Add(results, secondQueryToCache); resultSetCacheUnderTest.UpdateItemInCache(unmodifiedItem); //Would be a better test but ResultSets don't support equality checks //Assert.AreEqual(resultsBeforeUpdate, resultsAfterUpdate); Assert.AreEqual(8, resultSetCacheUnderTest.GetResultSet().Count); Assert.AreEqual(null, resultSetCacheUnderTest.GetResultSet()[0]["StoredString"]); Assert.AreEqual("Item 0", resultSetCacheUnderTest.GetResultSet()[1]["StoredString"]); Assert.AreEqual("Item 1", resultSetCacheUnderTest.GetResultSet()[2]["StoredString"]); Assert.AreEqual("Item 2", resultSetCacheUnderTest.GetResultSet()[3]["StoredString"]); Assert.AreEqual("Item 3", resultSetCacheUnderTest.GetResultSet()[4]["StoredString"]); Assert.AreEqual("Item 4", resultSetCacheUnderTest.GetResultSet()[5]["StoredString"]); Assert.AreEqual("Item 5", resultSetCacheUnderTest.GetResultSet()[6]["StoredString"]); Assert.AreEqual("Item 6", resultSetCacheUnderTest.GetResultSet()[7]["StoredString"]); }
public void MultipleQueries_QueriedFieldsAreIdentical_ReturnsOnlyOneRecordToken() { ResultSetCache <PalasoTestItem> resultSetCacheUnderTest = new ResultSetCache <PalasoTestItem>(dataMapper, _sortDefinitions, _results, _queryToCache); QueryAdapter <PalasoTestItem> secondQueryToCache = new QueryAdapter <PalasoTestItem>(); secondQueryToCache.In("Child").Show("StoredString"); ResultSet <PalasoTestItem> results = dataMapper.GetItemsMatching(secondQueryToCache); resultSetCacheUnderTest.Add(results, secondQueryToCache); PalasoTestItem itemCreatedAfterCache = dataMapper.CreateItem(); itemCreatedAfterCache.StoredString = "Item 6"; itemCreatedAfterCache.Child.StoredString = "Item 6"; dataMapper.SaveItem(itemCreatedAfterCache); resultSetCacheUnderTest.UpdateItemInCache(itemCreatedAfterCache); Assert.AreEqual(7, resultSetCacheUnderTest.GetResultSet().Count); Assert.AreEqual("Item 0", resultSetCacheUnderTest.GetResultSet()[0]["StoredString"]); Assert.AreEqual("Item 1", resultSetCacheUnderTest.GetResultSet()[1]["StoredString"]); Assert.AreEqual("Item 2", resultSetCacheUnderTest.GetResultSet()[2]["StoredString"]); Assert.AreEqual("Item 3", resultSetCacheUnderTest.GetResultSet()[3]["StoredString"]); Assert.AreEqual("Item 4", resultSetCacheUnderTest.GetResultSet()[4]["StoredString"]); Assert.AreEqual("Item 5", resultSetCacheUnderTest.GetResultSet()[5]["StoredString"]); Assert.AreEqual("Item 6", resultSetCacheUnderTest.GetResultSet()[6]["StoredString"]); }
public void UpdateItemInCache_ItemDoesNotExistInCacheButDoesInRepository_ItemIsAddedToResultSetAndSortedCorrectly() { ResultSetCache <PalasoTestItem> resultSetCacheUnderTest = new ResultSetCache <PalasoTestItem>(dataMapper, _sortDefinitions, _results, _queryToCache); QueryAdapter <PalasoTestItem> secondQueryToCache = new QueryAdapter <PalasoTestItem>(); secondQueryToCache.In("Child").Show("StoredString"); ResultSet <PalasoTestItem> results = dataMapper.GetItemsMatching(secondQueryToCache); resultSetCacheUnderTest.Add(results, secondQueryToCache); PalasoTestItem itemCreatedAfterCache = dataMapper.CreateItem(); itemCreatedAfterCache.StoredString = "Item 6"; dataMapper.SaveItem(itemCreatedAfterCache); resultSetCacheUnderTest.UpdateItemInCache(itemCreatedAfterCache); Assert.AreEqual(8, resultSetCacheUnderTest.GetResultSet().Count); Assert.AreEqual(null, resultSetCacheUnderTest.GetResultSet()[0]["StoredString"]); Assert.AreEqual("Item 0", resultSetCacheUnderTest.GetResultSet()[1]["StoredString"]); Assert.AreEqual("Item 1", resultSetCacheUnderTest.GetResultSet()[2]["StoredString"]); Assert.AreEqual("Item 2", resultSetCacheUnderTest.GetResultSet()[3]["StoredString"]); Assert.AreEqual("Item 3", resultSetCacheUnderTest.GetResultSet()[4]["StoredString"]); Assert.AreEqual("Item 4", resultSetCacheUnderTest.GetResultSet()[5]["StoredString"]); Assert.AreEqual("Item 5", resultSetCacheUnderTest.GetResultSet()[6]["StoredString"]); Assert.AreEqual("Item 6", resultSetCacheUnderTest.GetResultSet()[7]["StoredString"]); }
private QueryBase GetQueryFilter( ListFilter listFilter ) => QueryAdapter .CreateQuerySelect( GetTableName() , listFilter );
private QueryBase GetQueryKey( object keyValue ) => QueryAdapter .CreateQueryGet( GetTableName() , GetPrimaryKey() , keyValue );
private QueryBase GetQueryFilter( ListFilter listFilter , OrderList orderList ) => QueryAdapter .CreateQuerySelect( GetTableName() , listFilter , orderList );
public void Setup() { _repository = new MemoryRepository<TestItem>(); PopulateRepositoryWithItemsForQuerying(_repository); _queryToCache = new QueryAdapter<TestItem>(); _queryToCache.Show("StoredString"); _results = _repository.GetItemsMatching(_queryToCache); _sortDefinitions = new SortDefinition[1]; _sortDefinitions[0] = new SortDefinition("StoredString", Comparer<string>.Default); }
public void Setup() { dataMapper = new MemoryDataMapper <PalasoTestItem>(); PopulateRepositoryWithItemsForQuerying(dataMapper); _queryToCache = new QueryAdapter <PalasoTestItem>(); _queryToCache.ShowEach("StoredList"); _results = dataMapper.GetItemsMatching(_queryToCache); _sortDefinitions = new SortDefinition[1]; _sortDefinitions[0] = new SortDefinition("StoredList", Comparer <string> .Default); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); SqlResult sqlResult = QueryAdapter.GetSql("Audits").Where("TableName", "Test").Compile(); var a = MonoFrame.DataBase.DataAccess.Query(sqlResult); Console.ReadLine(); }
public void Add_QueryNull_Throws() { ResultSetCache <PalasoTestItem> resultSetCacheUnderTest = new ResultSetCache <PalasoTestItem>(dataMapper, _sortDefinitions, _results, _queryToCache); QueryAdapter <PalasoTestItem> secondQueryToCache = new QueryAdapter <PalasoTestItem>(); secondQueryToCache.In("Child").Show("StoredString"); ResultSet <PalasoTestItem> results = dataMapper.GetItemsMatching(secondQueryToCache); Assert.Throws <ArgumentNullException>(() => resultSetCacheUnderTest.Add(results, null)); }
public int Delete(object keyValue) { var keyName = GetPrimaryKey(); var q = QueryAdapter .CreateQueryDelete( GetTableName() , keyName ); q.Parameters.Add(keyName, keyValue); return(QueryAdapter.Execute(q)); }
public void DeleteAllItemsFromCache_AllItemsAreDeleted() { ResultSetCache <PalasoTestItem> resultSetCacheUnderTest = new ResultSetCache <PalasoTestItem>(dataMapper, _sortDefinitions, _results, _queryToCache); QueryAdapter <PalasoTestItem> secondQueryToCache = new QueryAdapter <PalasoTestItem>(); secondQueryToCache.In("Child").Show("StoredString"); ResultSet <PalasoTestItem> results = dataMapper.GetItemsMatching(secondQueryToCache); resultSetCacheUnderTest.Add(results, secondQueryToCache); resultSetCacheUnderTest.DeleteAllItemsFromCache(); Assert.AreEqual(0, resultSetCacheUnderTest.GetResultSet().Count); }
public IEnumerable <WeatherForecast> Get() { SqlResult sqlResult = QueryAdapter.GetSql("Audits").Where("TableName", "Test").Compile(); var a = ITGalax.DataBase.DataAccess.Query(sqlResult); var rng = new Random(); return(Enumerable.Range(1, 5).Select(index => new WeatherForecast { Date = DateTime.Now.AddDays(index), TemperatureC = rng.Next(-20, 55), Summary = Summaries[rng.Next(Summaries.Length)] }) .ToArray()); }
public List <Factura> Select(DateTime fecha) { var dr = QueryAdapter .GetDataReader( new SqlQuery( @" SELECT * FROM Facturas F WHERE F.Fecha = @fecha ; SELECT DF.* FROM Facturas F INNER JOIN DetalleFactura DF ON F.IdFactura = DF.IdFactura WHERE F.Fecha = @fecha ; " , new SqlParameterList { { "fecha", fecha } } ) ); var l = GetEnumerable(dr, false) .ToList(); dr.NextResult(); var ld = GetEnumerable <DetalleFactura>(dr) .ToList(); l.ForEach( f => f.ListaDetalle = ld.Where( d => d.IdFactura == f.IdFactura ) .ToList() ); ld = null; return(l); }
public void GetResultsOnQuery_AtLeastOneWithShow_OneItem() { // In the query below AtLeastOne and Show are siblings, // both are children of 'all'. QueryAdapter <PalasoTestItem> all = new QueryAdapter <PalasoTestItem>(); all.AtLeastOne().Show("StoredString"); List <IDictionary <string, object> > results = new List <IDictionary <string, object> > ( all.GetResults(item) ); Assert.IsNotNull(results); Assert.AreEqual(1, results.Count); Assert.AreEqual(null, results[0]["StoredString"]); }
public List <Cliente> Select(int idZona, int desde, int hasta) { var dr = QueryAdapter.GetDataReader( new SqlQuery( @" SELECT C.* FROM Clientes C WHERE C.IdAreaResponsabilidad = @idZona AND C.Estatus = 1 ; SELECT K.* FROM Clientes C INNER JOIN Consumos K ON C.IdCliente = K.IdCliente AND K.Mes >= @desde AND K.Mes <= @hasta WHERE C.IdAreaResponsabilidad = @idZona AND C.Estatus = 1 ; " , new SqlParameterList { { "idZona", idZona } , { "desde", desde } , { "hasta", hasta } } ) ); var lista = GetEnumerable(dr, false).ToList(); dr.NextResult(); var sublista = GetEnumerable <Consumo>(dr).ToList(); //foreach (var i in lista) //{ // i.Consumos = // sublista // .Where(c => c.IdCliente == i.IdCliente) // .ToList(); //} sublista = null; return(lista); }
public void ResultSetContainsIdenticalRecordTokens_Throws() { PalasoTestItem itemFromWhichToCreateIdenticalRecordTokens = dataMapper.CreateItem(); itemFromWhichToCreateIdenticalRecordTokens.StoredString = "Get me twice!"; QueryAdapter <PalasoTestItem> query1 = new QueryAdapter <PalasoTestItem>(); query1.Show("StoredString"); QueryAdapter <PalasoTestItem> query2 = new QueryAdapter <PalasoTestItem>(); query2.Show("StoredString"); ResultSetCache <PalasoTestItem> resultSetCacheUnderTest = new ResultSetCache <PalasoTestItem>(dataMapper, _sortDefinitions); resultSetCacheUnderTest.Add(dataMapper.GetItemsMatching(query1), query1); Assert.Throws <ArgumentException>(() => resultSetCacheUnderTest.Add(dataMapper.GetItemsMatching(query2), query2)); }
protected T GetEntity( QueryBase query ) { var dr = QueryAdapter .GetDataReader( query ); T e = null; if (dr.Read()) { e = GetEntity <T>(dr); } dr.Close(); return(e); }
public int Insert( T entity ) { var fields = entity .GetFields() .Where(p => !p.IsIdentity) .ToList(); return (QueryAdapter .Execute( QueryAdapter .CreateQueryInsert( GetTableName() , fields ) )); }
public int Update( T row , IDbTransaction transaction ) { var fields = row .GetFields() .ToList(); return (QueryAdapter .Execute( QueryAdapter .CreateQueryUpdate( GetTableName() , fields , transaction ) )); }
public IEnumerable <T> SelectAll( ) => GetEnumerable( QueryAdapter.CreateQuerySelect(GetTableName()) );
public void ResultSetContainsIdenticalRecordTokens_Throws() { TestItem itemFromWhichToCreateIdenticalRecordTokens = _repository.CreateItem(); itemFromWhichToCreateIdenticalRecordTokens.StoredString = "Get me twice!"; QueryAdapter<TestItem> query1 = new QueryAdapter<TestItem>(); query1.Show("StoredString"); QueryAdapter<TestItem> query2 = new QueryAdapter<TestItem>(); query2.Show("StoredString"); ResultSetCache<TestItem> resultSetCacheUnderTest = new ResultSetCache<TestItem>(_repository, _sortDefinitions); resultSetCacheUnderTest.Add(_repository.GetItemsMatching(query1), query1); resultSetCacheUnderTest.Add(_repository.GetItemsMatching(query2), query2); }
public void DeleteAllItemsFromCache_AllItemsAreDeleted() { ResultSetCache<TestItem> resultSetCacheUnderTest = new ResultSetCache<TestItem>(_repository, _sortDefinitions, _results, _queryToCache); QueryAdapter<TestItem> secondQueryToCache = new QueryAdapter<TestItem>(); secondQueryToCache.In("Child").Show("StoredString"); ResultSet<TestItem> results = _repository.GetItemsMatching(secondQueryToCache); resultSetCacheUnderTest.Add(results, secondQueryToCache); resultSetCacheUnderTest.DeleteAllItemsFromCache(); Assert.AreEqual(0, resultSetCacheUnderTest.GetResultSet().Count); }
public void DeleteItemFromCacheById_Id_ItemIsNoLongerInResultSet() { TestItem itemToDelete = _repository.CreateItem(); itemToDelete.StoredString = "Item 6"; _repository.SaveItem(itemToDelete); //_results = _repository.GetItemsMatching(_queryToCache); ResultSetCache<TestItem> resultSetCacheUnderTest = new ResultSetCache<TestItem>(_repository, _sortDefinitions, _results, _queryToCache); QueryAdapter<TestItem> secondQueryToCache = new QueryAdapter<TestItem>(); secondQueryToCache.In("Child").Show("StoredString"); ResultSet<TestItem> results = _repository.GetItemsMatching(secondQueryToCache); resultSetCacheUnderTest.Add(results, secondQueryToCache); resultSetCacheUnderTest.DeleteItemFromCache(itemToDelete); //Would be a better test but ResultSets don't support equality checks //Assert.AreEqual(resultsBeforeUpdate, resultsAfterUpdate); Assert.AreEqual(6, resultSetCacheUnderTest.GetResultSet().Count); Assert.AreEqual("Item 0", resultSetCacheUnderTest.GetResultSet()[0]["StoredString"]); Assert.AreEqual("Item 1", resultSetCacheUnderTest.GetResultSet()[1]["StoredString"]); Assert.AreEqual("Item 2", resultSetCacheUnderTest.GetResultSet()[2]["StoredString"]); Assert.AreEqual("Item 3", resultSetCacheUnderTest.GetResultSet()[3]["StoredString"]); Assert.AreEqual("Item 4", resultSetCacheUnderTest.GetResultSet()[4]["StoredString"]); Assert.AreEqual("Item 5", resultSetCacheUnderTest.GetResultSet()[5]["StoredString"]); }
public void UpdateItemInCache_ItemHasNotChanged_ResultSetIsNotChanged() { TestItem unmodifiedItem = _repository.CreateItem(); unmodifiedItem.StoredString = "Item 6"; _repository.SaveItem(unmodifiedItem); //_results = _repository.GetItemsMatching(_queryToCache); ResultSetCache<TestItem> resultSetCacheUnderTest = new ResultSetCache<TestItem>(_repository, _sortDefinitions, _results, _queryToCache); QueryAdapter<TestItem> secondQueryToCache = new QueryAdapter<TestItem>(); secondQueryToCache.In("Child").Show("StoredString"); ResultSet<TestItem> results = _repository.GetItemsMatching(secondQueryToCache); resultSetCacheUnderTest.Add(results, secondQueryToCache); resultSetCacheUnderTest.UpdateItemInCache(unmodifiedItem); //Would be a better test but ResultSets don't support equality checks //Assert.AreEqual(resultsBeforeUpdate, resultsAfterUpdate); Assert.AreEqual(8, resultSetCacheUnderTest.GetResultSet().Count); Assert.AreEqual(null, resultSetCacheUnderTest.GetResultSet()[0]["StoredString"]); Assert.AreEqual("Item 0", resultSetCacheUnderTest.GetResultSet()[1]["StoredString"]); Assert.AreEqual("Item 1", resultSetCacheUnderTest.GetResultSet()[2]["StoredString"]); Assert.AreEqual("Item 2", resultSetCacheUnderTest.GetResultSet()[3]["StoredString"]); Assert.AreEqual("Item 3", resultSetCacheUnderTest.GetResultSet()[4]["StoredString"]); Assert.AreEqual("Item 4", resultSetCacheUnderTest.GetResultSet()[5]["StoredString"]); Assert.AreEqual("Item 5", resultSetCacheUnderTest.GetResultSet()[6]["StoredString"]); Assert.AreEqual("Item 6", resultSetCacheUnderTest.GetResultSet()[7]["StoredString"]); }
public void UpdateItemInCache_ItemExists_ResultSetIsUpdatedAndSorted() { TestItem itemToModify = _repository.CreateItem(); itemToModify.StoredString = "Item 6"; _repository.SaveItem(itemToModify); ResultSetCache<TestItem> resultSetCacheUnderTest = new ResultSetCache<TestItem>(_repository, _sortDefinitions, _results, _queryToCache); QueryAdapter<TestItem> secondQueryToCache = new QueryAdapter<TestItem>(); secondQueryToCache.In("Child").Show("StoredString"); ResultSet<TestItem> results = _repository.GetItemsMatching(secondQueryToCache); resultSetCacheUnderTest.Add(results, secondQueryToCache); itemToModify.StoredString = "Item 7"; _repository.SaveItem(itemToModify); resultSetCacheUnderTest.UpdateItemInCache(itemToModify); Assert.AreEqual(8, resultSetCacheUnderTest.GetResultSet().Count); Assert.AreEqual(null, resultSetCacheUnderTest.GetResultSet()[0]["StoredString"]); Assert.AreEqual("Item 0", resultSetCacheUnderTest.GetResultSet()[1]["StoredString"]); Assert.AreEqual("Item 1", resultSetCacheUnderTest.GetResultSet()[2]["StoredString"]); Assert.AreEqual("Item 2", resultSetCacheUnderTest.GetResultSet()[3]["StoredString"]); Assert.AreEqual("Item 3", resultSetCacheUnderTest.GetResultSet()[4]["StoredString"]); Assert.AreEqual("Item 4", resultSetCacheUnderTest.GetResultSet()[5]["StoredString"]); Assert.AreEqual("Item 5", resultSetCacheUnderTest.GetResultSet()[6]["StoredString"]); Assert.AreEqual("Item 7", resultSetCacheUnderTest.GetResultSet()[7]["StoredString"]); }
public void UpdateItemInCache_ItemDoesNotExistInCacheButDoesInRepository_ItemIsAddedToResultSetAndSortedCorrectly() { ResultSetCache<TestItem> resultSetCacheUnderTest = new ResultSetCache<TestItem>(_repository, _sortDefinitions, _results, _queryToCache); QueryAdapter<TestItem> secondQueryToCache = new QueryAdapter<TestItem>(); secondQueryToCache.In("Child").Show("StoredString"); ResultSet<TestItem> results = _repository.GetItemsMatching(secondQueryToCache); resultSetCacheUnderTest.Add(results, secondQueryToCache); TestItem itemCreatedAfterCache = _repository.CreateItem(); itemCreatedAfterCache.StoredString = "Item 6"; _repository.SaveItem(itemCreatedAfterCache); resultSetCacheUnderTest.UpdateItemInCache(itemCreatedAfterCache); Assert.AreEqual(8, resultSetCacheUnderTest.GetResultSet().Count); Assert.AreEqual(null, resultSetCacheUnderTest.GetResultSet()[0]["StoredString"]); Assert.AreEqual("Item 0", resultSetCacheUnderTest.GetResultSet()[1]["StoredString"]); Assert.AreEqual("Item 1", resultSetCacheUnderTest.GetResultSet()[2]["StoredString"]); Assert.AreEqual("Item 2", resultSetCacheUnderTest.GetResultSet()[3]["StoredString"]); Assert.AreEqual("Item 3", resultSetCacheUnderTest.GetResultSet()[4]["StoredString"]); Assert.AreEqual("Item 4", resultSetCacheUnderTest.GetResultSet()[5]["StoredString"]); Assert.AreEqual("Item 5", resultSetCacheUnderTest.GetResultSet()[6]["StoredString"]); Assert.AreEqual("Item 6", resultSetCacheUnderTest.GetResultSet()[7]["StoredString"]); }
public void MultipleQueries_QueriedFieldsAreIdentical_ReturnsOnlyOneRecordToken() { ResultSetCache<TestItem> resultSetCacheUnderTest = new ResultSetCache<TestItem>(_repository, _sortDefinitions, _results, _queryToCache); QueryAdapter<TestItem> secondQueryToCache = new QueryAdapter<TestItem>(); secondQueryToCache.In("Child").Show("StoredString"); ResultSet<TestItem> results = _repository.GetItemsMatching(secondQueryToCache); resultSetCacheUnderTest.Add(results, secondQueryToCache); TestItem itemCreatedAfterCache = _repository.CreateItem(); itemCreatedAfterCache.StoredString = "Item 6"; itemCreatedAfterCache.Child.StoredString = "Item 6"; _repository.SaveItem(itemCreatedAfterCache); resultSetCacheUnderTest.UpdateItemInCache(itemCreatedAfterCache); Assert.AreEqual(7, resultSetCacheUnderTest.GetResultSet().Count); Assert.AreEqual("Item 0", resultSetCacheUnderTest.GetResultSet()[0]["StoredString"]); Assert.AreEqual("Item 1", resultSetCacheUnderTest.GetResultSet()[1]["StoredString"]); Assert.AreEqual("Item 2", resultSetCacheUnderTest.GetResultSet()[2]["StoredString"]); Assert.AreEqual("Item 3", resultSetCacheUnderTest.GetResultSet()[3]["StoredString"]); Assert.AreEqual("Item 4", resultSetCacheUnderTest.GetResultSet()[4]["StoredString"]); Assert.AreEqual("Item 5", resultSetCacheUnderTest.GetResultSet()[5]["StoredString"]); Assert.AreEqual("Item 6", resultSetCacheUnderTest.GetResultSet()[6]["StoredString"]); }
public void Add_QueryNull_Throws() { ResultSetCache<TestItem> resultSetCacheUnderTest = new ResultSetCache<TestItem>(_repository, _sortDefinitions, _results, _queryToCache); QueryAdapter<TestItem> secondQueryToCache = new QueryAdapter<TestItem>(); secondQueryToCache.In("Child").Show("StoredString"); ResultSet<TestItem> results = _repository.GetItemsMatching(secondQueryToCache); resultSetCacheUnderTest.Add(results, null); }
protected IEnumerable <T> GetEnumerable( QueryBase query ) => GetEnumerable <T>( QueryAdapter.GetDataReader(query) );
public void BulkInsert( IEnumerable <BulkCliente> listaClientes ) { QueryAdapter.BulkCopy(listaClientes.ToDataTable(), "Test", 1); }