Class IntegrationTestWithApproximation
An extended NetcodeIntegrationTest class that includes various helper mehtods to handle aproximating float various in order to avoid floating point drift related errors.
Inherited Members
Namespace: Unity.Netcode.TestHelpers.Runtime
Assembly: Unity.Netcode.Runtime.Tests.dll
Syntax
public abstract class IntegrationTestWithApproximation : NetcodeIntegrationTest
Constructors
IntegrationTestWithApproximation()
Default constructor with no parameters.
Declaration
public IntegrationTestWithApproximation()
IntegrationTestWithApproximation(NetworkTopologyTypes)
Overloaded constructor accepting the NetworkTopologyTypes as a parameter.
Declaration
public IntegrationTestWithApproximation(NetworkTopologyTypes networkTopologyType)
Parameters
| Type | Name | Description |
|---|---|---|
| NetworkTopologyTypes | networkTopologyType | The NetworkTopologyTypes to use for the NUnit.Framework.TestFixtureAttribute pass. |
Remarks
This is useful when using the NUnit.Framework.TestFixtureAttribute with your integration test.
IntegrationTestWithApproximation(NetworkTopologyTypes, HostOrServer)
Overloaded constructor accepting the NetworkTopologyTypes and NetcodeIntegrationTest.HostOrServer as parameters.
Declaration
public IntegrationTestWithApproximation(NetworkTopologyTypes networkTopologyType, NetcodeIntegrationTest.HostOrServer hostOrServer)
Parameters
| Type | Name | Description |
|---|---|---|
| NetworkTopologyTypes | networkTopologyType | The NetworkTopologyTypes to use for the NUnit.Framework.TestFixtureAttribute pass. |
| NetcodeIntegrationTest.HostOrServer | hostOrServer | The NetcodeIntegrationTest.HostOrServer to use for the NUnit.Framework.TestFixtureAttribute pass. |
Remarks
This is useful when using the NUnit.Framework.TestFixtureAttribute with your integration test.
IntegrationTestWithApproximation(HostOrServer)
Overloaded constructor accepting the NetcodeIntegrationTest.HostOrServer as a parameter.
Declaration
public IntegrationTestWithApproximation(NetcodeIntegrationTest.HostOrServer hostOrServer)
Parameters
| Type | Name | Description |
|---|---|---|
| NetcodeIntegrationTest.HostOrServer | hostOrServer | The NetcodeIntegrationTest.HostOrServer to use for the NUnit.Framework.TestFixtureAttribute pass. |
Remarks
This is useful when using the NUnit.Framework.TestFixtureAttribute with your integration test.
Methods
Approximately(float, float)
Determines an aproximated comparison between two float values.
Declaration
protected bool Approximately(float a, float b)
Parameters
| Type | Name | Description |
|---|---|---|
| float | a | The first float value. |
| float | b | The second float value. |
Returns
| Type | Description |
|---|---|
| bool | Returns true if they are approximately the same and false if they are not. |
Approximately(Quaternion, Quaternion)
Determines an aproximated comparison between two Quaternion values.
Declaration
protected bool Approximately(Quaternion a, Quaternion b)
Parameters
| Type | Name | Description |
|---|---|---|
| Quaternion | a | The first Quaternion value. |
| Quaternion | b | The second Quaternion value. |
Returns
| Type | Description |
|---|---|
| bool | Returns true if they are approximately the same and false if they are not. |
Approximately(Vector2, Vector2)
Determines an aproximated comparison between two Vector2 values.
Declaration
protected bool Approximately(Vector2 a, Vector2 b)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | a | The first Vector2 value. |
| Vector2 | b | The second Vector2 value. |
Returns
| Type | Description |
|---|---|
| bool | Returns true if they are approximately the same and false if they are not. |
Approximately(Vector3, Vector3)
Determines an aproximated comparison between two Vector3 values.
Declaration
protected bool Approximately(Vector3 a, Vector3 b)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | a | The first Vector3 value. |
| Vector3 | b | The second Vector3 value. |
Returns
| Type | Description |
|---|---|
| bool | Returns true if they are approximately the same and false if they are not. |
ApproximatelyEuler(float, float)
Determines an aproximated comparison between two Euler values.
Declaration
protected bool ApproximatelyEuler(float a, float b)
Parameters
| Type | Name | Description |
|---|---|---|
| float | a | The first Euler value. |
| float | b | The second Euler value. |
Returns
| Type | Description |
|---|---|
| bool | Returns true if they are approximately the same and false if they are not. |
ApproximatelyEuler(Vector3, Vector3)
Determines an aproximated comparison between two Vector3 expressed in Euler values.
Declaration
protected bool ApproximatelyEuler(Vector3 a, Vector3 b)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | a | The first Vector3 expressed in Euler values. |
| Vector3 | b | The second Vector3 expressed in Euler values. |
Returns
| Type | Description |
|---|---|
| bool | Returns true if they are approximately the same and false if they are not. |
EulerDelta(float, float)
Returns the delta between two Euler angles.
Declaration
protected float EulerDelta(float a, float b)
Parameters
| Type | Name | Description |
|---|---|---|
| float | a | The first Euler value. |
| float | b | The second Euler value. |
Returns
| Type | Description |
|---|---|
| float |
EulerDelta(Vector3, Vector3)
Returns the delta between two Vector3 values that represent Euler angles.
Declaration
protected Vector3 EulerDelta(Vector3 a, Vector3 b)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | a | The first Euler Vector3 value. |
| Vector3 | b | The second Euler Vector3 value. |
Returns
| Type | Description |
|---|---|
| Vector3 |
GetDeltaVarianceThreshold()
Override this to make changes to the precision level used.
Declaration
protected virtual float GetDeltaVarianceThreshold()
Returns
| Type | Description |
|---|---|
| float | A float value representing the minimum tolerence value required to be considered an approximation of a float value comparison. |
GetRandomVector3(float, float)
Returns a randomly generated Vector3 based on the min and max range specified in the parameters.
Declaration
protected Vector3 GetRandomVector3(float min, float max)
Parameters
| Type | Name | Description |
|---|---|---|
| float | min | The minimum float value. |
| float | max | The maximum float value. |
Returns
| Type | Description |
|---|---|
| Vector3 | The randomly generated Vector3 result. |
Remarks
Each axis value is a randomly generated value between min and max.
GetVector3Values(Vector3)
Returns a six decimal place string to represent a Vector3 value.
Declaration
protected string GetVector3Values(Vector3 vector3)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | vector3 | The Vector3 value to convert to a string. |
Returns
| Type | Description |
|---|---|
| string |
GetVector3Values(ref Vector3)
Returns a six decimal place string to represent a Vector3 value.
Declaration
protected string GetVector3Values(ref Vector3 vector3)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | vector3 | A reference to the Vector3 value to convert to a string. |
Returns
| Type | Description |
|---|---|
| string |