コード例 #1
0
    public IEnumerator TestResetMultipleObjectPositions()
    {
        // Given
        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(1.0f, 3.0f);
        otherTestObject.transform.position = new Vector2(-1.0f, 5.0f);

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

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

        yield return(null);

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

        yield return(null);

        VersionManager.Instance().ResetToHead();

        yield return(null);

        Assert.AreEqual(1.0f, testObject.transform.position.x, 0.1f);
        Assert.AreEqual(3.0f, testObject.transform.position.y, 0.1f);

        Assert.AreEqual(-1.0f, otherTestObject.transform.position.x, 0.1f);
        Assert.AreEqual(5.0f, otherTestObject.transform.position.y, 0.1f);
    }
コード例 #2
0
    public IEnumerator ShouldSetLocalScale()
    {
        VersionableObjectFactory factory = new VersionableObjectFactory();

        VersionController testController = factory.createBinaryVersionable();
        GameObject        testObject     = testController.GetActiveVersion();

        Assert.AreEqual(1.0f, testObject.transform.localScale.x, 0.01f);

        VersionManager.Instance().Add(testController);
        ICommit commit = VersionManager.Instance().Commit("Add a box");

        yield return(null);

        testObject.transform.localScale = new Vector3(-1.0f, 1.0f, 1.0f);
        Assert.AreEqual(-1.0f, testObject.transform.localScale.x, 0.01f);

        VersionManager.Instance().Add(testController);
        VersionManager.Instance().Commit("Flip the box");

        yield return(null);

        VersionManager.Instance().CheckoutCommit(commit);

        yield return(null);

        Assert.AreEqual(1.0f, testObject.transform.localScale.x, 0.01f);
    }
コード例 #3
0
    public IEnumerator TestResetPositionBeforeHEAD()
    {
        // Given
        VersionableObjectFactory factory = new VersionableObjectFactory();

        VersionController testController = factory.createVersionablePlayer();

        GameObject testObject = testController.GetActiveVersion();

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

        VersionManager.Instance().Add(testController);
        ICommit commitToLoad = VersionManager.Instance().Commit("Set thing position to 0,0");

        yield return(null);

        testObject.transform.position = new Vector2(1.0f, 1.0f);

        VersionManager.Instance().Add(testController);
        VersionManager.Instance().Commit("Set thing position to 1,1");

        yield return(null);

        // When
        VersionManager.Instance().CheckoutCommit(commitToLoad);

        yield return(null);

        // Then
        Assert.AreEqual(0.0f, testObject.transform.position.x, 0.1f);
        Assert.AreEqual(0.0f, testObject.transform.position.y, 0.1f);
    }
コード例 #4
0
    public IEnumerator shouldResetTrackedObjectsWhenCheckingOutCommitWhereAnObjectWasNotTracked()
    {
        VersionableObjectFactory factory = new VersionableObjectFactory();

        VersionController testController = factory.createVersionableBox();
        GameObject        testObject     = testController.GetActiveVersion();

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

        VersionManager.Instance().Add(testController);

        Guid firstCommitId = VersionManager.Instance().Commit("Create a box").GetId();

        yield return(null);

        VersionController otherTestController = factory.createVersionableBox();
        GameObject        otherTestObject     = otherTestController.GetActiveVersion();

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

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

        VersionManager.Instance().Commit("Create another box and move the first box");

        yield return(null);

        VersionManager.Instance().Checkout(VersionManager.Instance().GetActiveBranch(), firstCommitId);

        Assert.False(VersionManager.Instance().IsObjectTracked(otherTestController));
    }
コード例 #5
0
    public void SetUp()
    {
        VersionManager.Reset();

        testController1 = factory.createVersionablePlayer();
        testController2 = factory.createVersionableBox();

        testObject1 = testController1.GetActiveVersion();
        testObject2 = testController2.GetActiveVersion();

        master = VersionManager.Instance().GetActiveBranch();
    }
コード例 #6
0
    public IEnumerator shouldBeAbleToCreateNewBranchWhenInDetachedHeadAndThenCommit()
    {
        VersionableObjectFactory factory = new VersionableObjectFactory();

        VersionController testController      = factory.createVersionableBox();
        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, 0.0f);

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

        ICommit firstCommit   = VersionManager.Instance().Commit("Create two boxes");
        Guid    firstCommitId = firstCommit.GetId();

        yield return(null);

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

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

        VersionManager.Instance().Commit("Move boxes");

        yield return(null);

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

        IBranch newBranch = VersionManager.Instance().CreateBranch("refactor");

        VersionManager.Instance().Checkout(newBranch);

        Assert.AreEqual(newBranch.GetTip().GetId(), VersionManager.Instance().GetActiveBranch().GetTip().GetId());
        Assert.AreEqual(newBranch.GetTip().GetId(), VersionManager.Instance().GetActiveCommit().GetId());

        testObject.transform.position = new Vector2(-1.0f, 0.0f);

        VersionManager.Instance().Add(testController);
        ICommit commit = VersionManager.Instance().Commit("Move a box to the left");

        Assert.AreEqual(newBranch.GetTip().GetId(), commit.GetId());
        Assert.True(commit.ObjectIsTrackedInThisCommit(testController));
        Assert.True(commit.ObjectIsTrackedInThisCommit(otherTestController));
    }
