예제 #1
0
        internal override async Task <IDocumentContainer> CreateDocumentContainerAsync(
            int numItems,
            FlakyDocumentContainer.FailureConfigs failureConfigs = default)
        {
            Documents.PartitionKeyDefinition partitionKeyDefinition = new Documents.PartitionKeyDefinition()
            {
                Paths = new System.Collections.ObjectModel.Collection <string>()
                {
                    "/pk"
                },
                Kind    = Documents.PartitionKind.Hash,
                Version = Documents.PartitionKeyDefinitionVersion.V2,
            };

            IMonadicDocumentContainer monadicDocumentContainer = new InMemoryContainer(partitionKeyDefinition);

            if (failureConfigs != null)
            {
                monadicDocumentContainer = new FlakyDocumentContainer(monadicDocumentContainer, failureConfigs);
            }

            DocumentContainer documentContainer = new DocumentContainer(monadicDocumentContainer);

            for (int i = 0; i < 3; i++)
            {
                IReadOnlyList <FeedRangeInternal> ranges = await documentContainer.GetFeedRangesAsync(
                    trace : NoOpTrace.Singleton,
                    cancellationToken : default);
        internal static IMonadicDocumentContainer CreateMonadicDocumentContainerAsync(FlakyDocumentContainer.FailureConfigs failureConfigs)
        {
            IMonadicDocumentContainer monadicDocumentContainer = new InMemoryContainer(partitionKeyDefinition);

            if (failureConfigs != null)
            {
                monadicDocumentContainer = new FlakyDocumentContainer(monadicDocumentContainer, failureConfigs);
            }

            return(monadicDocumentContainer);
        }
예제 #3
0
        public void WebContentDispatcherRetriveFromPermanetTest()
        {
            ExecuteTest(() => {
                IContentContainer storage      = new InMemoryContainer();
                WebContentDispatcher container = new WebContentDispatcher(storage);

                TestContentType c = TestContentType.getARandomTestContentType(enforce_a_reference: false);
                storage.Add(c);
                Guid guid = c.guid;
                Assert.IsNotNull(container.GetContent <TestContentType>(c.guid));
                container.Dispose();
            });
        }
예제 #4
0
        private static async Task <IDocumentContainer> CreateDocumentContainerAsync(
            IReadOnlyList <CosmosObject> documents,
            FlakyDocumentContainer.FailureConfigs failureConfigs = null)
        {
            IMonadicDocumentContainer monadicDocumentContainer = new InMemoryContainer(partitionKeyDefinition);

            if (failureConfigs != null)
            {
                monadicDocumentContainer = new FlakyDocumentContainer(monadicDocumentContainer, failureConfigs);
            }

            DocumentContainer documentContainer = new DocumentContainer(monadicDocumentContainer);

            await documentContainer.SplitAsync(partitionKeyRangeId : 0, cancellationToken : default);
예제 #5
0
        private static async Task <IDocumentContainer> CreateDocumentContainerAsync(
            IReadOnlyList <CosmosObject> documents,
            FlakyDocumentContainer.FailureConfigs failureConfigs = null)
        {
            IMonadicDocumentContainer monadicDocumentContainer = new InMemoryContainer(partitionKeyDefinition);

            if (failureConfigs != null)
            {
                monadicDocumentContainer = new FlakyDocumentContainer(monadicDocumentContainer, failureConfigs);
            }

            DocumentContainer documentContainer = new DocumentContainer(monadicDocumentContainer);

            for (int i = 0; i < 3; i++)
            {
                IReadOnlyList <FeedRangeInternal> ranges = await documentContainer.GetFeedRangesAsync(cancellationToken : default);
예제 #6
0
        public void WebContentDispatcherStorageHaveDifferentInstaceButSameProperties()
        {
            ExecuteTest(() => {
                IContentContainer storage      = new InMemoryContainer();
                WebContentDispatcher container = new WebContentDispatcher(storage);

                TestContentType c = TestContentType.getARandomTestContentType(enforce_a_reference: false);
                storage.Add(c);
                Guid guid = c.guid;

                Assert.AreNotSame(container.GetContent <TestContentType>(guid),
                                  storage.GetContent <TestContentType>(guid));


                Assert.IsTrue(container.GetContent <TestContentType>(guid).samePropertiesValue(storage.GetContent <TestContentType>(guid)));
                container.Dispose();
            });
        }
예제 #7
0
        public void WebContentDispatcherStorageInstanceAddedOnDispose()
        {
            ExecuteTest(() => {
                IContentContainer storage = new InMemoryContainer();

                WebContentDispatcher container = new WebContentDispatcher(storage);
                this.getMystery().AssemblyRegister.setGlobalObject <IContentDispatcher>(container);

                TestContentType c = TestContentType.getARandomTestContentTypeWithoutreference();
                container.Add(c);


                Assert.IsFalse(storage.Contains(c));
                container.Dispose();

                Assert.IsTrue(storage.Contains(c));
                this.getMystery().AssemblyRegister.setGlobalObject <IContentDispatcher>(null);
            });
        }
예제 #8
0
        public void WebContentDispatcherWhenRemovedStorageStilHaveIt()
        {
            ExecuteTest(() => {
                IContentContainer storage      = new InMemoryContainer();
                WebContentDispatcher container = new WebContentDispatcher(storage);
                this.setGlobalObject <IContentDispatcher>(container);

                TestContentType c = TestContentType.getARandomTestContentType(enforce_a_reference: false);
                storage.Add(c);

                Assert.IsTrue(container.Remove(c));

                Assert.IsFalse(container.Contains(c));
                Assert.IsTrue(storage.Contains(c));
                container.Dispose();

                this.setGlobalObject <IContentDispatcher>(null);
            });
        }
예제 #9
0
        public void WebContentDispatcherStorageInstanceUpdateOnDispose()
        {
            ExecuteTest(() => {
                IContentContainer storage      = new InMemoryContainer();
                string test_value              = "ciao";
                WebContentDispatcher container = new WebContentDispatcher(storage);
                this.getMystery().AssemblyRegister.setGlobalObject <IContentDispatcher>(container);

                TestContentType c = TestContentType.getARandomTestContentTypeWithoutreference();
                storage.Add(c);
                Guid guid = c.guid;
                TestContentType in_request = container.GetContent <TestContentType>(guid);
                in_request.a_string        = test_value;
                Assert.AreNotEqual(test_value, c.a_string);
                container.Dispose();
                c = storage.GetContent <TestContentType>(guid);
                Assert.AreEqual(test_value, c.a_string);
                this.getMystery().AssemblyRegister.setGlobalObject <IContentDispatcher>(null);
            });
        }
 public AccountInMemoryRepository(InMemoryContainer container)
 {
     this.container = container;
 }
 public TransactionInMemoryRepository(InMemoryContainer container)
 {
     this.container = container;
 }
예제 #12
0
 public CompanyInMemoryRepository(InMemoryContainer container)
 {
     this.container = container;
 }
 public PersonInMemoryRepository(InMemoryContainer container)
 {
     this.container = container;
 }
예제 #14
0
 public ShareholderInMemoryRepository(InMemoryContainer container)
 {
     this.container = container;
 }
예제 #15
0
        public override PassThroughQueryTestOutput ExecuteTest(PassThroughQueryTestInput input)
        {
            // gets DocumentContainer
            IMonadicDocumentContainer monadicDocumentContainer = new InMemoryContainer(input.PartitionKeyDefinition);
            DocumentContainer         documentContainer        = new DocumentContainer(monadicDocumentContainer);

            SqlQuerySpec sqlQuerySpec = new SqlQuerySpec(input.Query);

            // gets query context
            string databaseId   = "db1234";
            string resourceLink = string.Format("dbs/{0}/colls", databaseId);
            CosmosQueryContextCore cosmosQueryContextCore = new CosmosQueryContextCore(
                client: new TestCosmosQueryClient(),
                resourceTypeEnum: Documents.ResourceType.Document,
                operationType: Documents.OperationType.Query,
                resourceType: typeof(QueryResponseCore),
                resourceLink: resourceLink,
                isContinuationExpected: false,
                allowNonValueAggregateQuery: true,
                useSystemPrefix: false,
                correlatedActivityId: Guid.NewGuid());

            //  gets input parameters
            QueryRequestOptions queryRequestOptions = new QueryRequestOptions();

            CosmosSerializerCore serializerCore = new();

            using StreamReader streamReader = new(serializerCore.ToStreamSqlQuerySpec(sqlQuerySpec, Documents.ResourceType.Document));
            string sqlQuerySpecJsonString = streamReader.ReadToEnd();

            PartitionedQueryExecutionInfo partitionedQueryExecutionInfo = GetPartitionedQueryExecutionInfo(sqlQuerySpecJsonString, input.PartitionKeyDefinition);

            if (input.PartitionKeyValue == default || input.PartitionKeyValue == Cosmos.PartitionKey.None)
            {
                input.PartitionKeyValue = Cosmos.PartitionKey.Null;
            }

            CosmosQueryExecutionContextFactory.InputParameters inputParameters = new CosmosQueryExecutionContextFactory.InputParameters(
                sqlQuerySpec: sqlQuerySpec,
                initialUserContinuationToken: null,
                initialFeedRange: null,
                maxConcurrency: queryRequestOptions.MaxConcurrency,
                maxItemCount: queryRequestOptions.MaxItemCount,
                maxBufferedItemCount: queryRequestOptions.MaxBufferedItemCount,
                partitionKey: input.PartitionKeyValue,
                properties: queryRequestOptions.Properties,
                partitionedQueryExecutionInfo: partitionedQueryExecutionInfo,
                executionEnvironment: null,
                returnResultsInDeterministicOrder: null,
                forcePassthrough: true,
                testInjections: null);

            IQueryPipelineStage queryPipelineStage = CosmosQueryExecutionContextFactory.Create(
                documentContainer,
                cosmosQueryContextCore,
                inputParameters,
                NoOpTrace.Singleton);
            bool result = queryPipelineStage.MoveNextAsync(NoOpTrace.Singleton).Result;

            Assert.AreEqual(input.ExpectedPassThrough, inputParameters.SqlQuerySpec.PassThrough);
            Assert.IsNotNull(queryPipelineStage);
            Assert.IsTrue(result);

            return(new PassThroughQueryTestOutput(inputParameters.SqlQuerySpec.PassThrough));
        }