public static SiteMinder WithNoSpam(this SiteMinder siteMinder, int?maxAttemptsWithinDuration = null,
                                            TimeSpan?withinDuration = null)
        {
            var fileStorage = new XmlFileStorageProvider <IpAddressRequest>();

            fileStorage.Initialise(new[] { GetXmlFolder() });
            var ruleSet = CreateRule <IpAddressBlockerRuleSetHandler, IpAddressRequest> .On <IpAddressRequest>()
                          .With(a => a.MaxAttemptsWithinDuration = maxAttemptsWithinDuration.GetValueOrDefault(100))
                          .With(a => a.Duration         = withinDuration.GetValueOrDefault(TimeSpan.FromDays(-1)))
                          .With(a => a.StorageMechanism = fileStorage)
                          .Build();

            return(siteMinder.AddRule <IpBlockerRuleSet, IpAddressBlockerRuleSetHandler, IpAddressRequest>(x => ruleSet));
        }
        public void CanPersist()
        {
            var list = new List <IpAddressRequest>
            {
                new IpAddressRequest()
                {
                    IpAddress = "127.0.0.1", CreatedUtcDateTime = DateTime.MaxValue
                }
            };

            _storageProvider.Items = list.AsQueryable();
            _storageProvider.SaveStorage();
            _storageProvider.Initialise(new[] { _temp });

            Assert.Equal(1, _storageProvider.Items.Count());
        }
 public XmlFileStorageProviderTests()
 {
     _storageProvider = new XmlFileStorageProvider <IpAddressRequest>();
     _storageProvider.Initialise(new[] { _temp });
     File.Delete(_storageProvider.FileName);
 }