Ejemplo n.º 1
0
        public async Task GivenTagKeys_WhenCompletingReindexing_ThenShouldPassArguments()
        {
            string operationId   = Guid.NewGuid().ToString();
            var    expectedInput = new List <int> {
                1, 2, 3, 4, 5
            };
            var expectedOutput = new List <int> {
                1, 2, 4, 5
            };

            // Arrange input
            IDurableActivityContext context = Substitute.For <IDurableActivityContext>();

            context.InstanceId.Returns(operationId);
            context.GetInput <IReadOnlyList <int> >().Returns(expectedInput);

            _extendedQueryTagStore
            .CompleteReindexingAsync(expectedInput, CancellationToken.None)
            .Returns(expectedOutput);

            // Call the activity
            IReadOnlyList <int> actual = await _reindexDurableFunction.CompleteReindexingAsync(
                context,
                NullLogger.Instance);

            // Assert behavior
            Assert.Same(expectedOutput, actual);
            context.Received(1).GetInput <IReadOnlyList <int> >();
            await _extendedQueryTagStore
            .Received(1)
            .CompleteReindexingAsync(expectedInput, CancellationToken.None);
        }
Ejemplo n.º 2
0
        public async Task GivenTagKeys_WhenAssigningReindexingOperation_ThenShouldPassArguments()
        {
            Guid operationId   = Guid.NewGuid();
            var  expectedInput = new List <int> {
                1, 2, 3, 4, 5
            };
            var expectedOutput = new List <ExtendedQueryTagStoreEntry>
            {
                new ExtendedQueryTagStoreEntry(1, "01010101", "AS", null, QueryTagLevel.Instance, ExtendedQueryTagStatus.Adding, QueryStatus.Enabled, 0)
            };

            // Arrange input
            IDurableActivityContext context = Substitute.For <IDurableActivityContext>();

            context.InstanceId.Returns(OperationId.ToString(operationId));
            context.GetInput <IReadOnlyList <int> >().Returns(expectedInput);

            _extendedQueryTagStore
            .AssignReindexingOperationAsync(expectedInput, operationId, false, CancellationToken.None)
            .Returns(expectedOutput);

            // Call the activity
            IReadOnlyList <ExtendedQueryTagStoreEntry> actual = await _reindexDurableFunction.AssignReindexingOperationAsync(
                context,
                NullLogger.Instance);

            // Assert behavior
            Assert.Same(expectedOutput, actual);
            context.Received(1).GetInput <IReadOnlyList <int> >();
            await _extendedQueryTagStore
            .Received(1)
            .AssignReindexingOperationAsync(expectedInput, operationId, false, CancellationToken.None);
        }