public void Returns_uncertified_deployments_by_application_and_environment()
		{
			var criteria = new CriterionSet();
			criteria.AddCriterion(new Criterion(Deployment.APPLICATION, "SampleApp1"));
			criteria.AddCriterion(new Criterion(Deployment.ENVIRONMENT, "Environment"));
			criteria.AddCriterion(new Criterion(Deployment.CERTIFIED_ON, null));
			criteria.AddCriterion(new Criterion(Deployment.RESULT, DeploymentResult.Success));
			criteria.OrderBy = Deployment.DEPLOYED_ON;
			criteria.SortOrder = SortOrder.Descending;

			var foundDeployments = new Deployment[0];

			var mocks = new MockRepository();
			var repository = mocks.CreateMock<IPersistentObjectRepository>();

			using (mocks.Record())
			{
				repository.ConfigurationFile = "deployer.hibernate.cfg.xml";
				Expect.Call(repository.FindAll<Deployment>(criteria)).Return(foundDeployments);
			}

			using (mocks.Playback())
			{
				IDeploymentRepository deploymentRepository = new DeploymentRepository(repository);

				var deployments = deploymentRepository.FindSuccessfulUncertified("SampleApp1", "Environment");

				Assert.That(deployments, Is.SameAs(foundDeployments));
			}

			mocks.VerifyAll();
		}
		public ApplicationInstance GetByMaintenanceHostHeaderAndMachineName(string maintenanceHostHeader, string machineName)
		{
			var criteria = new CriterionSet();
			criteria.AddCriterion(new Criterion(ApplicationInstance.MachineNameAttribute, machineName));
			criteria.AddCriterion(new Criterion(ApplicationInstance.MaintenanceHostHeaderAttribute, maintenanceHostHeader));

			var instance = _objectRepository.FindFirst<ApplicationInstance>(criteria);
			return instance;
		}
Exemplo n.º 3
0
		private CriterionSet getCriteria(string application, string environment)
		{
			var criteria = new CriterionSet();
			criteria.AddCriterion(new Criterion(Deployment.APPLICATION, application));
			criteria.AddCriterion(new Criterion(Deployment.ENVIRONMENT, environment));
			criteria.OrderBy = Deployment.DEPLOYED_ON;
			criteria.SortOrder = SortOrder.Descending;

			return criteria;
		}
Exemplo n.º 4
0
		public void Calculates_hash_code_based_on_criterion()
		{
			CriterionSet set1 = new CriterionSet();

			Criterion criterion1 = new Criterion("A1", "V1", ComparisonOperator.Equal);
			Criterion criterion2 = new Criterion("A2", "V2", ComparisonOperator.Equal);

			set1.AddCriterion(criterion1);
			set1.AddCriterion(criterion2);

			Assert.That(set1.GetHashCode(), Is.EqualTo(criterion1.GetHashCode() + criterion2.GetHashCode()));
		}
Exemplo n.º 5
0
		public void Can_add_criterion()
		{
			CriterionSet set = new CriterionSet();

			Criterion criterion1 = new Criterion("A1", "V1");
			Criterion criterion2 = new Criterion("A2", "V2");

			set.AddCriterion(criterion1);
			set.AddCriterion(criterion2);

			Assert.That(set.GetCriteria(), Is.EquivalentTo(new Criterion[] { criterion1, criterion2 }));
		}
Exemplo n.º 6
0
		public void Correctly_compares_equal_sets()
		{
			CriterionSet set1 = new CriterionSet();
			CriterionSet set2 = new CriterionSet();

			set1.AddCriterion(new Criterion("A1", "V1", ComparisonOperator.Equal));
			set1.AddCriterion(new Criterion("A2", "V2", ComparisonOperator.Equal));

			set2.AddCriterion(new Criterion("A1", "V1", ComparisonOperator.Equal));
			set2.AddCriterion(new Criterion("A2", "V2", ComparisonOperator.Equal));

			Assert.That(set1, Is.EqualTo(set2));
			Assert.That(set2, Is.EqualTo(set1));
		}
		public IEnumerable<ApplicationInstance> GetByHostHeader(string uniqueHostHeader)
		{
			var criteria = new CriterionSet();
			criteria.AddCriterion(new Criterion(ApplicationInstance.UniqueHostHeaderAttribute, uniqueHostHeader));
			IEnumerable<ApplicationInstance> instances = _objectRepository.FindAll<ApplicationInstance>(criteria);

			return instances;
		}
Exemplo n.º 8
0
		public void Correctly_compares_equal_sets_both_having_null()
		{
			CriterionSet set1 = new CriterionSet();
			CriterionSet set2 = new CriterionSet();

			set1.AddCriterion(new Criterion("A1", null, ComparisonOperator.Equal));
			set2.AddCriterion(new Criterion("A1", null, ComparisonOperator.Equal));

			Assert.That(set1, Is.EqualTo(set2));
			Assert.That(set2, Is.EqualTo(set1));
		}
