Пример #1
0
        /// <summary>
        ///   Add information on a tag that is expected to be updated during a fetch.
        /// </summary>
        /// <param name="tagName">Name of the tag.</param>
        /// <param name="oldId">Old ID of the tag.</param>
        /// <param name="tag">Datastructure containing expected updated tag information.</param>
        public void AddExpectedTag(string tagName, ObjectId oldId, TestRemoteInfo.ExpectedTagInfo tag)
        {
            string tagReferenceBase = "refs/tags/";

            ExpectedTags.Add(tagReferenceBase + tagName, tag);

            ObjectId referenceId = tag.IsAnnotated ? tag.AnnotationId : tag.TargetId;

            ExpectedReferenceUpdates.Add(tagReferenceBase + tagName, new ReferenceUpdate(oldId, referenceId));
        }
Пример #2
0
        /// <summary>
        ///   Check that all expected references have been updated.
        /// </summary>
        /// <param name="repo">Repository object whose state will be checked against expected state.</param>
        public void CheckUpdatedReferences(Repository repo)
        {
            // Verify the expected branches.
            // First, verify the expected branches have been created and
            List <string> sortedObservedBranches = repo.Branches.Select(branch => branch.CanonicalName).ToList();

            sortedObservedBranches.Sort();
            List <string> sortedExpectedBranches = ExpectedBranchTips.Keys.ToList();

            sortedExpectedBranches.Sort();
            Assert.Equal(sortedExpectedBranches, sortedObservedBranches);

            // Verify branches reference expected commits.
            foreach (KeyValuePair <string, ObjectId> kvp in ExpectedBranchTips)
            {
                Branch branch = repo.Branches[kvp.Key];
                Assert.NotNull(branch);
                Assert.Equal(kvp.Value, branch.Tip.Id);
            }

            // Verify the expected tags
            // First, verify the expected tags have been created
            List <string> sortedObservedTags = repo.Tags.Select(tag => tag.CanonicalName).ToList();

            sortedObservedTags.Sort();
            List <string> sortedExpectedTags = ExpectedTags.Keys.ToList();

            sortedExpectedTags.Sort();
            Assert.Equal(sortedExpectedTags, sortedObservedTags);

            // Verify tags reference the expected IDs.
            foreach (KeyValuePair <string, TestRemoteInfo.ExpectedTagInfo> kvp in ExpectedTags)
            {
                Tag tag = repo.Tags[kvp.Key];
                TestRemoteInfo.ExpectedTagInfo expectedTagInfo = kvp.Value;

                Assert.NotNull(tag);
                Assert.NotNull(tag.Target);

                Assert.Equal(expectedTagInfo.TargetId, tag.Target.Id);

                if (expectedTagInfo.IsAnnotated)
                {
                    Assert.NotNull(tag.Annotation);
                    Assert.Equal(expectedTagInfo.AnnotationId, tag.Annotation.Id);
                }
            }

            // We have already verified that all observed reference updates are expected,
            // verify that we have seen all expected reference updates.
            Assert.Equal(ExpectedReferenceUpdates.Count, ObservedReferenceUpdates.Count);
        }