public void ShouldReturnEmptyWhenClaimIsBeforeGivenDateThreshold()
        {
            var ignoredClaim = ClaimEventBuilder.New().Build();            
            var claimRepo = CreateClaimRepositoryWithStubbedClaims(new []{ignoredClaim});
            
            var dateThreshold = ignoredClaim.CreatedDate.AddDays(1).ToString();
            var claimFilter = new CurrentClaimsFilter(claimRepo,dateThreshold);            

            Assert.Empty(claimFilter.Filter());
        }
Example #2
0
        public void ShouldFilterClaims()
        {
            var existingClaims = new[] {
                new ClaimEvent
                {
                    Identifier  = 1,
                    Event       = "Created",
                    Source      = "FakeClaimSource",
                    Predicate   = "has name",
                    CreatedDate = DateTime.Now
                },
                new ClaimEvent
                {
                    Identifier  = 2,
                    Event       = "Deleted",
                    Source      = "FakeClaimSource",
                    Predicate   = "has name",
                    CreatedDate = DateTime.Now.AddSeconds(1)
                },
                new ClaimEvent
                {
                    Identifier  = 3,
                    Event       = "Created",
                    Source      = "AnotherFakeClaimSource",
                    Predicate   = "has address",
                    CreatedDate = DateTime.Now.AddSeconds(4)
                },
                new ClaimEvent
                {
                    Identifier  = 4,
                    Event       = "Created",
                    Source      = "AnotherOneFakeClaimSource",
                    Predicate   = "has country",
                    CreatedDate = DateTime.Parse("2007-01-01")
                }
            };

            var claimRepo = new Mock <ClaimRepository>();

            claimRepo.Setup(c => c.Query()).Returns(existingClaims.AsQueryable());

            var claimFilter = new CurrentClaimsFilter(claimRepo.Object, "2008-01-01");

            Assert.Equal(claimFilter.DateThreshold, DateTime.Parse("2008-01-01"));

            var result = claimFilter.Filter();

            Assert.Single(result);
            Assert.Equal(existingClaims[2], result.First());
        }
        public void ShouldReturnMostRecentClaimWhenTheyHaveSamePredicateAndSource()
        {
            var claim = ClaimEventBuilder.New().Build();
            var latestClaim = ClaimEventBuilder.New()
                .WithSamePredicateAndSourceThan(claim)
                .WithCreatedDateLaterThan(claim).Build();
            
            var claimRepo = CreateClaimRepositoryWithStubbedClaims(new []{claim,latestClaim});

            var claimFilter = new CurrentClaimsFilter(claimRepo,DateTime.MinValue.ToString());           

            var result = claimFilter.Filter();
            
            Assert.Single(result);
            Assert.Equal(latestClaim, result.First());
        }