Ejemplo n.º 1
0
    public IEnumerator TestMergeWorkerSmoke()
    {
        testObject1.transform.position = new Vector2(0.0f, 0.0f);
        testObject2.transform.position = new Vector2(3.0f, 3.0f);

        VersionManager.Instance().Add(testController1);
        VersionManager.Instance().Add(testController2);

        ICommit commit = VersionManager.Instance().Commit("Add two objects");

        yield return(null);

        IBranch testBranch = VersionManager.Instance().CreateBranch("testBranch");

        VersionManager.Instance().Checkout("testBranch");

        testObject1.transform.position = new Vector2(1.0f, 0.0f);
        VersionManager.Instance().Add(testController1);
        ICommit secondCommit = VersionManager.Instance().Commit("Move testObject1");

        VersionManager.Instance().Checkout("master");

        Assert.AreEqual("master", master.GetName());
        Assert.AreSame(commit, master.GetTip());
        Assert.AreEqual("testBranch", testBranch.GetName());
        Assert.AreSame(secondCommit, testBranch.GetTip());

        IMergeWorker mw = new MergeWorker(master, testBranch, null, null);

        Assert.AreEqual(Relationship.FastForward, mw.GetMergeType());
        Assert.AreEqual(MergeStatus.FastForward, mw.GetStatus(testController1));
        Assert.AreEqual(MergeStatus.FastForward, mw.GetStatus(testController2));
        Assert.AreEqual(true, mw.IsResolved());
    }
Ejemplo n.º 2
0
    public IEnumerator TestMergeFF()
    {
        testObject1.transform.position = new Vector2(0.0f, 0.0f);
        testObject2.transform.position = new Vector2(3.0f, 3.0f);

        VersionManager.Instance().Add(testController1);
        VersionManager.Instance().Add(testController2);

        ICommit commit = VersionManager.Instance().Commit("Add two objects");

        yield return(null);

        IBranch testBranch = VersionManager.Instance().CreateBranch("testBranch");

        VersionManager.Instance().Checkout("testBranch");

        testObject1.transform.position = new Vector2(1.0f, 0.0f);
        VersionManager.Instance().Add(testController1);
        ICommit secondCommit = VersionManager.Instance().Commit("Move testObject1");

        VersionManager.Instance().Checkout("master");

        Assert.AreEqual("master", master.GetName());
        Assert.AreSame(commit, master.GetTip());
        Assert.AreEqual("testBranch", testBranch.GetName());
        Assert.AreSame(secondCommit, testBranch.GetTip());

        Relationship mergeType = VersionManager.Instance().Merge(testBranch);

        Assert.AreEqual(Relationship.FastForward, mergeType);

        Assert.AreSame(secondCommit, master.GetTip());
        Assert.AreSame(secondCommit, VersionManager.Instance().GetActiveCommit());
    }
Ejemplo n.º 3
0
    public void PopulateConflictObjects(ICollection <VersionController> conflictObjects)
    {
        float yPos = -27.5f;

        foreach (VersionController conflictedObject in conflictObjects)
        {
            IBranch baseBranch    = mw.GetBaseBranch();
            IBranch featureBranch = mw.GetFeatureBranch();

            GameObject            uiObj      = Instantiate(Resources.Load("UI/MergeUI/UnresolvedObject")) as GameObject;
            MergeObjectController controller = uiObj.GetComponent <MergeObjectController>();

            this.controllers.Add(conflictedObject, controller);

            controller.underlyingObject = conflictedObject;
            controller.baseBranch       = baseBranch.GetName();
            controller.SetBasePreview(mw.GetBasePreviewForVersionedObject(conflictedObject));
            controller.featureBranch = featureBranch.GetName();
            controller.SetFeaturePreview(mw.GetFeaturePreviewForVersionedObject(conflictedObject));

            RectTransform rTransform = uiObj.GetComponent <RectTransform>();
            rTransform.SetParent(unresolvedControllersRegion, false);
            rTransform.anchoredPosition = new Vector2(rTransform.anchoredPosition.x, yPos);
            yPos -= 50.0f;
        }
    }
Ejemplo n.º 4
0
    public IEnumerator TestFastForward()
    {
        VersionManager.Instance().Commit("Initial Commit");
        IBranch master  = VersionManager.Instance().GetActiveBranch();
        IBranch feature = VersionManager.Instance().CreateBranch("feature");

        VersionManager.Instance().Checkout(feature.GetName());
        VersionManager.Instance().Commit("Commit on feature branch");
        yield return(null);

        Assert.AreEqual(Relationship.FastForward, LineageAnalyser.Compare(master.GetTip(), feature.GetTip()));
    }
