-
Notifications
You must be signed in to change notification settings - Fork 829
Commit
…ady test (#3887) Add instructions on how to set up a local development environment for contributing to agones unity sdk
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Agones Client SDKs | ||
Welcome to the Agones Client SDKs! Here you can find libraries to interface with Agones. | ||
|
||
## Developing, Testing, and Building | ||
For detailed instruction on how to develop each client library please refer to respective `README.md` files. | ||
|
||
* [Agones C/C++ Client SDK](cpp/README.md) | ||
* Agones C# Client SDK (todo) | ||
* Agones Go Client SDK (todo) | ||
* [Agones NodeJS Client SDK](nodejs/README.md) | ||
* [Agones Rust Client SDK](rust/README.md) | ||
* OpenAPI/Swagger Definitions (todo) | ||
* [Agones Unity Client SDK](unity/README.md) | ||
* Agones Unreal Client SDK (todo) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
{ | ||
"name": "Agones" | ||
} | ||
"name": "Agones", | ||
"rootNamespace": "", | ||
"includePlatforms": [], | ||
"excludePlatforms": [], | ||
"allowUnsafeCode": false, | ||
"overrideReferences": false, | ||
"precompiledReferences": [], | ||
"autoReferenced": true, | ||
"defineConstraints": [], | ||
"versionDefines": [], | ||
"noEngineReferences": false | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright 2024 Google LLC | ||
// All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using System.Threading.Tasks; | ||
using UnityEngine.Networking; | ||
|
||
namespace Agones | ||
{ | ||
public interface IRequestSender | ||
{ | ||
Task<AgonesSdk.AsyncResult> SendRequestAsync(string api, string json, string method = UnityWebRequest.kHttpVerbPOST); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Agones Unity Client SDK | ||
|
||
## Contributing | ||
Thank you for your interest in contributing to the Agones Unity client library. Setting up a local workspace to help develop the Agones Game Server Unity Client SDK involves cloning the Agones source code, having a host Unity project, and allowing the Unity project to run the external tests in the Unity test runner. | ||
|
||
### A copy of Agones source code | ||
If you don't already have a local copy of the Agones source code you can either (1) clone the official [googleforgames/agones repository](https://github.com/googleforgames/agones) for quicker access or (2) create a fork then clone your fork. Make note of where you clone the project to for the next setup steps! | ||
|
||
### Setting up the Test Agones Unity SDK Project | ||
In the directory `test/sdk/unity` there is a Test Agones Unity SDK project. This is the project you should add to your Unity Hub, to be able to develop the Agones Unity SDK. You can then open up the project in the Unity Editor application. Once open in the Unity Editor you can run the Agones Unity SDK test suite. | ||
|
||
Please be aware that when making contributions to the Agones Unity SDK you will be making modifications to directly to files under `Packages/Agones Unity SDK/` in Unity. The way this works is because the Test Agones Unity SDK project's `Package/manifest.json` uses a relative path to pull in the code directly from `sdks/unity`. For those new to Unity package development this may not be intuitive! | ||
|
||
Tests covering contributions is always encouraged. You are now ready to develop the Agones Unity SDK using the Test Agones Unity SDK project! |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2024 Google LLC | ||
// All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using System.Collections; | ||
using System.Threading.Tasks; | ||
using Agones; | ||
using NUnit.Framework; | ||
using Tests.TestingEnvironment; | ||
using UnityEngine; | ||
using UnityEngine.Networking; | ||
using UnityEngine.TestTools; | ||
|
||
namespace Tests.Runtime.Agones | ||
{ | ||
public class AgonesSdkComplianceTests | ||
{ | ||
[UnityTest] | ||
public IEnumerator AgonesSdk_Ready_ShouldInteractWithReadyApiEndpoint() | ||
{ | ||
var sut = new GameObject().AddComponent<AgonesSdk>(); | ||
var spy = new SpyRequestSender(); | ||
sut.requestSender = spy; | ||
yield return null; | ||
var task = sut.Ready(); | ||
yield return AwaitTask(task); | ||
Assert.IsTrue(spy.LastApi.Contains("/ready")); | ||
Assert.IsTrue(spy.LastJson.Equals("{}")); | ||
Assert.AreEqual(spy.LastMethod, UnityWebRequest.kHttpVerbPOST); | ||
} | ||
private IEnumerator AwaitTask(Task task) | ||
{ | ||
while (!task.IsCompleted) | ||
yield return null; | ||
if (task.Exception != null) | ||
throw task.Exception; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "Tests.Runtime.Agones", | ||
"rootNamespace": "", | ||
"references": [ | ||
"UnityEngine.TestRunner", | ||
"UnityEditor.TestRunner", | ||
"Agones", | ||
"" | ||
], | ||
"includePlatforms": [], | ||
"excludePlatforms": [], | ||
"allowUnsafeCode": false, | ||
"overrideReferences": true, | ||
"precompiledReferences": [ | ||
"nunit.framework.dll" | ||
], | ||
"autoReferenced": false, | ||
"defineConstraints": [ | ||
"UNITY_INCLUDE_TESTS" | ||
], | ||
"versionDefines": [], | ||
"noEngineReferences": false | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright 2024 Google LLC | ||
// All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using System.Threading.Tasks; | ||
using Agones; | ||
using UnityEngine.Networking; | ||
|
||
namespace Tests.TestingEnvironment | ||
{ | ||
public class SpyRequestSender: IRequestSender | ||
{ | ||
public string LastApi { get; private set; } | ||
public string LastJson { get; private set; } | ||
public string LastMethod { get; private set; } | ||
public async Task<AgonesSdk.AsyncResult> SendRequestAsync(string api, string json, | ||
string method = UnityWebRequest.kHttpVerbPOST) | ||
{ | ||
LastApi = api; | ||
LastJson = json; | ||
LastMethod = method; | ||
return new AgonesSdk.AsyncResult | ||
{ | ||
ok = true, | ||
json = "{}" | ||
}; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.