예제 #1
0
        public void ClonePlaceableWithLocalStateIsCopied(string placeableResRef)
        {
            Location    startLocation = NwModule.Instance.StartingLocation;
            NwPlaceable?placeable     = NwPlaceable.Create(placeableResRef, startLocation);

            Assert.That(placeable, Is.Not.Null, $"Placeable {placeableResRef} was null after creation.");
            Assert.That(placeable !.IsValid, Is.True, $"Placeable {placeableResRef} was invalid after creation.");

            createdTestObjects.Add(placeable);

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

            testVar.Value = 9999;

            NwPlaceable clone = placeable.Clone(startLocation);

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

            createdTestObjects.Add(clone);

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

            Assert.That(cloneTestVar.HasValue, Is.True, "Local variable did not exist on the clone with copyLocalState = true.");
            Assert.That(cloneTestVar.Value, Is.EqualTo(testVar.Value), "Local variable on the cloned placeable did not match the value of the original placeable.");
        }
예제 #2
0
        public void CreatePlaceableIsCreated(string placeableResRef)
        {
            Location    startLocation = NwModule.Instance.StartingLocation;
            NwPlaceable?placeable     = NwPlaceable.Create(placeableResRef, startLocation);

            Assert.That(placeable, Is.Not.Null, $"Placeable {placeableResRef} was null after creation.");
            Assert.That(placeable !.IsValid, Is.True, $"Placeable {placeableResRef} was invalid after creation.");

            createdTestObjects.Add(placeable);
        }
예제 #3
0
        public void ClonePlaceableWithoutTagOriginalTagIsCopied(string placeableResRef)
        {
            Location    startLocation = NwModule.Instance.StartingLocation;
            NwPlaceable?placeable     = NwPlaceable.Create(placeableResRef, startLocation);

            Assert.That(placeable, Is.Not.Null, $"Placeable {placeableResRef} was null after creation.");
            Assert.That(placeable !.IsValid, Is.True, $"Placeable {placeableResRef} was invalid after creation.");

            createdTestObjects.Add(placeable);
            placeable.Tag = "expectedNewTag";

            NwPlaceable clone = placeable.Clone(startLocation, null, false);

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

            createdTestObjects.Add(clone);

            Assert.That(clone.Tag, Is.EqualTo(placeable.Tag), "Cloned placeable's tag did not match the original placeable's.");
        }
예제 #4
0
        public void ClonePlaceableCustomTagIsApplied(string placeableResRef)
        {
            Location    startLocation = NwModule.Instance.StartingLocation;
            NwPlaceable?placeable     = NwPlaceable.Create(placeableResRef, startLocation);

            Assert.That(placeable, Is.Not.Null, $"Placeable {placeableResRef} was null after creation.");
            Assert.That(placeable !.IsValid, Is.True, $"Placeable {placeableResRef} was invalid after creation.");

            createdTestObjects.Add(placeable);

            string      expectedNewTag = "expectedNewTag";
            NwPlaceable clone          = placeable.Clone(startLocation, expectedNewTag, false);

            Assert.That(clone, Is.Not.Null, $"Placeable {placeableResRef} was null after clone.");
            Assert.That(clone.IsValid, Is.True, $"Placeable {placeableResRef} 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 placeable.");
        }
예제 #5
0
        public void SerializePlaceableCreatesValidData(string placeableResRef)
        {
            Location    startLocation = NwModule.Instance.StartingLocation;
            NwPlaceable?placeable     = NwPlaceable.Create(placeableResRef, startLocation);

            Assert.That(placeable, Is.Not.Null, $"Placeable {placeableResRef} was null after creation.");
            Assert.That(placeable !.IsValid, Is.True, $"Placeable {placeableResRef} was invalid after creation.");

            createdTestObjects.Add(placeable);

            byte[]? placeableData = placeable.Serialize();

            Assert.That(placeableData, Is.Not.Null);
            Assert.That(placeableData, Has.Length.GreaterThan(0));

            NwPlaceable?placeable2 = NwPlaceable.Deserialize(placeableData !);

            Assert.That(placeable2, Is.Not.Null);
            Assert.That(placeable2 !.IsValid, Is.True);

            createdTestObjects.Add(placeable2);

            Assert.That(placeable2.Area, Is.Null);
        }