Beispiel #1
0
        public void AnnounceAsync_WhenPackageIsOk_CallsExpectedMethodsAndThrowsNothing()
        {
            var announcementMock        = fixture.Freeze <Mock <IDeployAnnouncement> >();
            var announcementFactoryMock = fixture.Freeze <Mock <IDeployAnnouncementFactory> >();

            var versions      = fixture.CreateMany <PackageVersion>(5);
            var syncMock      = fixture.Freeze <Mock <ISyncService> >();
            var fusionMock    = fixture.Freeze <Mock <IFusionService> >();
            var scheduleMock  = fixture.Freeze <Mock <IScheduleService> >();
            var validatorMock = fixture.Freeze <Mock <IPackageVersionValidator> >();

            var sequence = new MoqSequence();

            var token = CancellationToken.None;

            validatorMock.Setup(_ => _.ConfirmAvailability(versions)).InSequence(sequence);
            announcementFactoryMock.Setup(_ => _.CreateNew(new string[0], versions)).InSequence(sequence).Returns(() => announcementMock.Object);
            scheduleMock.Setup(_ => _.ScheduleAsync(announcementMock.Object, token)).InSequence(sequence).Returns(Task.FromResult(true));

            var sut = fixture.Create <DeployService>();

            Assert.That(() => sut.AnnounceAsync(versions, token), Throws.Nothing);

            sequence.Verify();
        }
Beispiel #2
0
        public void ExtractMultiple_WhenCalled_DoesWhatExpected()
        {
            var announcementMock     = fixture.Freeze <Mock <IDeployAnnouncement> >();
            var fusionMock           = fixture.Freeze <Mock <IFusion> >();
            var builderMock          = fixture.Freeze <Mock <IFusionBuilder> >();
            var versionValidatorMock = fixture.Freeze <Mock <IPackageVersionValidator> >();
            var extractorMock        = fixture.Freeze <Mock <IFusionExtracter> >();

            var seq = new MoqSequence();

            announcementMock.Setup(_ => _.GetFusionIds()).InSequence(seq).Returns(() => new[] { "test" });
            announcementMock.Setup(_ => _.GetPackageVersions(It.IsAny <string>())).InSequence(seq);
            versionValidatorMock.Setup(_ => _.ConfirmAvailability(It.IsAny <IEnumerable <PackageVersion> >())).InSequence(seq);
            builderMock.Setup(_ => _.Build(It.IsAny <FusePackConfig>(), It.IsAny <IFusion>(), It.IsAny <IEnumerable <PackageVersion> >())).InSequence(seq);
            extractorMock.Setup(_ => _.Extract(It.IsAny <FusePackConfig>(), It.IsAny <Stream>())).InSequence(seq);

            var sut = fixture.Create <FusionService>();

            Assert.That(() => sut.Extract(announcementMock.Object, CancellationToken.None), Throws.Nothing);

            seq.Verify();
        }