public void TestInitialize() { _documentStore = DocumentStoreHelper.StartRaven(); _mockCommandProcessor = new Mock <ICommandProcessor>(); _mockUserContext = new Mock <IUserContext>(); _mockProjectsViewModelBuilder = new Mock <IProjectsViewModelBuilder>(); _mockTeamsViewModelBuilder = new Mock <ITeamsViewModelBuilder>(); _mockStreamItemsViewModelBuilder = new Mock <IStreamItemsViewModelBuilder>(); _mockObservationsViewModelBuilder = new Mock <IObservationsViewModelBuilder>(); _mockPostsViewModelBuilder = new Mock <IPostsViewModelBuilder>(); _mockReferenceSpeciesViewModelBuilder = new Mock <IReferenceSpeciesViewModelBuilder>(); using (var documentSession = _documentStore.OpenSession()) { _controller = new ProjectsController( _mockCommandProcessor.Object, _mockUserContext.Object, _mockProjectsViewModelBuilder.Object, _mockTeamsViewModelBuilder.Object, _mockStreamItemsViewModelBuilder.Object, _mockObservationsViewModelBuilder.Object, _mockPostsViewModelBuilder.Object, _mockReferenceSpeciesViewModelBuilder.Object, documentSession ); } }
/// <summary> /// Downloads the attachment as a stream. /// </summary> /// <param name="containerTitle">The container title.</param> /// <param name="entityId">The entity id.</param> /// <param name="fileName">Name of the file.</param> /// <returns></returns> public virtual Stream DownloadAttachment(string containerTitle, Guid entityId, string fileName) { var result = new MemoryStream(); SPSite site; var web = GetDocumentStoreWeb(out site); SPList list; SPFolder folder; if (SPDocumentStoreHelper.TryGetFolderFromPath(web, containerTitle, out list, out folder, String.Empty) == false) { return(null); } SPFile attachment; if (SPDocumentStoreHelper.TryGetDocumentStoreAttachment(list, folder, entityId, fileName, out attachment) == false) { return(null); } var attachmentStream = attachment.OpenBinaryStream(); DocumentStoreHelper.CopyStream(attachmentStream, result); result.Seek(0, SeekOrigin.Begin); return(result); }
public void InitializeDocumentStore_Throws_WhenUrlsIsEmptyCollection() { Assert.Throws <InvalidOperationException>(() => DocumentStoreHelper.InitializeDocumentStore(store => { store.Database = "some-database-name"; store.Urls = new string [] { }; })); }
public void TestInitialize() { _documentStore = DocumentStoreHelper.StartRaven(); using (var documentSession = _documentStore.OpenSession()) { } }
public void InitializeDocumentStore_Throws_WhenDatabaseNameIsNotProvided() { Assert.Throws <InvalidOperationException>(() => DocumentStoreHelper.InitializeDocumentStore(store => { store.Database = null; store.Urls = new[] { "http://some-url" }; })); }
public override EntityPart GetEntityPart(string containerTitle, Guid entityId, string partName) { //Get a new web in case we're executing in elevated permissions. using (var site = new SPSite(this.DocumentStoreUrl)) { using (var web = site.OpenWeb()) { var contentsHash = SPDocumentStoreHelper.GetEntityContentsHash(web, containerTitle, entityId); //If the contents hash is not set, fall back on just retrieving the entity. if (String.IsNullOrEmpty(contentsHash)) { return(base.GetEntityPart(containerTitle, entityId, partName)); } //If we found it in the cache, return the entity value. var cachedValue = HttpRuntime.Cache[EntityContentsCachePrefix + "_" + entityId + "_" + contentsHash]; if (cachedValue is EntityContents) { var cachedEntityContents = cachedValue as EntityContents; //If it hasn't changed, return a clone of the entity part. if (cachedEntityContents.Entity.ContentsETag == contentsHash) { if (cachedEntityContents.EntityParts.ContainsKey(partName) == false) { return(null); } return(DocumentStoreHelper.CloneObject(cachedEntityContents.EntityParts[partName])); } } var entityContents = GetEntityContents(web, containerTitle, entityId); HttpRuntime.Cache.Add(EntityContentsCachePrefix + "_" + entityId + "_" + contentsHash, entityContents, null, Cache.NoAbsoluteExpiration, CacheSlidingExpiration, CacheItemPriority.Normal, null); if (entityContents.EntityParts.ContainsKey(partName) == false) { return(null); } return(DocumentStoreHelper.CloneObject(entityContents.EntityParts[partName])); } } }
public void TestInitialize() { _documentStore = DocumentStoreHelper.StartRaven(); _mockCommandProcessor = new Mock <ICommandProcessor>(); _mockObservationsViewModelBuilder = new Mock <IObservationsViewModelBuilder>(); _mockUserContext = new Mock <IUserContext>(); _controller = new ObservationsController( _mockCommandProcessor.Object, _mockUserContext.Object, _mockObservationsViewModelBuilder.Object ); }
private static void CreateOrUpdateCachedFile(SPFile spFile, SPDirectory directory) { using (var spFileStream = spFile.OpenBinaryStream()) { using (var outputStream = directory.CreateCachedOutputAsStream(spFile.Name)) { DocumentStoreHelper.CopyStream(spFileStream, outputStream); outputStream.Flush(); } } directory.WriteCachedFileETag(spFile.Name, spFile.ETag); }
public void TestInitialize() { //_documentStore = DocumentStoreHelper.ServerDocumentStore(); _documentStore = DocumentStoreHelper.StartRaven(); _mockCommandProcessor = new Mock <ICommandProcessor>(); _mockUserContext = new Mock <IUserContext>(); _controller = new HomeController( _mockCommandProcessor.Object, _mockUserContext.Object ); }
public void TestInitialize() { _documentStore = DocumentStoreHelper.StartRaven(); _mockCommandProcessor = new Mock <ICommandProcessor>(); _mockUserContext = new Mock <IUserContext>(); _mockAccountViewModelBuilder = new Mock <IAccountViewModelBuilder>(); _controller = new AccountController( _mockCommandProcessor.Object, _mockUserContext.Object, _documentStore.OpenSession(), _mockAccountViewModelBuilder.Object ); }
private static void Main() { Log.Logger = DocumentStoreLogger.LoggerConfig; try { DocumentStoreHelper.Cleanup(); } catch (Exception ex) { Log.Fatal(ex, "Host terminated unexpectedly."); } finally { Log.CloseAndFlush(); } }
public void TestInitialize() { _documentStore = DocumentStoreHelper.StartRaven(); _mockCommandProcessor = new Mock <ICommandProcessor>(); _mockUserContext = new Mock <IUserContext>(); _mockUserViewModelBuilder = new Mock <IUserViewModelBuilder>(); _mockStreamItemsViewModelBuilder = new Mock <IStreamItemsViewModelBuilder>(); _mockProjectsViewModelBuilder = new Mock <IProjectsViewModelBuilder>(); _mockPostsViewModelBuilder = new Mock <IPostsViewModelBuilder>(); _mockTeamsViewModelBuilder = new Mock <ITeamsViewModelBuilder>(); _controller = new UsersController( _mockCommandProcessor.Object, _mockUserContext.Object, _mockUserViewModelBuilder.Object, _mockStreamItemsViewModelBuilder.Object, _mockProjectsViewModelBuilder.Object, _mockPostsViewModelBuilder.Object, _mockTeamsViewModelBuilder.Object ); }
internal SPFolder CreateFolderInternal(SPWeb web, string containerTitle, string path) { SPList list; if (SPDocumentStoreHelper.TryGetListForContainer(web, containerTitle, out list) == false) { throw new InvalidOperationException("A container with the specified title does not exist: " + web.Url + " " + containerTitle); } var currentFolder = list.RootFolder; web.AllowUnsafeUpdates = true; try { foreach (var subFolder in DocumentStoreHelper.GetPathSegments(path)) { if (currentFolder.SubFolders.OfType <SPFolder>().Any(sf => sf.Name == subFolder) == false) { var folder = currentFolder.SubFolders.Add(subFolder); //Ensure that the content type is, well, a folder and not a doc set. :-0 var folderListContentType = list.ContentTypes.BestMatch(SPBuiltInContentTypeId.Folder); if (folder.Item.ContentTypeId != folderListContentType) { folder.Item["ContentTypeId"] = folderListContentType; folder.Item.Update(); } } currentFolder = currentFolder.SubFolders[subFolder]; } } finally { web.AllowUnsafeUpdates = false; } return(currentFolder); }
public void Certificate_IsDisposed_WhenDocumentStoreIsDisposed() { var certificate = GetCertificate(); IDocumentStore store; using (store = DocumentStoreHelper.InitializeDocumentStore(documentStore => { documentStore.Urls = new[] { "https://127.0.0.1:54987" }; documentStore.Database = "some-database"; documentStore.Certificate = certificate; })) { AssertDocumentStoreNotDisposed(store); AssertCertificateCreated(store); } AssertDocumentStoreDisposed(store); AssertCertificateDisposed(store); }
public void TestInitialize() { _documentStore = DocumentStoreHelper.StartRaven(); _mockUserContext = new Mock <IUserContext>(); _mockCommandProcessor = new Mock <ICommandProcessor>(); _mockOrganisationsViewModelBuilder = new Mock <IOrganisationsViewModelBuilder>(); _mockStreamItemsViewModelBuilder = new Mock <IStreamItemsViewModelBuilder>(); _mockTeamsViewModelBuilder = new Mock <ITeamsViewModelBuilder>(); _mockPostsViewModelBuilder = new Mock <IPostsViewModelBuilder>(); _mockMemberViewModelBuilder = new Mock <IMemberViewModelBuilder>(); _mockReferenceSpeciesViewModelBuilder = new Mock <IReferenceSpeciesViewModelBuilder>(); _controller = new OrganisationsController( _mockCommandProcessor.Object, _mockUserContext.Object, _mockOrganisationsViewModelBuilder.Object, _mockStreamItemsViewModelBuilder.Object, _mockTeamsViewModelBuilder.Object, _mockPostsViewModelBuilder.Object, _mockMemberViewModelBuilder.Object, _mockReferenceSpeciesViewModelBuilder.Object ); }
public void TestInitialize() { _store = DocumentStoreHelper.StartRaven(); }
public OperationalDocumentStoreHolder(RavenDbOperationalStoreOptions options) { _documentStore = DocumentStoreHelper.InitializeDocumentStore(options.ConfigureDocumentStore); IndexHelper.ExecuteOperationalStoreIndexes(_documentStore); }
public void TestInitialize() { // start raven without seeding with data _store = DocumentStoreHelper.StartRaven(); }
public void TestCleanup() { _documentStore = null; DocumentStoreHelper.KillRaven(); }
public void TestInitialize() { _documentStore = DocumentStoreHelper.TestDocumentStore(); IndexCreation.CreateIndexes(typeof(StreamItem_WithParentIdAndUserIdAndCreatedDateTimeAndType).Assembly, _documentStore); }
public void TestInitialize() { _store = DocumentStoreHelper.StartRaven(); _mockMediaFilePathService = new Mock <IMediaFilePathService>(); }
public void TestInitialize() { _documentStore = DocumentStoreHelper.TestDocumentStore(); IndexCreation.CreateIndexes(typeof(User_WithUserIdAndEmail).Assembly, _documentStore); }
public void TestInitialize() { _documentStore = DocumentStoreHelper.TestDocumentStore(); IndexCreation.CreateIndexes(typeof(TeamMember_WithTeamIdAndUserId).Assembly, _documentStore); }
public void TestInitialize() { _mockCommandProcessor = new Mock <ICommandProcessor>(); _mockUserContext = new Mock <IUserContext>(); _documentStore = DocumentStoreHelper.StartRaven(); }
public void TestCleanup() { DocumentStoreHelper.KillRaven(); }
public void TestInitialize() { _documentStore = DocumentStoreHelper.RamDocumentStore(); }
public void TestInitialize() { _store = DocumentStoreHelper.InMemoryDocumentStore(); }