Beispiel #1
0
        public async void should_retrieve_builds_for_all_available_devices()
        {
            var inputDevice = Substitute.For<IInputDevice>();
            var connection = Substitute.For<ITeamCityConnection>();
            connection.GetBuild(Arg.Any<string>()).ReturnsForAnyArgs("<builds />");

            var outputDevice1 = Substitute.For<IOutputDevice>();
            outputDevice1.IsAvailable.Returns(true);
            var inputs1 = new[] { buildId1, buildId2 };

            var outputDevice2 = Substitute.For<IOutputDevice>();
            outputDevice2.IsAvailable.Returns(false);
            var inputs2 = new[] { buildId3 };

            var monitor = new TeamCityMonitor(inputDevice, d => connection);
            monitor.AddBuilds(outputDevice1, inputs1);
            monitor.AddBuilds(outputDevice2, inputs2);

            await monitor.BeginMonitoring();

            await Task.WhenAll(
                connection.Received().GetBuild(buildId1),
                connection.Received().GetBuild(buildId2),
                connection.DidNotReceive().GetBuild(buildId3));
        }
Beispiel #2
0
        public async void should_not_retrieve_builds_if_output_device_unavailable()
        {
            var inputDevice = Substitute.For<IInputDevice>();
            var connection = Substitute.For<ITeamCityConnection>();
            connection.GetBuild(Arg.Any<string>()).ReturnsForAnyArgs("<builds />");
            var outputDevice = Substitute.For<IOutputDevice>();
            outputDevice.IsAvailable.Returns(false);
            var inputs = new[] { buildId1 };
            var monitor = new TeamCityMonitor(inputDevice, d => connection);
            monitor.AddBuilds(outputDevice, inputs);

            await monitor.BeginMonitoring();

            await connection.DidNotReceiveWithAnyArgs().GetBuild(buildId1);
        }