public PartitionControllerTests()
        {
            lease = Mock.Of <ILease>();
            Mock.Get(lease)
            .Setup(l => l.PartitionId)
            .Returns("partitionId");

            partitionProcessor         = MockPartitionProcessor();
            leaseRenewer               = MockRenewer();
            observer                   = MockObserver();
            partitionSupervisorFactory = Mock.Of <IPartitionSupervisorFactory>(f => f.Create(lease) == new PartitionSupervisor(lease, observer, partitionProcessor, leaseRenewer));

            leaseManager = Mock.Of <ILeaseManager>();
            Mock.Get(leaseManager).Reset(); // Reset implicit/by default setup of properties.
            Mock.Get(leaseManager)
            .Setup(manager => manager.AcquireAsync(lease))
            .ReturnsAsync(lease);
            Mock.Get(leaseManager)
            .Setup(manager => manager.ReleaseAsync(lease))
            .Returns(Task.CompletedTask);
            var leaseContainer = Mock.Of <ILeaseContainer>();

            synchronizer = Mock.Of <IPartitionSynchronizer>();
            sut          = new PartitionController(leaseContainer, leaseManager, partitionSupervisorFactory, synchronizer);
        }
コード例 #2
0
 public PartitionController(
     ILeaseContainer leaseContainer,
     ILeaseManager leaseManager,
     IPartitionSupervisorFactory partitionSupervisorFactory,
     IPartitionSynchronizer synchronizer)
 {
     this.leaseContainer             = leaseContainer;
     this.leaseManager               = leaseManager;
     this.partitionSupervisorFactory = partitionSupervisorFactory;
     this.synchronizer               = synchronizer;
 }
        public PartitionControllerSplitTests()
        {
            lease = Mock.Of <ILease>();
            Mock.Get(lease)
            .Setup(l => l.PartitionId)
            .Returns("partitionId");

            leaseChild = Mock.Of <ILease>();
            Mock.Get(leaseChild)
            .Setup(l => l.PartitionId)
            .Returns("childPartitionId");

            leaseChild2 = Mock.Of <ILease>();
            Mock.Get(leaseChild2)
            .Setup(l => l.PartitionId)
            .Returns("childPartitionId2");

            var partitionSupervisor = Mock.Of <IPartitionSupervisor>();

            Mock.Get(partitionSupervisor)
            .Setup(o => o.RunAsync(It.IsAny <CancellationToken>()))
            .ThrowsAsync(new PartitionSplitException("lastContinuation"));

            partitionSupervisorFactory = Mock.Of <IPartitionSupervisorFactory>(f => f.Create(lease) == partitionSupervisor);

            leaseManager = Mock.Of <ILeaseManager>();
            Mock.Get(leaseManager)
            .Setup(manager => manager.AcquireAsync(lease))
            .ReturnsAsync(lease);

            Mock.Get(leaseManager)
            .Setup(manager => manager.ReleaseAsync(lease))
            .Returns(Task.FromResult(false));

            synchronizer = Mock.Of <IPartitionSynchronizer>();
            sut          = new PartitionController(leaseManager, partitionSupervisorFactory, synchronizer);
        }
        public PartitionControllerTests()
        {
            lease = Mock.Of <ILease>();
            Mock.Get(lease)
            .Setup(l => l.PartitionId)
            .Returns("partitionId");

            partitionProcessor         = MockPartitionProcessor();
            leaseRenewer               = MockRenewer();
            observer                   = MockObserver();
            partitionSupervisorFactory = Mock.Of <IPartitionSupervisorFactory>(f => f.Create(lease) == new PartitionSupervisor(lease, observer, partitionProcessor, leaseRenewer));

            leaseManager = Mock.Of <ILeaseManager>();
            Mock.Get(leaseManager)
            .Setup(manager => manager.AcquireAsync(lease))
            .ReturnsAsync(lease);

            Mock.Get(leaseManager)
            .Setup(manager => manager.ReleaseAsync(lease))
            .Returns(Task.FromResult(false));

            synchronizer = Mock.Of <IPartitionSynchronizer>();
            sut          = new PartitionController(leaseManager, partitionSupervisorFactory, synchronizer);
        }