public void VerifyGetAsValueDictionaryVersionOrderingIsDescendingMixedDigits()
        {
            var expectedChange1 = new DefaultChange(new ChangeVersion("0.10.0"), "Added", "This is the latest 0.10.0", DateTime.Today, "REL-1231");
            var expectedChange2 = new DefaultChange(new ChangeVersion("0.10.0"), "Removed", "This is the middle 0.10.0", DateTime.Today.AddHours(-2), "REL-1232");
            var expectedChange3 = new DefaultChange(new ChangeVersion("0.10.0"), "Removed", "This is the earliest 0.10.0", DateTime.Today.AddHours(-3), "REL-1233");
            var expectedChange4 = new DefaultChange(new ChangeVersion("0.9.0"), "Added", "This is a change", DateTime.Today.AddDays(-1), "REL-1234");
            var expectedChange5 = new DefaultChange(new ChangeVersion("0.9.0"), "Removed", "This is the middle 0.9.0", DateTime.Today.AddDays(-2), "REL-1235");
            var expectedChange6 = new DefaultChange(new ChangeVersion("0.9.0"), "Removed", "This is the earliest 0.9.0", DateTime.Today.AddDays(-3), "REL-1236");

            var changeCache = new ChangeCache();

            changeCache.Add(new List <IChange> {
                expectedChange1, expectedChange2, expectedChange3, expectedChange4, expectedChange5, expectedChange6
            });

            var actualValueDictionary = changeCache.GetAsValueDictionary();
            var actualVersions        = (List <Dictionary <string, object> >)actualValueDictionary["versions"];

            Assert.That(actualVersions[0]["version"], Is.EqualTo(expectedChange1.Version));
            Assert.That(actualVersions[1]["version"], Is.EqualTo(expectedChange4.Version));
        }
        public void VerifyGetAsValueDictionaryIsSuccessful()
        {
            var expectedChange1 = new DefaultChange("0.2.0", "Added", "This is the latest 0.2.0", DateTime.Today, "REL-1231");
            var expectedChange2 = new DefaultChange("0.2.0", "Removed", "This is the middle 0.2.0", DateTime.Today.AddHours(-2), "REL-1232");
            var expectedChange3 = new DefaultChange("0.2.0", "Removed", "This is the earliest 0.2.0", DateTime.Today.AddHours(-3), "REL-1233");
            var expectedChange4 = new DefaultChange("0.1.0", "Added", "This is a change", DateTime.Today.AddDays(-1), "REL-1234");
            var expectedChange5 = new DefaultChange("0.1.0", "Removed", "This is the middle 0.1.0", DateTime.Today.AddDays(-2), "REL-1235");
            var expectedChange6 = new DefaultChange("0.1.0", "Removed", "This is the earliest 0.1.0", DateTime.Today.AddDays(-3), "REL-1236");

            var changeCache = new ChangeCache();

            changeCache.Add(new List <IChange> {
                expectedChange1, expectedChange2, expectedChange3, expectedChange4, expectedChange5, expectedChange6
            });

            var actualValueDictionary = changeCache.GetAsValueDictionary();
            var actualVersions        = (List <Dictionary <string, object> >)actualValueDictionary["versions"];
            var version2                        = actualVersions.Find(v => v.ContainsValue("0.2.0"));
            var version2Tags                    = (List <Dictionary <string, object> >)version2["tags"];
            var version2AddedDictionary         = version2Tags.Find(t => t.ContainsValue("Added"));
            var version2AddedChanges            = (List <Dictionary <string, object> >)version2AddedDictionary["changes"];
            var version2AddedChangeSummaries    = version2AddedChanges.Select(c => c["summary"]);
            var version2AddedChangeReferences   = version2AddedChanges.Select(c => c["reference"]);
            var version2RemovedDictionary       = version2Tags.Find(t => t.ContainsValue("Removed"));
            var version2RemovedChanges          = (List <Dictionary <string, object> >)version2RemovedDictionary["changes"];
            var version2RemovedChangeSummaries  = version2RemovedChanges.Select(c => c["summary"]);
            var version2RemovedChangeReferences = version2RemovedChanges.Select(c => c["reference"]);

            Assert.That(version2["date"], Is.EqualTo(expectedChange1.Date.ToString("yyyy-MM-dd")));
            Assert.That(version2AddedChangeSummaries, Is.EquivalentTo(new List <string> {
                expectedChange1.Summary
            }));
            Assert.That(version2AddedChangeReferences, Is.EquivalentTo(new List <string> {
                expectedChange1.Reference
            }));
            Assert.That(version2RemovedChangeSummaries, Is.EquivalentTo(new List <string> {
                expectedChange2.Summary, expectedChange3.Summary
            }));
            Assert.That(version2RemovedChangeReferences, Is.EquivalentTo(new List <string> {
                expectedChange2.Reference, expectedChange3.Reference
            }));

            var version1                        = actualVersions.Find(v => v.ContainsValue("0.1.0"));
            var version1Tags                    = (List <Dictionary <string, object> >)version1["tags"];
            var version1AddedDictionary         = version1Tags.Find(t => t.ContainsValue("Added"));
            var version1AddedChanges            = (List <Dictionary <string, object> >)version1AddedDictionary["changes"];
            var version1AddedChangeSummaries    = version1AddedChanges.Select(c => c["summary"]);
            var version1AddedChangeReferences   = version1AddedChanges.Select(c => c["reference"]);
            var version1RemovedDictionary       = version1Tags.Find(t => t.ContainsValue("Removed"));
            var version1RemovedChanges          = (List <Dictionary <string, object> >)version1RemovedDictionary["changes"];
            var version1RemovedChangeSummaries  = version1RemovedChanges.Select(c => c["summary"]);
            var version1RemovedChangeReferences = version1RemovedChanges.Select(c => c["reference"]);

            Assert.That(version1["date"], Is.EqualTo(expectedChange4.Date.ToString("yyyy-MM-dd")));
            Assert.That(version1AddedChangeSummaries, Is.EquivalentTo(new List <string> {
                expectedChange4.Summary
            }));
            Assert.That(version1AddedChangeReferences, Is.EquivalentTo(new List <string> {
                expectedChange4.Reference
            }));
            Assert.That(version1RemovedChangeSummaries, Is.EquivalentTo(new List <string> {
                expectedChange5.Summary, expectedChange6.Summary
            }));
            Assert.That(version1RemovedChangeReferences, Is.EquivalentTo(new List <string> {
                expectedChange5.Reference, expectedChange6.Reference
            }));
        }