Esempio n. 1
0
        public void CloneItemNoLocalStateIsNotCopied(string itemResRef)
        {
            Location startLocation = NwModule.Instance.StartingLocation;
            NwItem?  item          = NwItem.Create(itemResRef, startLocation);

            Assert.That(item, Is.Not.Null, $"Item {itemResRef} was null after creation.");
            Assert.That(item !.IsValid, Is.True, $"Item {itemResRef} was invalid after creation.");

            createdTestObjects.Add(item);

            LocalVariableInt testVar = item.GetObjectVariable <LocalVariableInt>("test");

            testVar.Value = 9999;

            NwItem clone = item.Clone(startLocation, null, false);

            Assert.That(clone, Is.Not.Null, $"Item {itemResRef} was null after clone.");
            Assert.That(clone.IsValid, Is.True, $"Item {itemResRef} was invalid after clone.");

            createdTestObjects.Add(clone);

            LocalVariableInt cloneTestVar = clone.GetObjectVariable <LocalVariableInt>("test");

            Assert.That(cloneTestVar.HasValue, Is.False, "Local variable exists on the clone with copyLocalState = false.");
            Assert.That(cloneTestVar.Value, Is.Not.EqualTo(testVar.Value), "Local variable on the cloned item matches the value of the original item.");
        }