Exemplo n.º 1
0
            public async Task IgnoresAggregationWithoutChildren()
            {
                var aggregation = new TAggregationEntity
                {
                    RowKey = "rowKey"
                };

                var activeChildDifferentEntity = new TChildEntity
                {
                    ParentRowKey = "different"
                };

                var recentChildDifferentEntity = new TChildEntity
                {
                    ParentRowKey = "different",
                    EndTime      = Cursor
                };

                Table.SetupQuery(activeChildDifferentEntity, recentChildDifferentEntity);

                await Updater.UpdateAsync(aggregation, Cursor);

                Table
                .Verify(
                    x => x.ReplaceAsync(It.IsAny <ITableEntity>()),
                    Times.Never());

                ChildUpdater
                .Verify(
                    x => x.UpdateAsync(It.IsAny <TChildEntity>(), It.IsAny <DateTime>()),
                    Times.Never());
            }
Exemplo n.º 2
0
            public async Task DoesNotDeactivateAggregationWithRecentChildren()
            {
                var aggregation = new TAggregationEntity
                {
                    RowKey = "rowKey"
                };

                var activeChildDifferentEntity = new TChildEntity
                {
                    ParentRowKey = "different"
                };

                var recentChildDifferentEntity = new TChildEntity
                {
                    ParentRowKey = "different",
                    EndTime      = Cursor
                };

                var oldChildSameEntity = new TChildEntity
                {
                    ParentRowKey = aggregation.RowKey,
                    EndTime      = Cursor - EndMessageDelay
                };

                var recentChildSameEntity = new TChildEntity
                {
                    ParentRowKey = aggregation.RowKey,
                    EndTime      = Cursor
                };

                Table.SetupQuery(
                    activeChildDifferentEntity,
                    recentChildDifferentEntity,
                    oldChildSameEntity,
                    recentChildSameEntity);

                ChildUpdater
                .Setup(x => x.UpdateAsync(oldChildSameEntity, Cursor))
                .Returns(Task.CompletedTask)
                .Verifiable();

                ChildUpdater
                .Setup(x => x.UpdateAsync(recentChildSameEntity, Cursor))
                .Returns(Task.CompletedTask)
                .Verifiable();

                await Updater.UpdateAsync(aggregation, Cursor);

                Assert.True(aggregation.IsActive);

                Table
                .Verify(
                    x => x.ReplaceAsync(aggregation),
                    Times.Never());

                ChildUpdater.Verify();
            }
Exemplo n.º 3
0
            public async Task IgnoresDeactivatedAggregation()
            {
                var aggregation = new TAggregationEntity
                {
                    EndTime = new DateTime(2018, 10, 9)
                };

                await Updater.UpdateAsync(aggregation, Cursor);

                Table
                .Verify(
                    x => x.CreateQuery <TChildEntity>(),
                    Times.Never());

                Table
                .Verify(
                    x => x.ReplaceAsync(It.IsAny <ITableEntity>()),
                    Times.Never());

                ChildUpdater
                .Verify(
                    x => x.UpdateAsync(It.IsAny <TChildEntity>(), It.IsAny <DateTime>()),
                    Times.Never());
            }