Ejemplo n.º 1
0
        public void NonClonableWillNotBeCloned()
        {
            var foo = new CustomClass <NonClonableClass>(new NonClonableClass(), null, null, null);
            var bar = Cloning.Clone(foo);

            Assert.Equal(null, bar.Field1);
        }
Ejemplo n.º 2
0
        public void CloneIsNotTheSameObject()
        {
            var foo = new CustomClass <int>(1, 2, 3, 4);
            var bar = Cloning.Clone(foo);

            Assert.False(object.ReferenceEquals(foo, bar));
        }
Ejemplo n.º 3
0
        public void NullIsClonable()
        {
            var foo = (CustomClass <string>)null;
            var bar = Cloning.Clone(foo);

            Assert.True(ReferenceEquals(bar, null));
        }
Ejemplo n.º 4
0
        public void DoubleIsClonable()
        {
            // Produce an inexact double
            double d = (1.0 / 10) * 3;

            Assert.Equal(d, Cloning.Clone(d));
        }
Ejemplo n.º 5
0
        public void CloneAutoProperties()
        {
            var foo = new ClassWithAutoProperties <int>(10, 20);
            var bar = Cloning.Clone(foo);

            Assert.Equal(foo.Field1, bar.Field1);
            Assert.Equal(foo.Field2, bar.Field2);
        }
Ejemplo n.º 6
0
        public void CloneInsideStructIsNotTheSameObject()
        {
            var c   = new CustomClass <int>(1, 2, 3, 4);
            var foo = new CustomStruct <CustomClass <int> >(c, c, c, c);
            var bar = Cloning.Clone(foo);

            Assert.False(ReferenceEquals(foo.Field1, bar.Field1));
        }
Ejemplo n.º 7
0
        public void CloneArray()
        {
            var foo = new int[] { 10, 20 };
            var bar = Cloning.Clone(foo);

            Assert.Equal(foo.Length, bar.Length);
            Assert.Equal(foo[0], bar[0]);
            Assert.Equal(foo[1], bar[1]);
        }
Ejemplo n.º 8
0
        public void CustomStructIsClonable()
        {
            var foo = new CustomStruct <int>(10, 20, 30, 40);
            var bar = Cloning.Clone(foo);

            Assert.Equal(foo.Field1, bar.Field1);
            Assert.Equal(foo.Field2, bar.Field2);
            Assert.Equal(foo.Field3, bar.Field3);
            Assert.Equal(foo.Field4, bar.Field4);
        }
Ejemplo n.º 9
0
        public void ObjectRelationshipsInClassArePreserved()
        {
            var o   = new object();
            var foo = new CustomClass <object>(o, o, o, o);
            var bar = Cloning.Clone(foo);

            Assert.True(ReferenceEquals(bar.Field1, bar.Field2));
            Assert.True(ReferenceEquals(bar.Field2, bar.Field3));
            Assert.True(ReferenceEquals(bar.Field3, bar.Field4));
        }
Ejemplo n.º 10
0
        public void CustomSubClassIsClonable()
        {
            var foo = new CustomSubClass <int>(10, 20, 30, 40, 50);
            var bar = Cloning.Clone(foo);

            Assert.Equal(foo.Field1, bar.Field1);
            Assert.Equal(foo.Field2, bar.Field2);
            Assert.Equal(foo.Field3, bar.Field3);
            Assert.Equal(foo.Field4, bar.Field4);
            Assert.Equal(foo.Field5, bar.Field5);
        }
Ejemplo n.º 11
0
        public void RecursiveObjectsAreClonable()
        {
            var foo = new Recursive <int>();

            foo.RecursiveValue = foo;
            foo.ExtraValue     = 42;

            var bar = Cloning.Clone(foo);

            Assert.Equal(42, bar.ExtraValue);
            Assert.True(ReferenceEquals(bar, bar.RecursiveValue));
        }
Ejemplo n.º 12
0
        public void Clone2DArray()
        {
            var foo = new int[, ] {
                { 10, 20, 30 }, { 40, 50, 60 }
            };
            var bar = Cloning.Clone(foo);

            Assert.Equal(foo.Length, bar.Length);
            Assert.Equal(foo.GetLength(0), foo.GetLength(0));
            Assert.Equal(foo.GetLength(1), foo.GetLength(1));
            for (int x = 0; x < foo.GetLength(0); ++x)
            {
                for (int y = 0; y < foo.GetLength(1); ++y)
                {
                    Assert.Equal(foo[x, y], bar[x, y]);
                }
            }
        }
