예제 #1
0
        public void CanSaveAndGetWithCulture()
        {
            string culture = "en";

            using (IScope scope = ScopeProvider.CreateScope())
            {
                IRedirectUrlRepository repo = CreateRepository(ScopeProvider);
                var rurl = new RedirectUrl
                {
                    ContentKey = _textpage.Key,
                    Url        = "blah",
                    Culture    = culture
                };
                repo.Save(rurl);
                scope.Complete();

                Assert.AreNotEqual(0, rurl.Id);
            }

            using (IScope scope = ScopeProvider.CreateScope())
            {
                IRedirectUrlRepository repo = CreateRepository(ScopeProvider);
                IRedirectUrl           rurl = repo.GetMostRecentUrl("blah");
                scope.Complete();

                Assert.IsNotNull(rurl);
                Assert.AreEqual(_textpage.Id, rurl.ContentId);
                Assert.AreEqual(culture, rurl.Culture);
            }
        }
예제 #2
0
        public void CanSaveAndGet()
        {
            IScopeProvider provider = ScopeProvider;

            using (IScope scope = provider.CreateScope())
            {
                IRedirectUrlRepository repo = CreateRepository(provider);
                var rurl = new RedirectUrl
                {
                    ContentKey = _textpage.Key,
                    Url        = "blah"
                };
                repo.Save(rurl);
                scope.Complete();

                Assert.AreNotEqual(0, rurl.Id);
            }

            using (IScope scope = provider.CreateScope())
            {
                IRedirectUrlRepository repo = CreateRepository(provider);
                IRedirectUrl           rurl = repo.GetMostRecentUrl("blah");
                scope.Complete();

                Assert.IsNotNull(rurl);
                Assert.AreEqual(_textpage.Id, rurl.ContentId);
            }
        }
예제 #3
0
        public void CanSaveAndGetMostRecentForCulture()
        {
            string cultureA = "en";
            string cultureB = "de";

            Assert.AreNotEqual(_textpage.Id, _otherpage.Id);

            using (IScope scope = ScopeProvider.CreateScope())
            {
                IRedirectUrlRepository repo = CreateRepository(ScopeProvider);
                var rurl = new RedirectUrl
                {
                    ContentKey = _textpage.Key,
                    Url        = "blah",
                    Culture    = cultureA
                };
                repo.Save(rurl);
                scope.Complete();

                Assert.AreNotEqual(0, rurl.Id);

                // FIXME: too fast = same date = key violation?
                // and... can that happen in real life?
                // we don't really *care* about the IX, only supposed to make things faster...
                // BUT in realife we AddOrUpdate in a trx so it should be safe, always
                rurl = new RedirectUrl
                {
                    ContentKey    = _otherpage.Key,
                    Url           = "blah",
                    CreateDateUtc = rurl.CreateDateUtc.AddSeconds(1), // ensure time difference
                    Culture       = cultureB
                };
                repo.Save(rurl);
                scope.Complete();

                Assert.AreNotEqual(0, rurl.Id);
            }

            using (IScope scope = ScopeProvider.CreateScope())
            {
                IRedirectUrlRepository repo = CreateRepository(ScopeProvider);
                IRedirectUrl           rurl = repo.GetMostRecentUrl("blah", cultureA);
                scope.Complete();

                Assert.IsNotNull(rurl);
                Assert.AreEqual(_textpage.Id, rurl.ContentId);
                Assert.AreEqual(cultureA, rurl.Culture);
            }
        }
예제 #4
0
        public void CanSaveAndGetByContent()
        {
            IScopeProvider provider = ScopeProvider;

            using (IScope scope = provider.CreateScope())
            {
                IRedirectUrlRepository repo = CreateRepository(provider);
                var rurl = new RedirectUrl
                {
                    ContentKey = _textpage.Key,
                    Url        = "blah"
                };
                repo.Save(rurl);
                scope.Complete();

                Assert.AreNotEqual(0, rurl.Id);

                // FIXME: goes too fast and bam, errors, first is blah
                rurl = new RedirectUrl
                {
                    ContentKey    = _textpage.Key,
                    Url           = "durg",
                    CreateDateUtc = rurl.CreateDateUtc.AddSeconds(1) // ensure time difference
                };
                repo.Save(rurl);
                scope.Complete();

                Assert.AreNotEqual(0, rurl.Id);
            }

            using (IScope scope = provider.CreateScope())
            {
                IRedirectUrlRepository repo  = CreateRepository(provider);
                IRedirectUrl[]         rurls = repo.GetContentUrls(_textpage.Key).ToArray();
                scope.Complete();

                Assert.AreEqual(2, rurls.Length);
                Assert.AreEqual("durg", rurls[0].Url);
                Assert.AreEqual("blah", rurls[1].Url);
            }
        }
예제 #5
0
        public void CanSaveAndDelete()
        {
            IScopeProvider provider = ScopeProvider;

            using (IScope scope = provider.CreateScope())
            {
                IRedirectUrlRepository repo = CreateRepository(provider);
                var rurl = new RedirectUrl
                {
                    ContentKey = _textpage.Key,
                    Url        = "blah"
                };
                repo.Save(rurl);
                scope.Complete();

                Assert.AreNotEqual(0, rurl.Id);

                rurl = new RedirectUrl
                {
                    ContentKey = _otherpage.Key,
                    Url        = "durg"
                };
                repo.Save(rurl);
                scope.Complete();

                Assert.AreNotEqual(0, rurl.Id);
            }

            using (IScope scope = provider.CreateScope())
            {
                IRedirectUrlRepository repo = CreateRepository(provider);
                repo.DeleteContentUrls(_textpage.Key);
                scope.Complete();

                IEnumerable <IRedirectUrl> rurls = repo.GetContentUrls(_textpage.Key);

                Assert.AreEqual(0, rurls.Count());
            }
        }
예제 #6
0
 public RedirectUrlService(
     ICoreScopeProvider provider,
     ILoggerFactory loggerFactory,
     IEventMessagesFactory eventMessagesFactory,
     IRedirectUrlRepository redirectUrlRepository)
     : base(provider, loggerFactory, eventMessagesFactory) =>
 public GetRedirectUrlQueryHandler(IRedirectUrlRepository repository)
 {
     _repository = repository;
 }
예제 #8
0
 public RedirectUrlService(IScopeProvider provider, ILogger logger, IEventMessagesFactory eventMessagesFactory,
                           IRedirectUrlRepository redirectUrlRepository)
     : base(provider, logger, eventMessagesFactory)
 {
     _redirectUrlRepository = redirectUrlRepository;
 }