コード例 #1
0
        public async Task RunAsync_WhenMultipleEntriesWithSamePackageIdentityInSameBatch_Throws()
        {
            var zipWithWrongNameNuspec = CreateZipStreamWithEntry("Newtonsoft.Json.nuspec", _nuspecData);
            var indexJsonUri           = _catalogToDnxStorage.ResolveUri("/listedpackage/index.json");
            var nupkgUri       = _catalogToDnxStorage.ResolveUri("/listedpackage/1.0.0/listedpackage.1.0.0.nupkg");
            var nuspecUri      = _catalogToDnxStorage.ResolveUri("/listedpackage/1.0.0/listedpackage.nuspec");
            var nupkgStream    = File.OpenRead(@"Packages\ListedPackage.1.0.1.zip");
            var expectedNupkg  = GetStreamBytes(nupkgStream);
            var catalogStorage = Catalogs.CreateTestCatalogWithMultipleEntriesWithSamePackageIdentityInSameBatch();

            await _mockServer.AddStorageAsync(catalogStorage);

            _mockServer.SetAction(
                "/packages/listedpackage.1.0.0.nupkg",
                request => Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StreamContent(nupkgStream)
            }));

            var        front = new DurableCursor(_cursorJsonUri, _catalogToDnxStorage, MemoryCursor.MinValue);
            ReadCursor back  = MemoryCursor.CreateMax();

            var exception = await Assert.ThrowsAsync <InvalidOperationException>(
                () => _target.RunAsync(front, back, CancellationToken.None));

            Assert.Equal("The catalog batch 10/13/2015 6:40:07 AM contains multiple entries for the same package identity.  Package(s):  listedpackage 1.0.0", exception.Message);
        }