Exemplo n.º 1
0
		public void DeleteThrowsIfHasMultipleConfigStores()
		{
			const string name = nameof(AffiliateApplicationFixture) + ".MultipleConfigStores";
			try
			{
				var affiliateApplication = AffiliateApplication.FindByName(name) ?? AffiliateApplication.Create(name);

				var defaultConfigStore = new ConfigStore(affiliateApplication.Name, ConfigStoreCollection.DEFAULT_CONFIG_STORE_IDENTIFIER) {
					Properties = { ["key1"] = "value1" }
				};
				Invoking(() => defaultConfigStore.Save()).Should().NotThrow();

				var otherConfigStore = new ConfigStore.ConfigStoreProperties(affiliateApplication.Name, Guid.NewGuid().ToString("B")) {
					Properties = { ["key2"] = "value2" }
				};
				Invoking(() => otherConfigStore.Save()).Should().NotThrow();

				AffiliateApplication.FindByName(name).ConfigStores.Should().HaveCount(2);

				Invoking(() => affiliateApplication.Delete())
					.Should().Throw<InvalidOperationException>()
					.WithMessage(
						$"To prevent any destructive effects, BizTalk.Factory will not delete an {nameof(AffiliateApplication)} that it has not created or that has other {nameof(ConfigStore)}s than the default one.");

				otherConfigStore.Delete();
			}
			finally
			{
				AffiliateApplication.FindByName(name)?.Delete();
			}
		}
        public void UpdateExistentDefaultConfigStoreWithValueUpdates()
        {
            try
            {
                var newConfigStore = new ConfigStore(_affiliateApplication.Name, ConfigStoreCollection.DEFAULT_CONFIG_STORE_IDENTIFIER);
                newConfigStore.SettingsShouldBeInitialized();

                newConfigStore.Properties["Key1"] = "Value1";
                newConfigStore.Properties["Key2"] = "Value2";
                newConfigStore.Save();

                var existentConfigStore = new ConfigStore(_affiliateApplication.Name, ConfigStoreCollection.DEFAULT_CONFIG_STORE_IDENTIFIER);
                existentConfigStore.Properties.Should().BeEquivalentTo(newConfigStore.Properties);
                existentConfigStore.Properties["Key1"] = "Value3";
                existentConfigStore.Properties["Key2"] = "Value4";
                existentConfigStore.Save();

                var reloadConfigStore = new ConfigStore(_affiliateApplication.Name, ConfigStoreCollection.DEFAULT_CONFIG_STORE_IDENTIFIER);
                reloadConfigStore.Properties.Should().NotContainValues("Value1", "Value2");
                reloadConfigStore.Properties.Should().BeEquivalentTo(existentConfigStore.Properties);
            }
            finally
            {
                var configStore = new ConfigStore(_affiliateApplication.Name, ConfigStoreCollection.DEFAULT_CONFIG_STORE_IDENTIFIER);
                configStore.Delete();
            }
        }
        public void SaveNonexistentNonDefaultConfigStoreThrows()
        {
            var configStore = new ConfigStore(_affiliateApplication.Name, Guid.NewGuid().ToString("B"));

            Action(() => configStore.Save())
            .Should().Throw <InvalidOperationException>()
            .WithMessage("Cannot save or overwrite the properties of a ConfigStore other than the default one.");
        }
        public void DeleteExistentDefaultConfigStoreDoesNotThrow()
        {
            var configStore = new ConfigStore(_affiliateApplication.Name, ConfigStoreCollection.DEFAULT_CONFIG_STORE_IDENTIFIER);

            configStore.SettingsShouldBeInitialized();
            configStore.Properties["Key1"] = "Value1";
            configStore.Save();
            Action(() => configStore.Delete()).Should().NotThrow();
        }
Exemplo n.º 5
0
        public void DeleteExistentDefaultConfigStoreDoesNotThrow()
        {
            var configStore = new ConfigStore(_affiliateApplication.Name, ConfigStoreCollection.DEFAULT_CONFIG_STORE_IDENTIFIER);

            configStore.Properties.Count.Should().Be(0);
            configStore.Properties["Key1"] = "Value1";
            configStore.Save();
            Invoking(() => configStore.Delete()).Should().NotThrow();
        }
        public void LoadExistentDefaultConfigStore()
        {
            try
            {
                var newConfigStore = new ConfigStore(_affiliateApplication.Name, ConfigStoreCollection.DEFAULT_CONFIG_STORE_IDENTIFIER);
                newConfigStore.Properties["Key1"] = "Value1";
                newConfigStore.Properties["Key2"] = "Value2";
                newConfigStore.Save();

                var existentConfigStore = new ConfigStore(_affiliateApplication.Name, ConfigStoreCollection.DEFAULT_CONFIG_STORE_IDENTIFIER);
                existentConfigStore.Properties.Should().NotBeEmpty();
            }
            finally
            {
                new ConfigStore(_affiliateApplication.Name, ConfigStoreCollection.DEFAULT_CONFIG_STORE_IDENTIFIER).Delete();
            }
        }
Exemplo n.º 7
0
        public void SaveAndLoadEmptyDefaultConfigStore()
        {
            try
            {
                var configStore = new ConfigStore(_affiliateApplication.Name, ConfigStoreCollection.DEFAULT_CONFIG_STORE_IDENTIFIER);
                configStore.Properties.Should().BeEmpty();
                configStore.Save();

                configStore = new(_affiliateApplication.Name, ConfigStoreCollection.DEFAULT_CONFIG_STORE_IDENTIFIER);
                Invoking(() => configStore.Properties).Should().NotThrow();
            }
            finally
            {
                var configStore = new ConfigStore(_affiliateApplication.Name, ConfigStoreCollection.DEFAULT_CONFIG_STORE_IDENTIFIER);
                configStore.Delete();
            }
        }
        public void PropertyNameIsCaseInsensitive()
        {
            try
            {
                var configStore = new ConfigStore(_affiliateApplication.Name, ConfigStoreCollection.DEFAULT_CONFIG_STORE_IDENTIFIER);
                configStore.SettingsShouldBeInitialized();

                configStore.Properties["PropertyNameWithCasing"] = "Value1";
                configStore.Save();

                configStore.Properties["propertynamewithcasing"].Should().Be("Value1");
            }
            finally
            {
                var configStore = new ConfigStore(_affiliateApplication.Name, ConfigStoreCollection.DEFAULT_CONFIG_STORE_IDENTIFIER);
                configStore.Delete();
            }
        }
        public void SaveNonexistentDefaultConfigStore()
        {
            try
            {
                var configStore = new ConfigStore(_affiliateApplication.Name, ConfigStoreCollection.DEFAULT_CONFIG_STORE_IDENTIFIER);
                configStore.SettingsShouldBeInitialized();

                configStore.Properties["Key1"] = "Value1";
                configStore.Properties["Key2"] = "Value2";
                configStore.Save();

                var reloadConfigStore = new ConfigStore(_affiliateApplication.Name, ConfigStoreCollection.DEFAULT_CONFIG_STORE_IDENTIFIER);
                reloadConfigStore.Properties.Should().BeEquivalentTo(configStore.Properties);
            }
            finally
            {
                var configStore = new ConfigStore(_affiliateApplication.Name, ConfigStoreCollection.DEFAULT_CONFIG_STORE_IDENTIFIER);
                configStore.Delete();
            }
        }