Example #1
0
        public void Gets_expected_subset_results_from_database_with_custom_metadata()
        {
            Database.AddStorageModelsToDatabase(StorageModels);

            var ids     = StorageModels.Skip(1).Take(3).Select(m => m.Model.Id);
            var getTask = Database.StorageModelQueries.GetManyAsync(m => ids.Contains(m.Model.Id));

            getTask.Wait();

            var results = getTask.Result.ToList();

            AssertResults.Match(results, StorageModels.Skip(1).Take(3).ToList());
        }
Example #2
0
        public void Gets_expected_subset_results_from_database_with_custom_metadata()
        {
            Database.AddStorageModelsToDatabase(StorageModels);

            var ids     = StorageModels.Skip(1).Take(3).Select(m => m.Model.Id);
            var getTask = Database.StorageModelQueries.ProjectManyAsync(
                m => ids.Contains(m.Model.Id),
                sm => new { sm.Model.Name, sm.Metadata.FirstName, sm.Metadata.LastName });

            getTask.Wait();

            var results = getTask.Result.ToList();

            foreach (var storageModel in StorageModels.Skip(1).Take(3))
            {
                var result = results.Single(m => m.Name == storageModel.Model.Name);
                result.FirstName.Should().Be(storageModel.Metadata.FirstName);
                result.LastName.Should().Be(storageModel.Metadata.LastName);
            }
        }
        public void Removes_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 mergeTask = Database.StorageModelCommands.MergeCompleteSetAsync(models);

            mergeTask.Wait();

            var getTask = Database.StorageModelQueries.GetManyAsync(m => !models.Keys.Contains(m.Model.Id));

            getTask.Wait();

            getTask.Result.Should().BeEmpty();
        }
        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());
        }
Example #5
0
        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());
        }