private CmdbRepository(IHubConnectionContext clients, IRepositoryAdapter<CmdbGraph<CmdbItem, CmdbDependency>> graphsAdapter, IRepositoryAdapter<CmdbItem> nodesAdapter, IRepositoryAdapter<CmdbDependency> edgesAdapter) { Clients = clients; _graphsAdapter = graphsAdapter; _nodesAdapter = nodesAdapter; _edgesAdapter = edgesAdapter; var applicationCategory = new CmdbItemCategory(1, "Application"); Categories = new Dictionary<long, CmdbItemCategory> {{applicationCategory.Id, applicationCategory}}; var applicationTypeAttribute = new CmdbAttributeDefinition {Id = 1, Name = "Application Type", Type = typeof (string), AuthorisedValues = new List<object> {"Desktop", "Service"}}; var languageAttribute = new CmdbAttributeDefinition { Id = 2, Name = "Language", Type = typeof(List<string>) }; var operationSystemAttribute = new CmdbAttributeDefinition { Id = 3, Name = "Operating System", Type = typeof(string) }; var itOwnerAttribute = new CmdbAttributeDefinition { Id = 4, Name = "IT Owner", Type = typeof(string) }; var urlAttribute = new CmdbAttributeDefinition {Id = 5, Name = "Url Link", Type = typeof (string)}; var businessOwnerAttribute = new CmdbAttributeDefinition {Id = 6, Name = "Business Owner", Type = typeof (string)}; var componentVersionAttribute = new CmdbAttributeDefinition {Id = 7, Name = "Version", Type = typeof (string)}; var criticalityAttribute = new CmdbAttributeDefinition {Id = 8, Name = "Criticality", Type = typeof (string)}; //non critical, critical, mission critical var vendorAttribute = new CmdbAttributeDefinition {Id = 9, Name = "Vendor", Type = typeof (bool)}; //var wikiAttribute = new CmdbAttributeDefinition {Id = 10, Name = "Wiki Url", Type = typeof (string)}; //var licencesAttribute = new CmdbAttributeDefinition {Id = 8, Name = "Licences", Type = typeof (List<string>)}; AttributeDefinitions = new Dictionary<long, ICollection<CmdbAttributeDefinition>>(); AttributeDefinitions[applicationCategory.Id] = new List<CmdbAttributeDefinition> { applicationTypeAttribute, languageAttribute, operationSystemAttribute, itOwnerAttribute, urlAttribute, businessOwnerAttribute, componentVersionAttribute, }; }
/// <summary> /// Initializes a new instance of the <see cref="DatabaseContext"/> class. /// </summary> /// <param name="connection"> /// The IDbConnection to use. /// </param> /// <param name="repositoryAdapter"> /// The name qualifier for the database. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="connection"/> or <paramref name="repositoryAdapter"/> is null. /// </exception> /// <remarks> /// The supplied IDbConnection will not be closed/disposed - that remains the responsibility of the caller. /// </remarks> public DatabaseContext( [NotNull] IDbConnection connection, [NotNull] IRepositoryAdapter repositoryAdapter) { this.Connection = connection ?? throw new ArgumentNullException(nameof(connection)); this.RepositoryAdapter = repositoryAdapter ?? throw new ArgumentNullException(nameof(repositoryAdapter)); this.isConnectionUserProvided = true; this.connectionString = connection.ConnectionString; this.pocoFactory = new RaisedPocoFactory(this.RepositoryAdapter.DefinitionProvider); }
/// <summary> /// Initializes a new instance of the <see cref="DatabaseContext"/> class. /// Construct a Database using a supplied connection string and a DbProviderFactory. /// </summary> /// <param name="connectionString"> /// The database connection string to use. /// </param> /// <param name="providerFactory"> /// The DbProviderFactory to use for instantiating IDbConnections. /// </param> /// <param name="repositoryAdapter"> /// The entity definition provider. /// </param> /// <exception cref="ArgumentException"> /// <paramref name="connectionString"/> is null or whitespace. /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="providerFactory"/> or <paramref name="repositoryAdapter"/> is null. /// </exception> public DatabaseContext( [NotNull] string connectionString, [NotNull] DbProviderFactory providerFactory, [NotNull] IRepositoryAdapter repositoryAdapter) { if (string.IsNullOrWhiteSpace(connectionString)) { throw new ArgumentException(ErrorMessages.ValueCannotBeNullOrWhiteSpace, nameof(connectionString)); } this.factory = providerFactory ?? throw new ArgumentNullException(nameof(providerFactory)); this.RepositoryAdapter = repositoryAdapter ?? throw new ArgumentNullException(nameof(repositoryAdapter)); this.connectionString = connectionString; this.pocoFactory = new RaisedPocoFactory(this.RepositoryAdapter.DefinitionProvider); }
/// <summary> /// Initializes a new instance of the <see cref="DefaultDatabaseContextFactory"/> class. /// </summary> /// <param name="connectionString"> /// The connection string. /// </param> /// <param name="providerName"> /// The provider name. /// </param> /// <param name="repositoryAdapter"> /// The definition provider. /// </param> /// <exception cref="ArgumentException"> /// <paramref name="connectionString"/> or <paramref name="providerName"/> is null or whitespace. /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="repositoryAdapter"/> is null. /// </exception> public DefaultDatabaseContextFactory( [NotNull] string connectionString, [NotNull] string providerName, [NotNull] IRepositoryAdapter repositoryAdapter) { if (string.IsNullOrWhiteSpace(connectionString)) { throw new ArgumentException(ErrorMessages.ValueCannotBeNullOrWhiteSpace, nameof(connectionString)); } if (string.IsNullOrWhiteSpace(providerName)) { throw new ArgumentException(ErrorMessages.ValueCannotBeNullOrWhiteSpace, nameof(providerName)); } this.repositoryAdapter = repositoryAdapter ?? throw new ArgumentNullException(nameof(repositoryAdapter)); this.connectionString = connectionString; this.providerName = providerName; }
public UiFlowContextDataRepositoryDecorator(IRepositoryAdapter decoratedRepository, IProfiler profiler) { _decoratedRepository = decoratedRepository; _profiler = profiler; }
public RepositoryManageSteps(IRepositoryAdapter repositoryAdapter) { _repositoryAdapter = repositoryAdapter; }
static void Execute(IRepositoryAdapter adapter) { new UseCase(adapter).OnStoryFinished(); }
public DefaultRepositoryMethodExecutor(TRepository repository, IRepositoryAdapter repositoryAdapter) { _repository = repository; _repositoryAdapter = repositoryAdapter; }
/// <summary> /// Returns the instance of SkyDriveFile Service /// </summary> /// <returns>SkyDriveFileService</returns> private SkyDriveFileService GetSkyDriveFileService() { this.repositoryService = new StubIRepositoryService() { GetRepositoryByIdInt32 = (repositoryId) => { return this.repository; }, }; this.userService = new StubIUserService() { GetUserAuthTokenInt32Int32 = (userId, RepositoryId) => { return this.userAuthToken; }, AddUpdateAuthTokenAuthToken = authToken => { return authToken; } }; this.fileRepository = new StubIFileRepository() { GetItemInt32Int32 = (userId, fileName) => { return new File() { Name = "test", FileId = 100, Status = "Uploaded" }; }, UpdateFileFile = (file) => { return file; } }; IUnitOfWork unitOfWork = new Fakes.StubIUnitOfWork() { Commit = () => { return; } }; this.blobDataRepository = new StubIBlobDataRepository() { GetBlobContentString = (name) => { return new DataDetail(); }, DeleteFileString = (fileName) => { return true; } }; this.skyDriveAdapter = new StubIRepositoryAdapter() { PostFilePublishFileModel = (publishFileModel) => { OperationStatus status = OperationStatus.CreateSuccessStatus(); status.CustomReturnValues = "x1234"; return status; }, RefreshTokenString = (accessToken) => { AuthToken authToken = new AuthToken() { AccessToken = "accessToken", RefreshToken = "refreshToken", TokenExpiresOn = DateTime.UtcNow.AddHours(1) }; return authToken; } }; IRepositoryAdapterFactory adapterFactory = new StubIRepositoryAdapterFactory() { GetRepositoryAdapterString = (baseRepositoryName) => { return skyDriveAdapter; } }; this.repositoryDetails = new StubIRepositoryDetails() { GetRepositoryByIdInt32 = id => new Repository() { BaseRepository = new BaseRepository() { Name = "Repository Type 1" } } }; SkyDriveFileService skyDriveFileService; using (ShimsContext.Create()) { ShimDiagnosticsProvider.ConstructorType = (dp, type) => { }; skyDriveFileService = new SkyDriveFileService(fileRepository, blobDataRepository, unitOfWork, repositoryDetails, repositoryService, userService, adapterFactory); } return skyDriveFileService; }
public void Allow_Download() { BaseRepository baseRepository = new BaseRepository() { BaseRepositoryId = 2, Name = "SkyDrive" }; this.repository = new Repository() { BaseRepositoryId = 2, Name = "test", IsImpersonating = false, BaseRepository = baseRepository }; RepositoryCredentials repositoryCredentials = new RepositoryCredentials(); File file = new File() { FileId = 1 }; User user = new User() { UserId = 1 }; var fileProvider = this.GetSkyDriveFileService(); this.skyDriveAdapter = new Microsoft.Research.DataOnboarding.RepositoryAdapters.Interfaces.Fakes.StubIRepositoryAdapter() { PostFilePublishFileModel = (publishFileModel) => { OperationStatus status = OperationStatus.CreateFailureStatus("error"); return status; }, DownloadFileStringStringString = (identifier, accessToken, fileName) => { return new DataFile(); } }; DataFile result; using (ShimsContext.Create()) { ShimSkyDriveFileService.AllInstances.GetOrUpdateAuthTokensRepositoryAuthToken = (skyDriveFileService, repository, authToken) => new AuthToken(); result = fileProvider.DownLoadFileFromRepository(file, this.repository, user, repositoryCredentials); } Assert.IsNotNull(result); }
public void Return_ErrorCode_When_Adapter_Returns_Failure() { // construct the model AuthToken authToken = new AuthToken() { AccessToken = "accessToken", RefreshToken = "refreshToken", TokenExpiresOn = DateTime.UtcNow.AddHours(-1), RespositoryId = 1 }; File fakeFile = new File() { Name = "test1", FileId = 100, RepositoryId = 1, CreatedBy = 1, Status = FileStatus.None.ToString() }; PublishMessage model = new PublishMessage() { RepositoryId = 3, AuthToken = authToken, FileId = fakeFile.FileId, UserId = 1 }; this.repository = new Repository() { BaseRepositoryId = 2, Name = "test", IsImpersonating = false, BaseRepository = new BaseRepository { Name = "SkyDrive" } }; this.userAuthToken = null; var fileProvider = this.GetSkyDriveFileService(); this.skyDriveAdapter = new Microsoft.Research.DataOnboarding.RepositoryAdapters.Interfaces.Fakes.StubIRepositoryAdapter() { PostFilePublishFileModel = (publishFileModel) => { OperationStatus status = OperationStatus.CreateFailureStatus("error"); return status; }, }; IFileProcesser fileProcessor = new StubIFileProcesser() { DownloadDocumentFile = file => new DataDetail() { FileNameToDownLoad = "abc.xyz" } }; string fileIdentifier; using (ShimsContext.Create()) { ShimFileFactory.GetFileTypeInstanceStringIBlobDataRepositoryIFileRepositoryIRepositoryService = (fileExtension, blobDataRepository, fileDataRepository, repositoryService) => fileProcessor; ShimSkyDriveFileService.AllInstances.GetOrUpdateAuthTokensRepositoryAuthToken = (skyDriveFileService, repository, at) => new AuthToken(); fileIdentifier = fileProvider.PublishFile(model); } Assert.IsTrue(string.IsNullOrEmpty(fileIdentifier)); }
public UseCase(IRepositoryAdapter adapter) { this.adapter = adapter; }