示例#1
0
        protected async Task CreateRecord(T record, string file)
        {
            try
            {
                var args = new[]
                {
                    "Import",
                    $"File={file}"
                };

                TestConfiguration testConfiguration = new TestConfiguration();
                string[]          programArgs       = testConfiguration.BuildArgs(args);
                IOption           option            = testConfiguration.GetOption(args);

                await Program.Main(programArgs);

                IPathFinderStore     store     = new CosmosPathFinderStore(option.Store, _loggerFactory);
                IRecordContainer <T> container = await store.Container.Create <T>();

                Record <T>?read = await container.Get(record.Id);

                read.Should().NotBeNull();
                record.Equals(read !.Value).Should().BeTrue();
            }
            finally
            {
                File.Delete(file);
            }
        }
示例#2
0
        protected async Task TestClearCollection(Func <int, T> createRecord, int count)
        {
            IReadOnlyList <T> list = Enumerable.Range(0, count)
                                     .Select((x, i) => createRecord(i))
                                     .ToArray();

            // Clear records
            var args = new[]
            {
                _entityName,
                "Clear",
            };

            TestConfiguration testConfiguration = new TestConfiguration();
            IOption           option            = testConfiguration.GetOption(args);

            IPathFinderStore     store     = new CosmosPathFinderStore(option.Store, _loggerFactory);
            IRecordContainer <T> container = await store.Container.Create <T>();

            foreach (var record in list)
            {
                await container.Set(record);
            }

            IReadOnlyList <T> readRecords = await container.Search.List(QueryParameters.Default);

            readRecords.Should().NotBeNull();
            readRecords.Count.Should().Be(list.Count);

            // Execute clear
            string[] programArgs = testConfiguration.BuildArgs(args);
            await Program.Main(programArgs);

            // Verify
            IReadOnlyList <T> verifyReadRecords = await container.Search.List(QueryParameters.Default);

            verifyReadRecords.Should().NotBeNull();
            verifyReadRecords.Count.Should().Be(0);
        }
示例#3
0
        protected async Task DeleteRecord(T agentRecord)
        {
            var args = new[]
            {
                _entityName,
                "Delete",
                $"Id={agentRecord.Id}",
            };

            TestConfiguration testConfiguration = new TestConfiguration();

            string[] programArgs = testConfiguration.BuildArgs(args);
            IOption  option      = testConfiguration.GetOption(args);

            await Program.Main(programArgs);

            IPathFinderStore     store     = new CosmosPathFinderStore(option.Store, _loggerFactory);
            IRecordContainer <T> container = await store.Container.Create <T>();

            Record <T>?read = await container.Get(agentRecord.Id);

            read.Should().BeNull();
        }