Ejemplo n.º 1
0
        public void Generates_certification_label_text()
        {
            Deployment deployment = new Deployment();

            deployment.CertifiedBy = "khurwitz";
            deployment.CertifiedOn = new DateTime(2007, 4, 15, 8, 32, 45);

            MockRepository mocks = new MockRepository();
            IDeploymentSelectionValidator validator = mocks.CreateMock <IDeploymentSelectionValidator>();

            using (mocks.Record())
            {
                Expect.Call(validator.IsValid("845", deployment)).Return(true);
            }

            using (mocks.Playback())
            {
                ILabelTextGenerator textGenerator = new LabelTextGenerator(validator);
                string text = textGenerator.GetCertificationText("845", deployment);

                Assert.That(text, Is.EqualTo("4/15/2007 8:32 AM by khurwitz"));
            }

            mocks.VerifyAll();
        }
Ejemplo n.º 2
0
        private string getText(Environment environment, string versionNumber, Deployment deployment, Action action)
        {
            var text = new StringBuilder();

            if (_validator.IsValid(versionNumber, deployment))
            {
                var isDeployment = action == Action.Deploy;
                var username     = isDeployment ? deployment.DeployedBy : deployment.CertifiedBy;
                var date         = isDeployment ? deployment.DeployedOn : deployment.CertifiedOn.GetValueOrDefault();

                if (environment != null)
                {
                    text.AppendFormat("{0} on ", environment.Predecessor);
                }

                text.AppendFormat("{0} by {1}", date.ToString("g"), username);
            }

            return(text.ToString());
        }
Ejemplo n.º 3
0
        public void Returns_empty_certification_string_for_invalid_deployment()
        {
            MockRepository mocks = new MockRepository();
            IDeploymentSelectionValidator validator = mocks.CreateMock <IDeploymentSelectionValidator>();

            using (mocks.Record())
            {
                Expect.Call(validator.IsValid("845", null)).Return(false);
            }

            using (mocks.Playback())
            {
                ILabelTextGenerator textGenerator = new LabelTextGenerator(validator);
                string text = textGenerator.GetCertificationText("845", null);

                Assert.That(text, Is.EqualTo(string.Empty));
            }

            mocks.VerifyAll();
        }