コード例 #1
0
        public void ProposeDistributionFor()
        {
            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);

            var first = new Mock <IGenerateDistributionProposals>();
            {
                first.Setup(p => p.ProposeDistributionFor(It.IsAny <DatasetActivationRequest>(), It.IsAny <CancellationToken>()))
                .Returns(
                    new DistributionPlan[]
                {
                    CreateNewDistributionPlan(
                        new DatasetActivationProposal(),
                        CreateOfflineInfo(new Mock <IPersistenceInformation>().Object),
                        systemDiagnostics)
                })
                .Verifiable();
            }

            var second = new Mock <IGenerateDistributionProposals>();
            {
                second.Setup(p => p.ProposeDistributionFor(It.IsAny <DatasetActivationRequest>(), It.IsAny <CancellationToken>()))
                .Returns(
                    new DistributionPlan[]
                {
                    CreateNewDistributionPlan(
                        new DatasetActivationProposal(),
                        CreateOfflineInfo(new Mock <IPersistenceInformation>().Object),
                        systemDiagnostics)
                })
                .Verifiable();
            }

            var generator = new DatasetDistributionGenerator(new IGenerateDistributionProposals[] { first.Object, second.Object });
            var results   = generator.ProposeDistributionFor(new DatasetActivationRequest(), new CancellationToken());

            Assert.AreEqual(2, results.Count());
            first.Verify(f => f.ProposeDistributionFor(It.IsAny <DatasetActivationRequest>(), It.IsAny <CancellationToken>()), Times.Once());
            second.Verify(s => s.ProposeDistributionFor(It.IsAny <DatasetActivationRequest>(), It.IsAny <CancellationToken>()), Times.Once());
        }
コード例 #2
0
        public void ProposeDistributionFor()
        {
            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);

            var first = new Mock<IGenerateDistributionProposals>();
            {
                first.Setup(p => p.ProposeDistributionFor(It.IsAny<DatasetActivationRequest>(), It.IsAny<CancellationToken>()))
                    .Returns(
                        new DistributionPlan[]
                        {
                            CreateNewDistributionPlan(
                                new DatasetActivationProposal(),
                                CreateOfflineInfo(new Mock<IPersistenceInformation>().Object),
                                systemDiagnostics)
                        })
                        .Verifiable();
            }

            var second = new Mock<IGenerateDistributionProposals>();
            {
                second.Setup(p => p.ProposeDistributionFor(It.IsAny<DatasetActivationRequest>(), It.IsAny<CancellationToken>()))
                    .Returns(
                        new DistributionPlan[]
                        {
                            CreateNewDistributionPlan(
                                new DatasetActivationProposal(),
                                CreateOfflineInfo(new Mock<IPersistenceInformation>().Object),
                                systemDiagnostics)
                        })
                        .Verifiable();
            }

            var generator = new DatasetDistributionGenerator(new IGenerateDistributionProposals[] { first.Object, second.Object });
            var results = generator.ProposeDistributionFor(new DatasetActivationRequest(), new CancellationToken());

            Assert.AreEqual(2, results.Count());
            first.Verify(f => f.ProposeDistributionFor(It.IsAny<DatasetActivationRequest>(), It.IsAny<CancellationToken>()), Times.Once());
            second.Verify(s => s.ProposeDistributionFor(It.IsAny<DatasetActivationRequest>(), It.IsAny<CancellationToken>()), Times.Once());
        }