Exemplo n.º 1
0
        [Test] //TODO: Ce test est-il encore valide ?
        public void IndexingContentData()
        {
            var content = new Content(Module[TestsConstants.ContentType.FolderTypeName], Cultures.FrenchCanadianCulture);

            content[Cultures.FrenchCanadianCulture][TestsConstants.ContentType.NamePropertyName].SetValue(TestsConstants.ContentType.FolderTypeName);

            content.CreateTranslationVersions();

            content[Cultures.FrenchCanadianCulture][TestsConstants.ContentType.NamePropertyName].SetValue(TestsConstants.ContentType.FolderTypeName + 2);

            using (var contentManager = DependencyResolver.Current.GetService <IContentManager>())
            {
                contentManager.Store(content);
                contentManager.SaveChanges();
            }

            RavenDBUtilities.WaitForStaleIndexes(DependencyResolver.Current.GetService <IDocumentStore>());

            List <Content> contents;

            using (var session = DependencyResolver.Current.GetService <IDocumentSession>())
            {
                contents = session.Advanced.LuceneQuery <Content, ContentTranslationVersionByNameIndex>()
                           .WhereEquals(TestsConstants.ContentType.NamePropertyName, TestsConstants.ContentType.FolderTypeName).ToList();;
            }

            Assert.That(contents.Count, Is.EqualTo(1));
            Assert.That(contents.ElementAt(0), Is.EqualTo(content));
        }
Exemplo n.º 2
0
        public void DeleteAllRoutes()
        {
            RavenDBUtilities.WaitForStaleIndexes(_documentSession.Advanced.DocumentStore);

            _documentSession.Advanced.DocumentStore.DatabaseCommands.DeleteByIndex("RouteIndex", new IndexQuery());

            RavenDBUtilities.WaitForStaleIndexes(_documentSession.Advanced.DocumentStore);
        }
Exemplo n.º 3
0
        public void FromClassInstanceToRavenDBAndBack()
        {
            IndexCreation.CreateIndexes(typeof(FakeClassIndex).Assembly, DependencyResolver.Current.GetService <IDocumentStore>());

            var fakeClassInstance = new FakeClass
            {
                Age  = 1,
                Date = new DateTime(2012, 12, 12, 12, 12, 12),
                Name = "Maxime Séguin"
            };

            using (var reflectionContentManager = DependencyResolver.Current.GetService <IReflectionContentManager>())
            {
                //TODO: Pas certain d'aimer que pour avoir un Content ça génère une query...
                var content = reflectionContentManager.GetNewOrUpdatedContent(fakeClassInstance).Item;
                reflectionContentManager.Store(content);
                reflectionContentManager.SaveChanges();
            }

            RavenDBUtilities.WaitForStaleIndexes(DependencyResolver.Current.GetService <IDocumentStore>());

            List <ContentTranslationVersion> contents;

            using (var session = DependencyResolver.Current.GetService <IDocumentSession>())
            {
                contents = session.Query <Content, FakeClassIndex>()
                           .AsProjection <ContentTranslationVersion>()
                           .ToList();
            }

            Assert.That(contents.Count, Is.EqualTo(1));

            List <FakeClass> fakeClasses;

            using (var session = DependencyResolver.Current.GetService <IDocumentSession>())
            {
                fakeClasses = session.Query <Content, FakeClassIndex>()
                              .AsProjection <FakeClass>()
                              .ToList();
            }

            Assert.That(fakeClasses.Count, Is.EqualTo(1));

            var savedFakeClassInstance = fakeClasses.ElementAt(0);

            Assert.That(savedFakeClassInstance.Age, Is.EqualTo(fakeClassInstance.Age));
            Assert.That(savedFakeClassInstance.Date, Is.EqualTo(fakeClassInstance.Date));
            Assert.That(savedFakeClassInstance.Name, Is.EqualTo(fakeClassInstance.Name));
        }