public void Should_Load_cctray_and_return_failure_list_with_zero_items()
 {
     var xml = "<Projects><Project name='Create_Environment :: Create_VMs' activity='Sleeping' lastBuildStatus='Success' lastBuildLabel='Environment_Number_1' lastBuildTime='2011-08-18T14:18:06' webUrl='http://build.london.ttldev.local:8153/go/pipelines/Create_Environment/1/Create_VMs/1' /><Project name='SomePipeline :: Create_VMs :: Create_Master_SQL_Server' activity='Sleeping' lastBuildStatus='Success' lastBuildLabel='Environment_Number_1' lastBuildTime='2011-08-04T17:02:27' webUrl='http://build.london.ttldev.local:8153/go/tab/build/detail/Create_Environment/1/Create_VMs/1/Create_Master_SQL_Server' /></Projects>";
     this._endPoint.Expect(x => x.GetXml()).Return(xml);
     var tray = new CcTray(this._endPoint, dateTimeNow);
     tray.Load();
     this._endPoint.VerifyAllExpectations();
     Assert.That(tray.FailedPipelines().Count, Is.EqualTo(0));
 }
Ejemplo n.º 2
0
 public void Should_Load_cctray_and_return_list_of_all_pipeline_names_no_duplicte()
 {
     var xml = "<Projects><Project name='Create_Environment :: Create_VMs' activity='Sleeping' lastBuildStatus='Success' lastBuildLabel='Environment_Number_1' lastBuildTime='2011-08-18T14:18:06' webUrl='http://build.london.ttldev.local:8153/go/pipelines/Create_Environment/1/Create_VMs/1' /><Project name='Create_Environment :: Create_VMs' activity='Sleeping' lastBuildStatus='Success' lastBuildLabel='Environment_Number_1' lastBuildTime='2011-08-18T14:18:06' webUrl='http://build.london.ttldev.local:8153/go/pipelines/Create_Environment/1/Create_VMs/1' /><Project name='SomePipeline :: Create_VMs :: Create_Master_SQL_Server' activity='Sleeping' lastBuildStatus='Success' lastBuildLabel='Environment_Number_1' lastBuildTime='2011-08-04T17:02:27' webUrl='http://build.london.ttldev.local:8153/go/tab/build/detail/Create_Environment/1/Create_VMs/1/Create_Master_SQL_Server' /></Projects>";
     _endPoint.Expect(x => x.GetXml()).Return(xml);
     var ccTray = new CcTray(_endPoint);
     // Test
     ccTray.Load();
     // Assert
     _endPoint.VerifyAllExpectations();
     Assert.That(ccTray.AllPipelineNames().Count, Is.EqualTo(2));
     Assert.That(ccTray.AllPipelineNames()[0], Is.EqualTo("Create_Environment"));
     Assert.That(ccTray.AllPipelineNames()[1], Is.EqualTo("SomePipeline"));
 }
 public void Should_Load_cctray_and_return_single_pipeline_last_build_length_in_seconds()
 {
     int seconds = 59;
     var past = new DateTime(2012, 11, 10, 9, 8, seconds);
     dateTimeNow.Expect(x => x.GetNow()).Return(new DateTime(2012, 11, 10, 9, 8, 0));
     var xml = string.Format("<Projects><Project name='Create_Environment :: Create_VMs' activity='Sleeping' lastBuildStatus='Success' lastBuildLabel='Environment_Number_1' lastBuildTime='{0}' webUrl='http://build.london.ttldev.local:8153/go/pipelines/Create_Environment/1/Create_VMs/1' /></Projects>", GetPastDateTime(past));
     this._endPoint.Expect(x => x.GetXml()).Return(xml);
     var ccTray = new CcTray(this._endPoint, dateTimeNow);
     ccTray.Load();
     this._endPoint.VerifyAllExpectations();
     var lengths = ccTray.GetPipelineLengths();
     Assert.That(lengths[0].Name, Is.EqualTo("Create_Environment"));
     Assert.That(lengths[0].Length, Is.EqualTo(seconds));
 }
Ejemplo n.º 4
0
        public void As_A_user_I_want_to_have_a_message_when_a_build_fails_so_that_I_can_fix_the_build()
        {
            var message = "someMessage - " + Guid.NewGuid().ToString();
            var skype = new Skype(makeMessageProcessor());
            var chats = new Chats(skype);
            var configurationLoader = new ConfigurationLoader();
            var loader = new Loader(new MessengerClient(skype, new UserCollection(new SKYPE4COMLib.UserCollection()), chats), new BuildCollection());
            var projectwatcher = new Projectwatcher(loader.GetUserGroups(configurationLoader.Load("OnePipeline.xml")));

            string url = "someUrl";

            var httpGet = MockRepository.GenerateMock<IHttpGet>();
            httpGet.Expect(x => x.Request(url));
            httpGet.Expect(x => x.StatusCode).Return(200);
            httpGet.Expect(x => x.ResponseBody).Return(File.ReadAllText("cctray.xml"));

            ICcTray ccTray = new CcTray(new EndpointImpl(httpGet, url));
            ccTray.Load();

            //Test
            projectwatcher.Message(ccTray.FailedPipelines());
        }
