Example #1
0
		internal static void TestVersionIsReadOnly(IPolicySetVersionCache version)
		{
			try
			{
				version.Content = "try and update";
				Assert.Fail("Failed to throw exception when updating a read-only version");
			}
			catch (Exception ex)
			{
				Assert.AreEqual(ex.Message, "Unable to update version information, this version is not the latest and therefore read-only");
			}

			try
			{
				version.NewCompiledPolicySet("", "", "", "");
				Assert.Fail("Failed to throw exception when updating a read-only version");
			}
			catch (Exception ex)
			{
				Assert.AreEqual(ex.Message, "Unable to update version information, this version is not the latest and therefore read-only");
			}

			try
			{
				version.NewMasterCatalogue("");
				Assert.Fail("Failed to throw exception when updating a read-only version");
			}
			catch (Exception ex)
			{
				Assert.AreEqual(ex.Message, "Unable to update version information, this version is not the latest and therefore read-only");
			}

			try
			{
				version.NewReferenceCatalgue("");
				Assert.Fail("Failed to throw exception when updating a read-only version");
			}
			catch (Exception ex)
			{
				Assert.AreEqual(ex.Message, "Unable to update version information, this version is not the latest and therefore read-only");
			}


			foreach (ICompiledPolicySetCache cps in version.CompiledPolicySets)
			{
				if (cps != null)
				{
					try
					{
						cps.Content = "try and update";
						Assert.Fail("Failed to throw exception when updating a read-only version");
					}
					catch (Exception ex)
					{
						Assert.AreEqual(ex.Message, "Unable to update version information, this version is not the latest and therefore read-only");
					}


					try
					{
						cps.ObjectReferences = "try and update";
						Assert.Fail("Failed to throw exception when updating a read-only version");
					}
					catch (Exception ex)
					{
						Assert.AreEqual(ex.Message, "Unable to update version information, this version is not the latest and therefore read-only");
					}

					try
					{
						cps.NewLanguage("", "", false);
						Assert.Fail("Failed to throw exception when updating a read-only version");
					}
					catch (Exception ex)
					{
						Assert.AreEqual(ex.Message, "Unable to update version information, this version is not the latest and therefore read-only");
					}

					foreach (IPolicyLanguageTableCache lplt in cps.Languages)
					{
						try
						{
							lplt.Content = "try and update";
							Assert.Fail("Failed to throw exception when updating a read-only version");
						}
						catch (Exception ex)
						{
							Assert.AreEqual(ex.Message, "Unable to update version information, this version is not the latest and therefore read-only");
						}
					}
				}
			}

			if (version.MasterCatalogue != null)
			{
				try
				{
					version.MasterCatalogue.Content = "try and update";
					Assert.Fail("Failed to throw exception when updating a read-only version");
				}
				catch (Exception ex)
				{
					Assert.AreEqual(ex.Message, "Unable to update version information, this version is not the latest and therefore read-only");
				}

				try
				{
					version.MasterCatalogue.NewLanguage("", "", false);
					Assert.Fail("Failed to throw exception when updating a read-only version");
				}
				catch (Exception ex)
				{
					Assert.AreEqual(ex.Message, "Unable to update version information, this version is not the latest and therefore read-only");
				}

				foreach (IPolicyLanguageTableCache lplt in version.MasterCatalogue.Languages)
				{
					try
					{
						lplt.Content = "try and update";
						Assert.Fail("Failed to throw exception when updating a read-only version");
					}
					catch (Exception ex)
					{
						Assert.AreEqual(ex.Message, "Unable to update version information, this version is not the latest and therefore read-only");
					}
				}
			}
		}