public async Task GetByPackageWithException()
        {
            // Arrange
            var statusService = new PackageMonitoringStatusService(
                new MemoryStorageFactory(),
                new Mock <ILogger <PackageMonitoringStatusService> >().Object);

            var undesiredStatuses = new PackageMonitoringStatus[]
            {
                PackageMonitoringStatusTestUtility.CreateStatusWithPackageValidationResult(
                    "json.newtonsoft",
                    "1.0.9",
                    TestResult.Pass),
                PackageMonitoringStatusTestUtility.CreateStatusWithPackageValidationResult(
                    "json.newtonsoft.json",
                    "1.0.9.1",
                    TestResult.Fail),
                PackageMonitoringStatusTestUtility.CreateStatusWithPackageValidationResult(
                    "j.n.j",
                    "1.9.1",
                    TestResult.Skip),
                PackageMonitoringStatusTestUtility.CreateStatusWithPackageValidationResult(
                    "newtonsoft.json",
                    "9.0.2",
                    TestResult.Pass)
            };

            var desiredPackageId      = "newtonsoft.json";
            var desiredPackageVersion = "9.0.1";
            var desiredStatus         = PackageMonitoringStatusTestUtility.CreateStatusWithException(desiredPackageId, desiredPackageVersion);

            await statusService.UpdateAsync(desiredStatus, CancellationToken.None);

            await Task.WhenAll(undesiredStatuses.Select(s => statusService.UpdateAsync(s, CancellationToken.None)));

            // Act
            var status = await statusService.GetAsync(new FeedPackageIdentity(desiredPackageId, desiredPackageVersion), CancellationToken.None);

            // Assert
            PackageMonitoringStatusTestUtility.AssertStatus(desiredStatus, status);
        }
        public async Task GetByState()
        {
            // Arrange
            var statusService = new PackageMonitoringStatusService(
                new MemoryStorageFactory(),
                new Mock <ILogger <PackageMonitoringStatusService> >().Object);

            var expectedValidStatuses = new PackageMonitoringStatus[]
            {
                PackageMonitoringStatusTestUtility.CreateStatusWithPackageValidationResult(
                    "newtonsoft.json", "9.0.2", TestResult.Pass),
                PackageMonitoringStatusTestUtility.CreateStatusWithPackageValidationResult(
                    "a.b", "1.2.3", TestResult.Pass),
                PackageMonitoringStatusTestUtility.CreateStatusWithPackageValidationResult(
                    "newtonsoft.json", "6.0.8", TestResult.Skip),
                PackageMonitoringStatusTestUtility.CreateStatusWithPackageValidationResult(
                    "a.b", "0.8.9", TestResult.Skip)
            };

            var expectedInvalidStatuses = new PackageMonitoringStatus[]
            {
                PackageMonitoringStatusTestUtility.CreateStatusWithPackageValidationResult(
                    "jQuery",
                    "3.1.2",
                    new ValidationResult[]
                {
                    PackageMonitoringStatusTestUtility.CreateValidationResult(
                        TestResult.Fail,
                        new ValidationException("malarky!"))
                }),
                PackageMonitoringStatusTestUtility.CreateStatusWithPackageValidationResult(
                    "EntityFramework",
                    "6.1.2",
                    new ValidationResult[]
                {
                    PackageMonitoringStatusTestUtility.CreateValidationResult(
                        TestResult.Fail,
                        new ValidationException("absurd!"))
                }),
                PackageMonitoringStatusTestUtility.CreateStatusWithException(
                    "NUnit",
                    "3.6.1")
            };

            var expectedUnknownStatuses = new PackageMonitoringStatus[]
            {
                PackageMonitoringStatusTestUtility.CreateStatusWithPackageValidationResult(
                    "xunit", "2.4.1", TestResult.Pending),
                PackageMonitoringStatusTestUtility.CreateStatusWithPackageValidationResult(
                    "a.b", "99.9.99", TestResult.Pending)
            };

            foreach (var expectedValidStatus in expectedValidStatuses)
            {
                await statusService.UpdateAsync(expectedValidStatus, CancellationToken.None);
            }

            foreach (var expectedInvalidStatus in expectedInvalidStatuses)
            {
                await statusService.UpdateAsync(expectedInvalidStatus, CancellationToken.None);
            }

            foreach (var expectedSkippedStatus in expectedUnknownStatuses)
            {
                await statusService.UpdateAsync(expectedSkippedStatus, CancellationToken.None);
            }

            // Act
            var validStatuses = await statusService.GetAsync(PackageState.Valid, CancellationToken.None);

            var invalidStatuses = await statusService.GetAsync(PackageState.Invalid, CancellationToken.None);

            var unknownStatuses = await statusService.GetAsync(PackageState.Unknown, CancellationToken.None);

            // Assert
            PackageMonitoringStatusTestUtility.AssertAll(
                expectedValidStatuses.OrderBy(s => s.Package.Id).ThenBy(s => s.Package.Version),
                validStatuses.OrderBy(s => s.Package.Id).ThenBy(s => s.Package.Version),
                PackageMonitoringStatusTestUtility.AssertStatus);

            PackageMonitoringStatusTestUtility.AssertAll(
                expectedInvalidStatuses.OrderBy(s => s.Package.Id).ThenBy(s => s.Package.Version),
                invalidStatuses.OrderBy(s => s.Package.Id).ThenBy(s => s.Package.Version),
                PackageMonitoringStatusTestUtility.AssertStatus);

            PackageMonitoringStatusTestUtility.AssertAll(
                expectedUnknownStatuses.OrderBy(s => s.Package.Id).ThenBy(s => s.Package.Version),
                unknownStatuses.OrderBy(s => s.Package.Id).ThenBy(s => s.Package.Version),
                PackageMonitoringStatusTestUtility.AssertStatus);
        }