コード例 #7
0
    public IEnumerator shouldNotBeAbleToCommitWhenInDetachedHeadState()
    {
        VersionableObjectFactory factory = new VersionableObjectFactory();

        VersionController testController      = factory.createVersionableBox();
        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, 0.0f);

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

        ICommit firstCommit   = VersionManager.Instance().Commit("Create two boxes");
        Guid    firstCommitId = firstCommit.GetId();

        yield return(null);

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

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

        VersionManager.Instance().Commit("Move boxes");

        yield return(null);

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

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

        VersionManager.Instance().Add(testController);

        ICommit commit = null;

        try {
            commit = VersionManager.Instance().Commit("Move the box");
            Assert.Fail();
        } catch (InvalidOperationException ioe) {
            Assert.AreEqual(ioe.Message, "Cannot commit in detached HEAD state");
            Assert.IsNull(commit);
            Assert.AreEqual(VersionManager.Instance().GetActiveCommit(), firstCommit);
        }
    }
コード例 #8
0
    public IEnumerator TestCheckoutCommitOnDifferentBranch()
    {
        VersionableObjectFactory factory = new VersionableObjectFactory();

        VersionController testController      = factory.createVersionableBox();
        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, 0.0f);

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

        Guid firstCommitId = VersionManager.Instance().Commit("Create two boxes").GetId();

        yield return(null);

        VersionManager.Instance().CreateBranch("feature");
        VersionManager.Instance().Checkout("feature");

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

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

        VersionManager.Instance().Commit("Move boxes");

        yield return(null);

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

        Assert.AreEqual(0.0f, testObject.transform.position.x, 0.1f);
        Assert.AreEqual(0.0f, testObject.transform.position.y, 0.1f);

        Assert.AreEqual(3.0f, otherTestObject.transform.position.x, 0.1f);
        Assert.AreEqual(0.0f, otherTestObject.transform.position.y, 0.1f);

        IBranch master = VersionManager.Instance().LookupBranch("master");

        Assert.AreEqual(master, VersionManager.Instance().GetActiveBranch());
    }
コード例 #9
0
ファイル: BranchTests.cs プロジェクト: bpar476/GitGood
    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());
    }
コード例 #10
0
    public IEnumerator TestResetObjectsToCommitWhereOneWasNotChanged()
    {
        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);

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

        yield return(null);

        testObject.transform.position = new Vector2(-2.0f, -2.0f);

        VersionManager.Instance().Add(testController);
        VersionManager.Instance().Commit("Move one of the objects");

        yield return(null);

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

        yield return(null);

        VersionManager.Instance().ResetToHead();

        Assert.AreEqual(-2.0f, testObject.transform.position.x, 0.1f);
        Assert.AreEqual(-2.0f, testObject.transform.position.y, 0.1f);

        Assert.AreEqual(3.0f, otherTestObject.transform.position.x, 0.1f);
        Assert.AreEqual(3.0f, otherTestObject.transform.position.y, 0.1f);
    }
コード例 #11
0
    public IEnumerator shouldPreserveStagingAreaWhenCheckingOutNewBranch()
    {
        VersionableObjectFactory factory = new VersionableObjectFactory();

        VersionController testController      = factory.createVersionableBox();
        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, 0.0f);

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

        VersionManager.Instance().Commit("Create two boxes").GetId();

        yield return(null);

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

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

        VersionManager.Instance().CreateBranch("feature");
        VersionManager.Instance().Checkout("feature");

        VersionManager.Instance().Commit("Move boxes");

        VersionManager.Instance().ResetToHead();

        Assert.AreEqual(1.0f, testObject.transform.position.x, 0.1f);
        Assert.AreEqual(0.0f, testObject.transform.position.y, 0.1f);

        Assert.AreEqual(4.0f, otherTestObject.transform.position.x, 0.1f);
        Assert.AreEqual(1.0f, otherTestObject.transform.position.y, 0.1f);
    }
コード例 #12
0
    public void CreateMergeConflictScenario()
    {
        versionManager.CreateBranch("conflict-branch");
        versionManager.Checkout("conflict-branch");
        tutorialBox.GetActiveVersion().transform.position = new Vector2(10, tutorialBox.GetActiveVersion().transform.position.y);
        versionManager.Add(tutorialBox);
        versionManager.Commit("move the box");

        versionManager.Checkout("master");
        tutorialBox.GetActiveVersion().transform.position = new Vector2(20, tutorialBox.GetActiveVersion().transform.position.y);
        versionManager.Add(tutorialBox);
        versionManager.Commit("Change the box position");

        versionManager.Merge(versionManager.LookupBranch("conflict-branch"));

        tutorialBox.GetActiveVersion().transform.position = new Vector2(15, tutorialBox.GetActiveVersion().transform.position.y);
    }
コード例 #13
0
    public IEnumerator shouldResetObjectToInitialPositionIfCheckingOutCommitWhereItWasNotTracked()
    {
        VersionableObjectFactory factory = new VersionableObjectFactory();

        VersionController testController = factory.createVersionableBox();
        GameObject        testObject     = testController.GetActiveVersion();

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

        VersionManager.Instance().Add(testController);

        Guid firstCommitId = VersionManager.Instance().Commit("Create a box").GetId();

        yield return(null);

        VersionController otherTestController = factory.createVersionableBox();
        GameObject        otherTestObject     = otherTestController.GetActiveVersion();

        otherTestController.GetComponent <TransformVersionable>().SetInitialState(new Vector2(5.0f, 0.0f));

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

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

        VersionManager.Instance().Commit("Create another box and move the first box");

        yield return(null);

        VersionManager.Instance().Checkout(VersionManager.Instance().GetActiveBranch(), firstCommitId);

        Assert.AreEqual(0.0f, testObject.transform.position.x, 0.1f);
        Assert.AreEqual(0.0f, testObject.transform.position.y, 0.1f);

        Assert.AreEqual(5.0f, otherTestObject.transform.position.x, 0.1f);
        Assert.AreEqual(0.0f, otherTestController.transform.position.y, 0.1f);
    }