void SetInPropertyBagImpl(string key, object value, IPropertyBag bag)
        {
            if (FailureCount != -1)
            {
                this.failures++;

                if (this.failures == this.FailureCount)
                    this.SaveCount++;
                else
                {
                    var ex = new MSPUpdatedConcurrencyException();
                    throw ex.Instance;
                }
            }
            else
                this.SaveCount++;
        }
        public void SaveValueExceedsRetryFails()
        {
            //Arrange
            string key     = "{6313EE1A-5A12-46A3-A537-4905678FBD9E}";
            var    propBag = new BIPropertyBag();
            int    retry   = 0;
            bool   expectedExceptionThrown = false;

            propBag.ItemSetStringString = (k, v) =>
            {
                if (retry < 3)
                {
                    retry++;
                    var ex = new MSPUpdatedConcurrencyException();
                    throw ex.Instance;
                }
                else
                {
                    propBag.Values[k] = v;
                }
            };

            propBag.Values.Count = 0;
            var hierarchy = new BIConfigStack();

            hierarchy.Bags.Add(propBag);
            var target = new ConfigManager(hierarchy, new MockConfigSettingSerializer());

            //Act
            try
            {
                target.SetInPropertyBag(key, 3, propBag);
            }
            catch (ConfigurationException)
            {
                expectedExceptionThrown = true;
            }


            //Assert
            Assert.IsTrue(expectedExceptionThrown);
        }
        public void SaveValueWithRetrySucceeds()
        {
            //Arrange
            string key     = "{6313EE1A-5A12-46A3-A537-4905678FBD9E}";
            var    propBag = new BIPropertyBag();
            int    retry   = 0;

            propBag.ItemSetStringString = (k, v) =>
            {
                if (retry < 2)
                {
                    retry++;
                    var ex = new MSPUpdatedConcurrencyException();
                    throw ex.Instance;
                }
                else
                {
                    propBag.Values[k] = v;
                }
            };

            propBag.Values.Count = 0;
            var hierarchy = new BIConfigStack();

            hierarchy.Bags.Add(propBag);
            var target = new ConfigManager(hierarchy, new MockConfigSettingSerializer());

            //Act
            target.SetInPropertyBag(key, 3, propBag);

            //Assert
            Assert.IsTrue(target.ContainsKeyInPropertyBag(key, propBag));
            int value = target.GetFromPropertyBag <int>(key, propBag);

            Assert.IsTrue(value == 3);
        }
Beispiel #4
0
        void SetInPropertyBagImpl(string key, object value, SPFarm farm)
        {
            if (key == Constants.AreasConfigKey)
            {
                if (this.failureCount != -1)
                {
                    this.failures++;

                    if (this.failures == this.failureCount)
                    {
                        this.SaveCount++;
                    }
                    else
                    {
                        var ex = new MSPUpdatedConcurrencyException();
                        throw ex.Instance;
                    }
                }
                else
                {
                    this.SaveCount++;
                }
            }
        }