Ejemplo n.º 5
0
    public IEnumerator TestMergeDivergent()
    {
        testObject1.transform.position = new Vector2(0.0f, 0.0f);
        testObject2.transform.position = new Vector2(3.0f, 3.0f);

        VersionManager.Instance().Add(testController1);
        VersionManager.Instance().Add(testController2);

        VersionManager.Instance().Commit("Add two objects");

        yield return(null);

        IBranch testBranch = VersionManager.Instance().CreateBranch("testBranch");

        VersionManager.Instance().Checkout("testBranch");

        testObject1.transform.position = new Vector2(1.0f, 0.0f);
        testObject2.transform.position = new Vector2(0.0f, 0.0f);
        VersionManager.Instance().Add(testController1);
        VersionManager.Instance().Add(testController2);
        ICommit secondCommit = VersionManager.Instance().Commit("Move testObject1 and testObject2");

        VersionManager.Instance().Checkout("master");

        testObject2.transform.position = new Vector2(6.0f, 6.0f);
        VersionManager.Instance().Add(testController2);
        ICommit thirdCommit = VersionManager.Instance().Commit("Move testObject2");

        Assert.AreEqual("master", master.GetName());
        Assert.AreSame(thirdCommit, master.GetTip());
        Assert.AreEqual("testBranch", testBranch.GetName());
        Assert.AreSame(secondCommit, testBranch.GetTip());

        Relationship mergeType = VersionManager.Instance().Merge(testBranch);

        Assert.AreEqual(Relationship.Divergent, mergeType);
        Assert.AreEqual(MergeStatus.FastForward, VersionManager.Instance().GetMergeWorker().GetStatus(testController1));
        Assert.AreEqual(MergeStatus.Conflict, VersionManager.Instance().GetMergeWorker().GetStatus(testController2));
        Assert.AreEqual(true, VersionManager.Instance().IsInMergeConflict());

        VersionManager.Instance().GetMergeWorker().PickVersion(testController2, master.GetTip().getObjectVersion(testController2));

        Assert.AreEqual(MergeStatus.Resolved, VersionManager.Instance().GetMergeWorker().GetStatus(testController2));
        Assert.AreEqual(false, VersionManager.Instance().IsInMergeConflict());

        ICommit mergeCommit = VersionManager.Instance().ResolveMerge();

        Assert.NotNull(mergeCommit);

        Assert.AreSame(mergeCommit, master.GetTip());
        Assert.AreSame(mergeCommit, VersionManager.Instance().GetActiveCommit());
    }
Ejemplo n.º 6
0
    public IEnumerator TestSwitchBranch()
    {
        VersionableObjectFactory factory = new VersionableObjectFactory();

        VersionController testController      = factory.createVersionablePlayer();
        VersionController otherTestController = factory.createVersionableBox();

        GameObject testObject      = testController.GetActiveVersion();
        GameObject otherTestObject = otherTestController.GetActiveVersion();


        testObject.transform.position      = new Vector2(0.0f, 0.0f);
        otherTestObject.transform.position = new Vector2(3.0f, 3.0f);

        VersionManager.Instance().Add(testController);
        VersionManager.Instance().Add(otherTestController);

        ICommit commit = VersionManager.Instance().Commit("Add two objects");

        yield return(null);

        Assert.AreSame(commit, VersionManager.Instance().GetActiveBranch().GetTip());

        IBranch testBranch = VersionManager.Instance().CreateBranch("testBranch");

        Assert.AreEqual("testBranch", testBranch.GetName());
        Assert.AreEqual(true, VersionManager.Instance().Checkout("testBranch"));
        Assert.AreSame(testBranch, VersionManager.Instance().GetActiveBranch());
        Assert.AreSame(commit, VersionManager.Instance().GetActiveBranch().GetTip());

        testObject.transform.position = new Vector2(1.0f, 0.0f);
        VersionManager.Instance().Add(testController);
        ICommit secondCommit = VersionManager.Instance().Commit("Move testObject");

        Assert.AreSame(secondCommit, VersionManager.Instance().GetActiveBranch().GetTip());
        Assert.AreSame(secondCommit, VersionManager.Instance().GetHead());
        Assert.AreSame(commit, VersionManager.Instance().LookupBranch("master").GetTip());

        VersionManager.Instance().Checkout("master");
        Assert.AreSame(commit, VersionManager.Instance().GetHead());
    }