Exemplo n.º 9
0
		public void Correctly_compares_unequal_sets_based_on_sorting()
		{
			CriterionSet set1 = new CriterionSet();
			CriterionSet set2 = new CriterionSet();

			set1.OrderBy = "A1";
			set2.OrderBy = "B1";

			set1.SortOrder = SortOrder.Ascending;
			set2.SortOrder = SortOrder.Ascending;

			set1.AddCriterion(new Criterion("A1", null, ComparisonOperator.Equal));
			set2.AddCriterion(new Criterion("A1", null, ComparisonOperator.Equal));

			Assert.That(set1, Is.Not.EqualTo(set2));
			Assert.That(set2, Is.Not.EqualTo(set1));
		}
Exemplo n.º 10
0
		public void Does_not_add_null_valued_criteria()
		{
			Criterion nullCriterion = new Criterion("A1", null, ComparisonOperator.Equal);

			CriterionSet set1 = new CriterionSet();
			set1.AddCriterion(nullCriterion);

			Assert.That(set1.GetCriteria(), Is.EqualTo(new Criterion[] { nullCriterion }));
		}
Exemplo n.º 11
0
		public void Correctly_compares_empty_set_with_non_empty_set()
		{
			CriterionSet set1 = new CriterionSet();
			CriterionSet set2 = new CriterionSet();

			set2.AddCriterion(new Criterion("A1", "V1", ComparisonOperator.Equal));

			Assert.That(set1, Is.Not.EqualTo(set2));
			Assert.That(set2, Is.Not.EqualTo(set1));
		}
Exemplo n.º 12
0
		public void Correctly_compares_unequal_sets_with_same_number_of_elements_but_different_number_of_values()
		{
			CriterionSet set1 = new CriterionSet();
			CriterionSet set2 = new CriterionSet();

			set1.AddCriterion(new Criterion("A1", "V1", ComparisonOperator.Equal));
			set1.AddCriterion(new Criterion("A2", "V2", ComparisonOperator.Equal));

			set2.AddCriterion(new Criterion("A1", "V1", ComparisonOperator.Equal));

			Assert.That(set1, Is.Not.EqualTo(set2));
			Assert.That(set2, Is.Not.EqualTo(set1));
		}
Exemplo n.º 13
0
		public void Correctly_compares_complex_equal_sets()
		{
			CriterionSet set1 = new CriterionSet();
			CriterionSet set2 = new CriterionSet();

			string myString = "abc";

			set1.AddCriterion(new Criterion("A1", myString));
			set1.AddCriterion(new Criterion("A2", new DateTime(2007, 4, 15), ComparisonOperator.GreaterThan));

			set2.AddCriterion(new Criterion("A1", myString));
			set2.AddCriterion(new Criterion("A2", new DateTime(2007, 4, 15), ComparisonOperator.GreaterThan));

			Assert.That(set1, Is.EqualTo(set2));
			Assert.That(set2, Is.EqualTo(set1));
		}
		public void Can_correctly_gets_application_instances_by_host_header()
		{
			var instance1 = new ApplicationInstance();
			var instance2 = new ApplicationInstance();
			var instances = new[] { instance1, instance2 };

			var criteria = new CriterionSet();
			criteria.AddCriterion(new Criterion("UniqueHostHeader", "MyHostHeader"));

			var mocks = new MockRepository();
			var objectRepository = mocks.CreateMock<IPersistentObjectRepository>();

			using (mocks.Record())
			{
				objectRepository.ConfigurationFile = "webmanagement.hibernate.cfg.xml";
				Expect.Call(objectRepository.FindAll<ApplicationInstance>(criteria)).Return(instances);
			}

			using (mocks.Playback())
			{
				IApplicationInstanceRepository repository = new ApplicationInstanceRepository(objectRepository);
				IEnumerable<ApplicationInstance> actualInstances = repository.GetByHostHeader("MyHostHeader");

				EnumerableAssert.That(actualInstances, Is.EqualTo(instances));
			}
		}
		public void Can_correctly_gets_application_instances_by_machine_name_and_maintenance_host_header()
		{
			var instance = new ApplicationInstance();

			var criteria = new CriterionSet();
			criteria.AddCriterion(new Criterion("MachineName", "MyMachine"));
			criteria.AddCriterion(new Criterion("MaintenanceHostHeader", "MyDomain"));

			var mocks = new MockRepository();
			var objectRepository = mocks.CreateMock<IPersistentObjectRepository>();

			using (mocks.Record())
			{
				objectRepository.ConfigurationFile = "webmanagement.hibernate.cfg.xml";
				Expect.Call(objectRepository.FindFirst<ApplicationInstance>(criteria)).Return(instance);
			}

			using (mocks.Playback())
			{
				IApplicationInstanceRepository repository = new ApplicationInstanceRepository(objectRepository);
				var actualInstance = repository.GetByMaintenanceHostHeaderAndMachineName("MyDomain", "MyMachine");

				Assert.That(actualInstance, Is.SameAs(instance));
			}
		}