This commit is contained in:
2025-01-17 13:10:42 +01:00
commit 4536213c91
15115 changed files with 1442174 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
{
"displayName": "Exercise 5: Solution",
"description": "How to test and verify code that logs to the console log.",
"interactiveImport": true
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 98b61cbe6cb33d6459acafc4416f80c5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 2fc0400bd351485459090b8a1b80c158
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,17 @@
using UnityEngine;
namespace MyExercise_5s
{
public class MyLoggingClass
{
public void DoSomething()
{
Debug.Log("Doing something");
}
public void DoSomethingElse()
{
Debug.LogError("An error happened. Code: " + Random.Range(0, 10));
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c33a9a41ecf23ef4c90e9aed8113c45d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a7023aa1fd07413478ff7a4262310157
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,31 @@
using System.Text.RegularExpressions;
using MyExercise_5s;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
namespace Tests_5s
{
internal class MyLoggingClassTests
{
[Test]
public void DoSomethingLogsMessage()
{
var loggingClassUnderTest = new MyLoggingClass();
loggingClassUnderTest.DoSomething();
LogAssert.Expect(LogType.Log, "Doing something");
}
[Test]
public void DoSomethingElseLogsError()
{
var loggingClassUnderTest = new MyLoggingClass();
loggingClassUnderTest.DoSomethingElse();
LogAssert.Expect(LogType.Error, new Regex("An error happened. Code: \\d"));
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 99b545004a81ea945bffa04c23c7ff84
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,22 @@
{
"name": "Tests_5s",
"references": [
"UnityEngine.TestRunner",
"UnityEditor.TestRunner",
"MyExercise_5s"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [
"nunit.framework.dll"
],
"autoReferenced": true,
"defineConstraints": [
"UNITY_INCLUDE_TESTS"
],
"versionDefines": []
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 670e922b357dfe04db205d6bc22848e7
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: