public void Removes_expected_result_from_database_with_custom_metadata() { Database.AddStorageModelsToDatabase(StorageModels); var removeTask = Database.StorageModelCommands.RemoveOneAsync(StorageModels[1].Model); removeTask.Wait(); var getTask = Database.StorageModelQueries.GetAllAsync(); getTask.Wait(); var results = getTask.Result.ToList(); AssertResults.Match(results, StorageModels.Where(m => m.Model.Id != StorageModels[1].Model.Id).ToList()); }
public void Does_not_overwrite_other_records_with_custom_metadata() { Database.AddStorageModelsToDatabase(StorageModels); var updatedModel = StorageModels[1]; updatedModel.Model.Name = "Updated name"; updatedModel.Metadata.FirstName = "Updated first name"; updatedModel.Metadata.LastName = "Updated last name"; var updateTask = Database.StorageModelCommands.UpdateOneAsync(updatedModel.Model, updatedModel.Metadata); updateTask.Wait(); var getTask = Database.StorageModelQueries.GetManyAsync(m => m.Model.Id != updatedModel.Model.Id); getTask.Wait(); var results = getTask.Result.ToList(); AssertResults.Match(results, StorageModels.Where(m => m.Model.Id != updatedModel.Model.Id).ToList()); }
public void Updates_each_when_models_exist_in_database_with_custom_metadata() { Database.AddStorageModelsToDatabase(StorageModels); StorageModels[1].Model.Name = "Updated name 1"; StorageModels[1].Metadata.FirstName = "Updated first name 1"; StorageModels[1].Metadata.LastName = "Updated last name 1"; StorageModels[2].Model.Name = "Updated name 2"; StorageModels[2].Metadata.FirstName = "Updated first name 2"; StorageModels[2].Metadata.LastName = "Updated last name 2"; var models = StorageModels.Skip(1).Take(2).ToDictionary(m => m.Model.Id, m => m); var updateTask = Database.StorageModelCommands.UpdateManyAsync(models); updateTask.Wait(); var getTask = Database.StorageModelQueries.GetManyAsync(m => models.Keys.Contains(m.Model.Id)); getTask.Wait(); var results = getTask.Result.ToList(); AssertResults.Match(results, StorageModels.Where(m => models.Keys.Contains(m.Model.Id)).ToList()); }
public void Does_not_overwrite_other_records_with_custom_metadata() { Database.AddStorageModelsToDatabase(StorageModels); StorageModels[1].Model.Name = "Updated name 1"; StorageModels[1].Metadata.FirstName = "Updated first name 1"; StorageModels[1].Metadata.LastName = "Updated last name 1"; StorageModels[2].Model.Name = "Updated name 2"; StorageModels[2].Metadata.FirstName = "Updated first name 2"; StorageModels[2].Metadata.LastName = "Updated last name 2"; var models = StorageModels.Skip(1).Take(2).ToDictionary(m => m.Model.Id, m => m); var addOrUpdateTask = Database.StorageModelCommands.AddOrUpdateManyAsync(models); addOrUpdateTask.Wait(); var getTask = Database.StorageModelQueries.GetManyAsync(m => !models.Keys.Contains(m.Model.Id)); getTask.Wait(); var results = getTask.Result.ToList(); AssertResults.Match(results, StorageModels.Where(m => !models.Keys.Contains(m.Model.Id)).ToList()); }