Ejemplo n.º 13
0
    /// <summary>
    /// handle clone input
    /// </summary>
    private void handleCloneInput()
    {
        if (Input.GetMouseButtonDown(0))
        {
            //TODO: add visualization of  mouse over
            if (leaveCloning.GetComponent <MouseOverObj>().isMouseOver)
            {
                if (!cloner.isSeedOnFloor())
                {
                    if (selectedSplice != -1)
                    {
                        cloneSplicesShelf.transform.GetChild(selectedSplice).GetComponent <MouseOverObj>().lockedOutline = false;
                        cloneSplicesShelf.transform.GetChild(selectedSplice).GetComponent <MouseOverObj>().removeOutline();
                        selectedSplice = -1;
                    }
                    cloner.resetSeedDisplay();
                    SoundManager.instance.playSound(SoundManager.SOUNDS.DEFAULT_UI);
                    switchToMainLab();
                }
                else
                {
                    StartCoroutine(blinkingOutline(cloner.getPacketGO()));
                }
            }

            if (addCloneWorkerButton.GetComponent <MouseOverObj>().isMouseOver)
            {
                numberOfWorkers++;
                updateNumberOfWorkersDisplay(true);
                if (selectedSplice != -1)
                {
                    cloner.updateNumSeeds(GameState.instance.mySplices[selectedSplice], numberOfWorkers);
                }
                SoundManager.instance.playSound(SoundManager.SOUNDS.DEFAULT_UI);
            }

            if (removeCloneWorkerButton.GetComponent <MouseOverObj>().isMouseOver)
            {
                numberOfWorkers--;
                updateNumberOfWorkersDisplay(true);
                if (selectedSplice != -1)
                {
                    cloner.updateNumSeeds(GameState.instance.mySplices[selectedSplice], numberOfWorkers);
                }
                SoundManager.instance.playSound(SoundManager.SOUNDS.DEFAULT_UI);
            }

            if (cloneButton.GetComponent <MouseOverObj>().isMouseOver)
            {
                if (specieToClone != null)
                {
                    if (!cloner.isSeedOnFloor())
                    {
                        if (GameState.instance.addJob(JobType.CLONE, numberOfWorkers, 0))
                        {
                            specieToClone = GameState.instance.mySplices[selectedSplice];
                            cloner.Clone(specieToClone, numberOfWorkers);
                            SoundManager.instance.playSound(SoundManager.SOUNDS.CLONE);
                        }
                        else
                        {
                            //TODO: HUD ERROR
                        }
                        numberOfWorkers = 1;
                        cloner.updateNumSeeds(GameState.instance.mySplices[selectedSplice], numberOfWorkers);
                        updateNumberOfWorkersDisplay(true);
                    }
                    else
                    {
                        StartCoroutine(blinkingOutline(cloner.getPacketGO()));
                        SoundManager.instance.playSound(SoundManager.SOUNDS.ERROR_LAB);
                    }
                }
                else
                {
                    for (int i = 0; i < 5; i++)
                    {
                        StartCoroutine(blinkingOutline(cloneSplicesShelf.transform.GetChild(i).gameObject));
                        SoundManager.instance.playSound(SoundManager.SOUNDS.ERROR_LAB);
                    }
                }
            }
            if (findSelectedCustomSplice(true))
            {
                if (GameState.instance.mySplices[selectedSplice] != null)
                {
                    specieToClone = GameState.instance.mySplices[selectedSplice];
                    splicer.updateStatsDisplay(specieToClone, null, numberOfWorkers, true);
                    cloner.updateNumSeeds(GameState.instance.mySplices[selectedSplice], numberOfWorkers);
                }
                else
                {
                    specieToClone = null;
                }
                SoundManager.instance.playSound(SoundManager.SOUNDS.SELECT_SHELF_OBJ);
            }
        }
    }
Ejemplo n.º 14
0
 public void StringIsClonable()
 {
     Assert.Equal("foo", Cloning.Clone("foo"));
 }
Ejemplo n.º 15
0
 public void IntIsClonable()
 {
     Assert.Equal(42, Cloning.Clone(42));
 }