/// <summary> /// Returns the instance of MessageHandler. /// </summary> /// <param name="handlerName">MessageHandler Enumeration value.</param> /// <returns>IMessageHandler Instance.</returns> public IMessageHandler GetMessageHandler(MessageHandlerEnum handlerName) { IMessageHandler messageHandler = null; switch (handlerName) { case MessageHandlerEnum.PublishMessageHandler: messageHandler = new PublishQueueService(this.fileServiceFactory, this.repositoryService, this.queueRepository); break; case MessageHandlerEnum.VerifyMessageHandler: messageHandler = new VerifyFileQueueService(this.fileServiceFactory, this.repositoryService, this.queueRepository, this.blobRepository); break; } return messageHandler; }
/// <summary> /// Reuturns the PublishQueueServicer instance. /// </summary> /// <param name="nullMessageHandler">Indicates if the handler has to be returned or not.</param> /// <returns>MessaeRouter instance.</returns> private PublishQueueService GetPublishQueueService() { this.fileService = new StubIFileService() { PublishFilePublishMessage = (publishMessage) => { return "successfull"; }, GetFileByFileIdInt32 = (fileId) => { this.file = new File() { FileId = 1 }; return file; }, UpdateFileFile = (file) => { this.file = file; return true; }, }; this.fileServiceFactory = new StubIFileServiceFactory() { GetFileServiceString = (instanceName) => { return this.fileService; } }; this.repositoryService = new StubIRepositoryService() { GetRepositoryByIdInt32 = (repositoryId) => { return new Repository() { BaseRepository = new BaseRepository() { Name = "SkyDrive", BaseRepositoryId = 2 }, RepositoryId = 1, Name = "test" }; } }; this.queueRepository = new StubIQueueRepository() { AddMessageToQueueBaseMessage = (message) => { this.addedMessage = message; }, DeleteFromQueueBaseMessage = (message) => { this.deletedMessage = message; }, UpdateMessageBaseMessage = (message) => { this.updatedQueueContent = true; } }; PublishQueueService publishQueueService = new PublishQueueService(this.fileServiceFactory, this.repositoryService, this.queueRepository); return publishQueueService; }