Esempio n. 1
0
        public async Task SkipNextCommandSkips()
        {
            using var mock = AutoMock.GetLoose();
            var context = mock.Mock <IUpgradeContext>().Object;

            var stepTitle = "Test step!";
            var step      = new TestUpgradeStep(stepTitle);
            var command   = new SkipNextCommand(step);

            // Initialize step
            Assert.Equal(UpgradeStepStatus.Unknown, step.Status);
            await step.InitializeAsync(context, CancellationToken.None).ConfigureAwait(false);

            Assert.Equal(UpgradeStepStatus.Incomplete, step.Status);
            Assert.Equal(BuildBreakRisk.Low, step.Risk);

            // Apply command
            Assert.True(await command.ExecuteAsync(context, CancellationToken.None).ConfigureAwait(false));

            // Confirm command text and step state are as expected
            Assert.Equal($"Skip next step ({stepTitle})", command.CommandText);
            Assert.Equal(0, step.ApplicationCount);
            Assert.Equal(UpgradeStepStatus.Skipped, step.Status);
            Assert.Equal(BuildBreakRisk.Low, step.Risk);
            Assert.Equal("Step skipped", step.StatusDetails);
        }
Esempio n. 2
0
        public void NegativeCtorTests()
        {
            var goodParent = new ConfigUpdaterStep(Enumerable.Empty <IConfigUpdater>(), new ConfigUpdaterOptions(), new NullLogger <ConfigUpdaterStep>());
            var badParent  = new TestUpgradeStep("Test step");

            Assert.Throws <ArgumentNullException>("parentStep", () => new ConfigUpdaterSubStep(null !, new Mock <IConfigUpdater>().Object, new NullLogger <ConfigUpdaterStep>()));
            Assert.Throws <ArgumentNullException>("parentStep", () => new ConfigUpdaterSubStep(badParent, new Mock <IConfigUpdater>().Object, new NullLogger <ConfigUpdaterStep>()));
            Assert.Throws <ArgumentNullException>("configUpdater", () => new ConfigUpdaterSubStep(goodParent, null !, new NullLogger <ConfigUpdaterStep>()));
            Assert.Throws <ArgumentNullException>("logger", () => new ConfigUpdaterSubStep(goodParent, new Mock <IConfigUpdater>().Object, null !));
        }
Esempio n. 3
0
        public async Task NegativeTests()
        {
            Assert.Throws <ArgumentNullException>(() => new ApplyNextCommand(null !));
            Assert.Throws <ArgumentNullException>(() => new SkipNextCommand(null !));
            Assert.Throws <ArgumentNullException>(() => new ExitCommand(null !));

            // Applying before intialization throws
            using var mock = AutoMock.GetLoose();
            var context = mock.Mock <IUpgradeContext>().Object;
            var step    = new TestUpgradeStep(string.Empty);
            var command = new ApplyNextCommand(step);
            await Assert.ThrowsAsync <InvalidOperationException>(async() => await command.ExecuteAsync(context, CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false);
        }
        public void NegativeCtorTests()
        {
            var options = new Mock <IOptions <ICollection <ConfigUpdaterOptions> > >();

            options.Setup(o => o.Value).Returns(Array.Empty <ConfigUpdaterOptions>());

            var goodParent = new ConfigUpdaterStep(Enumerable.Empty <IUpdater <ConfigFile> >(), options.Object, new NullLogger <ConfigUpdaterStep>());
            var badParent  = new TestUpgradeStep("Test step");

            Assert.Throws <ArgumentNullException>("parentStep", () => new ConfigUpdaterSubStep(null !, new Mock <IUpdater <ConfigFile> >().Object, new NullLogger <ConfigUpdaterStep>()));
            Assert.Throws <ArgumentNullException>("parentStep", () => new ConfigUpdaterSubStep(badParent, new Mock <IUpdater <ConfigFile> >().Object, new NullLogger <ConfigUpdaterStep>()));
            Assert.Throws <ArgumentNullException>("configUpdater", () => new ConfigUpdaterSubStep(goodParent, null !, new NullLogger <ConfigUpdaterStep>()));
            Assert.Throws <ArgumentNullException>("logger", () => new ConfigUpdaterSubStep(goodParent, new Mock <IUpdater <ConfigFile> >().Object, null !));
        }