Ejemplo n.º 5
0
        public void As_A_user_I_want_to_two_messages_in_the_same_group_window_when_a_build_fails_so_that_I_can_fix_the_builds_when_each_fails()
        {
            var skype = new Skype(makeMessageProcessor());
            var chats = new Chats(skype);
            var configurationLoader = new ConfigurationLoader();
            var loader = new Loader(new MessengerClient(skype, new UserCollection(new SKYPE4COMLib.UserCollection()), chats),new BuildCollection());
            var projectwatcher = new Projectwatcher(loader.GetUserGroups(configurationLoader.Load("OnePipeline.xml")));

            string url = "someUrl";

            var httpGet = MockRepository.GenerateMock<IHttpGet>();
            httpGet.Expect(x => x.Request(url));
            httpGet.Expect(x => x.StatusCode).Return(200);
            httpGet.Expect(x => x.ResponseBody).Return(File.ReadAllText("cctray.xml"));

            ICcTray ccTray = new CcTray(new EndpointImpl(httpGet, url));
            ccTray.Load();

            //Test
            projectwatcher.Message(ccTray.FailedPipelines());

            var p = new Project("Trunk_QA_Env_PCIDSS :: Deployment_to_QA_PCIDSS1", "Failed", "Failure", "1.2.3.4","2011-09-23T16:59:18", "web");
            ccTray.FailedPipelines().Add(p);
            projectwatcher.Message(ccTray.FailedPipelines());

            projectwatcher.Message(ccTray.FailedPipelines());
        }
Ejemplo n.º 6
0
        public void Should_send_a_multiple_message_sucessfully_mocking_http_and_skype()
        {
            var message = "Trunk_QA_Env_PCIDSS has Failure build 03.13.00.207 http://build.london.ttldev.local:8153/go/pipelines/Trunk_QA_Env_PCIDSS/34/Deployment_to_QA_PCIDSS/1";
            var name = "Trunk_QA_Env_PCIDSS";
            var projects = TestData.CreateProjects(10, 1);
            client.Expect(x => x.IsRunning()).Return(true);
            chats.Expect(x => x.Get(name, userCollection)).Return(chat);
            skype.Expect(x => x.SkypeClient()).Return(client);
            skype.Expect(x => x.GetUsers()).Return(new List<string> { "owainfperry" });
            skype.Expect(x => x.GetUser("owainfperry")).IgnoreArguments().Return(user).Repeat.Once();
            skype.Expect(x => x.GetUser("otherUser")).IgnoreArguments().Return(user).Repeat.Once();
            chat.Expect(x => x.OpenWindow());
            chat.Expect(x => x.SendMessage(message));
            userCollection.Expect(x => x.Add(user)).IgnoreArguments();

            var config = configurationLoader.Load("MockOnePipeline.xml");
            var userGroups = loader.GetUserGroups(config);
            var projectwatcher = new Projectwatcher(userGroups);
            string url = "someUrl";

            HttpClientReadXml(url, TestData.MakeXml(projects));

            ICcTray ccTray = new CcTray(new EndpointImpl(httpGet, url));
            ccTray.Load();
            //ccTray.FailedPipelines.Add(new Project("a1", "Failed", "broken", "label", "10:20", "a.b"));
            //Test
            projectwatcher.Message(ccTray.FailedPipelines());
            projectwatcher.Message(ccTray.FailedPipelines());
        }
Ejemplo n.º 7
0
        public void Should_send_a_single_message_sucessfully_mocking_http_and_skype()
        {
            //var message = "Trunk_QA_Env_PCIDSS has Failure build 03.13.00.207 http://build.london.ttldev.local:8153/go/pipelines/Trunk_QA_Env_PCIDSS/34/Deployment_to_QA_PCIDSS/1";
            var name = "name1";
            string ccTrayXml = "MockOnePipeline.xml";
            string url = "someUrl";
            var projects = TestData.CreateProjects(10, 1);
            var failedProject = projects.Project[projects.Project.Length - 1];
            client.Expect(x => x.IsRunning()).Return(true);
            chats.Expect(x => x.Get(name, userCollection)).Return(chat);
            skype.Expect(x => x.SkypeClient()).Return(client);
            skype.Expect(x => x.GetUsers()).Return(new List<string> { "owainfperry" });
            skype.Expect(x => x.GetUser("owainfperry")).IgnoreArguments().Return(user).Repeat.Once();
            skype.Expect(x => x.GetUser("otherUser")).IgnoreArguments().Return(user).Repeat.Once();
            chat.Expect(x => x.OpenWindow());
            chat.Expect(x => x.SendMessage(failedProject.GetMessage()));
            userCollection.Expect(x => x.Add(user)).IgnoreArguments();

            buildCollection.Expect(x => x.ShouldAlert(failedProject)).Return(true);

            var projectwatcher = CreateProjectwatcher(ccTrayXml);
            HttpClientReadXml(url, TestData.MakeXml(projects));
            ICcTray ccTray = new CcTray(new EndpointImpl(httpGet, url));
            ccTray.Load();
            //Test
            projectwatcher.Message(ccTray.FailedPipelines());
        }