Beispiel #1
0
        public void BuildTargetsShouldSkipNullTargets()
        {
            // arrange
            var bounceMock  = new Mock <ITargetBuilderBounce>();
            var commandMock = new Mock <IBounceCommand>();

            bounceMock.Setup(_ => _.TaskScope(It.IsAny <IObsoleteTask>(), commandMock.Object, It.IsAny <string>())).Returns(new Mock <ITaskScope>().Object);
            bounceMock.Setup(_ => _.Invoke(commandMock.Object, It.IsAny <IObsoleteTask>())).Callback((IBounceCommand c, IObsoleteTask t) => {
                if (t == null)
                {
                    throw new NullReferenceException();
                }
            });

            var targets = new List <Target> {
                new Target {
                    Name = "OK", Task = new Mock <IObsoleteTask>().Object
                }, new Target {
                    Name = "Fail", Task = null
                }
            };
            var targetsBuilder = new TargetsBuilder();

            // act / assert (no exception)
            targetsBuilder.BuildTargets(bounceMock.Object, targets, commandMock.Object);
        }
Beispiel #2
0
        public void AbleToUseBounceFromOutside()
        {
            // arrange
            var bounce           = new BounceFactory().GetBounce();
            var targetsRetriever = new TargetsRetriever();
            var parameters       = new CommandLineParameters();

            var targets = targetsRetriever.GetTargetsFromObject(GetTargets(parameters)).ToTargets();
            var command = BounceCommandFactory.GetCommandByName("build");
            var builder = new TargetsBuilder();

            // act
            builder.BuildTargets(bounce, targets, command);

            // assert
            Assert.That(Directory.Exists(GitCheckoutDirectory), Is.True);
        }
Beispiel #3
0
        public void AbleToUseBounceFromOutside()
        {
            // arrange
            var bounce = new BounceFactory().GetBounce();
            var targetsRetriever = new TargetsRetriever();
            var parameters = new CommandLineParameters();

            var targets = targetsRetriever.GetTargetsFromObject(GetTargets(parameters)).ToTargets();
            var command = BounceCommandFactory.GetCommandByName("build");
            var builder = new TargetsBuilder();

            // act
            builder.BuildTargets(bounce, targets, command);

            // assert
            Assert.That(Directory.Exists(GitCheckoutDirectory), Is.True);
        }
Beispiel #4
0
        public void BuildTargetsShouldSkipNullTargets() {
            // arrange
            var bounceMock = new Mock<ITargetBuilderBounce>();
            var commandMock = new Mock<IBounceCommand>();

            bounceMock.Setup(_ => _.TaskScope(It.IsAny<IObsoleteTask>(), commandMock.Object, It.IsAny<string>())).Returns(new Mock<ITaskScope>().Object);
            bounceMock.Setup(_ => _.Invoke(commandMock.Object, It.IsAny<IObsoleteTask>())).Callback((IBounceCommand c, IObsoleteTask t) => {
                if (t == null) {
                    throw new NullReferenceException();
                }
            });

            var targets = new List<Target> { new Target { Name = "OK", Task = new Mock<IObsoleteTask>().Object }, new Target { Name = "Fail", Task = null } };
            var targetsBuilder = new TargetsBuilder();

            // act / assert (no exception)
            targetsBuilder.BuildTargets(bounceMock.Object, targets, commandMock.Object);
        }