public void testPut_WithPrefix() { global::GitSharp.Core.Ref refA_one = newRef("refs/heads/A", ID_ONE); global::GitSharp.Core.Ref refA_two = newRef("refs/heads/A", ID_TWO); packed = toList(refA_one); RefMap map = new RefMap("refs/heads/", packed, loose, resolved); Assert.AreSame(refA_one, map.get("A")); Assert.AreSame(refA_one, map.put("A", refA_two)); // map changed, but packed, loose did not Assert.AreSame(refA_two, map.get("A")); Assert.AreSame(refA_one, packed.get(0)); Assert.AreEqual(0, loose.size()); Assert.AreSame(refA_two, map.put("A", refA_one)); Assert.AreSame(refA_one, map.get("A")); }
public void testPut_KeyMustMatchName_WithPrefix() { global::GitSharp.Core.Ref refA = newRef("refs/heads/A", ID_ONE); RefMap map = new RefMap("refs/heads/", packed, loose, resolved); try { map.put("FOO", refA); Assert.Fail("map accepted invalid key/value pair"); } catch (ArgumentException) { // expected } }
public void testPut_CollapseResolved() { global::GitSharp.Core.Ref master = newRef("refs/heads/master", ID_ONE); global::GitSharp.Core.Ref headU = newRef("HEAD", "refs/heads/master"); global::GitSharp.Core.Ref headR = newRef("HEAD", master); global::GitSharp.Core.Ref a = newRef("refs/heads/A", ID_ONE); loose = toList(headU, master); resolved = toList(headR); RefMap map = new RefMap("", packed, loose, resolved); Assert.IsNull(map.put(a.getName(), a)); Assert.AreSame(a, map.get(a.getName())); Assert.AreSame(headR, map.get("HEAD")); }
public void testPut_KeyMustMatchName_WithPrefix() { global::GitSharp.Core.Ref refA = newRef("refs/heads/A", ID_ONE); RefMap map = new RefMap("refs/heads/", packed, loose, resolved); try { map.put("FOO", refA); Assert.Fail("map accepted invalid key/value pair"); } catch (ArgumentException err) { // expected } }