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."); }
public void CreateItemIsCreated(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); }
public void CloneItemWithoutTagOriginalTagIsCopied(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); item.Tag = "expectedNewTag"; 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); Assert.That(clone.Tag, Is.EqualTo(item.Tag), "Cloned item's tag did not match the original item's."); }
public void CloneItemCustomTagIsApplied(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); string expectedNewTag = "expectedNewTag"; NwItem clone = item.Clone(startLocation, expectedNewTag, 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); Assert.That(clone.Tag, Is.EqualTo(expectedNewTag), "Tag defined in clone method was not applied to the cloned item."); }
public void SerializeItemCreatesValidData(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); byte[]? itemData = item.Serialize(); Assert.That(itemData, Is.Not.Null); Assert.That(itemData, Has.Length.GreaterThan(0)); NwItem?item2 = NwItem.Deserialize(itemData !); Assert.That(item2, Is.Not.Null); Assert.That(item2 !.IsValid, Is.True); createdTestObjects.Add(item2); Assert.That(item2.Area, Is.Null); }