예제 #1
0
        public void CloneWaypointWithLocalStateIsCopied(string waypointResRef)
        {
            Location   startLocation = NwModule.Instance.StartingLocation;
            NwWaypoint?waypoint      = NwWaypoint.Create(waypointResRef, startLocation);

            Assert.That(waypoint, Is.Not.Null, $"Waypoint {waypointResRef} was null after creation.");
            Assert.That(waypoint !.IsValid, Is.True, $"Waypoint {waypointResRef} was invalid after creation.");

            createdTestObjects.Add(waypoint);

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

            testVar.Value = 9999;

            NwWaypoint clone = waypoint.Clone(startLocation);

            Assert.That(clone, Is.Not.Null, $"Waypoint {waypointResRef} was null after clone.");
            Assert.That(clone.IsValid, Is.True, $"Waypoint {waypointResRef} 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 waypoint did not match the value of the original waypoint.");
        }
예제 #2
0
        public void CreateWaypointIsCreated(string waypointResRef)
        {
            Location   startLocation = NwModule.Instance.StartingLocation;
            NwWaypoint?waypoint      = NwWaypoint.Create(waypointResRef, startLocation);

            Assert.That(waypoint, Is.Not.Null, $"Waypoint {waypointResRef} was null after creation.");
            Assert.That(waypoint !.IsValid, Is.True, $"Waypoint {waypointResRef} was invalid after creation.");

            createdTestObjects.Add(waypoint);
        }
예제 #3
0
        public void CloneWaypointWithoutTagOriginalTagIsCopied(string waypointResRef)
        {
            Location   startLocation = NwModule.Instance.StartingLocation;
            NwWaypoint?waypoint      = NwWaypoint.Create(waypointResRef, startLocation);

            Assert.That(waypoint, Is.Not.Null, $"Waypoint {waypointResRef} was null after creation.");
            Assert.That(waypoint !.IsValid, Is.True, $"Waypoint {waypointResRef} was invalid after creation.");

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

            NwWaypoint clone = waypoint.Clone(startLocation, null, false);

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

            createdTestObjects.Add(clone);

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

            Assert.That(waypoint, Is.Not.Null, $"Waypoint {waypointResRef} was null after creation.");
            Assert.That(waypoint !.IsValid, Is.True, $"Waypoint {waypointResRef} was invalid after creation.");

            createdTestObjects.Add(waypoint);

            string     expectedNewTag = "expectedNewTag";
            NwWaypoint clone          = waypoint.Clone(startLocation, expectedNewTag, false);

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

            Assert.That(waypoint, Is.Not.Null, $"Waypoint {waypointResRef} was null after creation.");
            Assert.That(waypoint !.IsValid, Is.True, $"Waypoint {waypointResRef} was invalid after creation.");

            createdTestObjects.Add(waypoint);

            byte[]? waypointData = waypoint.Serialize();

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

            NwWaypoint?waypoint2 = NwWaypoint.Deserialize(waypointData !);

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

            createdTestObjects.Add(waypoint2);

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