예제 #1
0
            internal Test(bool useStorage = true)
            {
                Handler     = new MockServerHttpClientHandler();
                _httpClient = new HttpClient(Handler);

                PackageFileName    = $"{PackageId.ToLowerInvariant()}.{PackageVersion.ToLowerInvariant()}.nupkg";
                Timestamp          = DateTime.UtcNow;
                ContentUri         = new Uri($"https://nuget.test/packages/{PackageFileName}");
                PackageUri         = Utilities.GetNugetCacheBustingUri(ContentUri, Timestamp.ToString("O"));
                Storage            = new Mock <IAzureStorage>(MockBehavior.Strict);
                Blob               = new Mock <ICloudBlockBlob>(MockBehavior.Strict);
                FeedPackageDetails = new FeedPackageDetails(
                    ContentUri,
                    Timestamp.AddHours(-3),
                    Timestamp.AddHours(-2),
                    Timestamp.AddHours(-1),
                    PackageId,
                    PackageVersion,
                    PackageVersion);

                var stream = TestHelper.GetStream(PackageFileName + ".testdata");

                Handler.SetAction(
                    PackageUri.PathAndQuery,
                    request => Task.FromResult(
                        new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StreamContent(stream)
                }));

                TelemetryService = new MockTelemetryService();

                Creator = PackageCatalogItemCreator.Create(
                    _httpClient,
                    TelemetryService,
                    Mock.Of <ILogger>(),
                    useStorage ? Storage.Object : null);
            }
예제 #2
0
        public ApplicationIdentityServiceTests()
        {
            BuildTestConfiguration();

            var memoryCache = new MemoryCache(new MemoryCacheOptions()
            {
            });
            var accessTokenRetriever = new TestAccessTokenRetriever();
            var telemetryService     = new MockTelemetryService();

            _graphService                    = new GraphService(memoryCache, _configuration, accessTokenRetriever, telemetryService);
            _testHttpContext                 = new DefaultHttpContext();
            _httpContextAccessor             = new HttpContextAccessor();
            _httpContextAccessor.HttpContext = _testHttpContext;

            var dbContextOptionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>();

            dbContextOptionsBuilder.UseInMemoryDatabase(Guid.NewGuid().ToString());
            _dbContext = new ApplicationDbContext(dbContextOptionsBuilder.Options, false, true, false);

            _applicationIdentityService = new ApplicationIdentityService(_dbContext, _graphService, _httpContextAccessor);

            SetApplicationUser();
        }