-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test to color and depth color
- Loading branch information
Showing
5 changed files
with
230 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Color Struct | ||
|
||
## Description | ||
|
||
The `Color` struct represents a color in RGBA color space. Each color component is represented as a byte, with values ranging from 0 to 255. | ||
|
||
## Properties | ||
|
||
- `R`: The red component of the color. | ||
- `G`: The green component of the color. | ||
- `B`: The blue component of the color. | ||
- `A`: The alpha (transparency) component of the color. | ||
|
||
## Constructors | ||
|
||
- `Color(byte r, byte g, byte b, byte a)`: Initializes a new instance of the `Color` struct with the specified red, green, blue, and alpha values. | ||
- `Color(int r, int g, int b, int a)`: Initializes a new instance of the `Color` struct with the specified red, green, blue, and alpha values. The integer values are cast to bytes. | ||
|
||
## Static Properties | ||
|
||
- `Black`: Represents the color black. This property is read-only. | ||
- `Red`: Represents the color red. This property is read-only. | ||
|
||
## Examples | ||
|
||
Creating a new `Color` instance: | ||
|
||
```csharp | ||
Color color = new Color(255, 128, 64, 32); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Depth Struct | ||
|
||
## Description | ||
|
||
The `Depth` struct represents a depth value in a 3D space. The depth is represented as an integer. | ||
|
||
## Properties | ||
|
||
- `Value`: The depth value. | ||
|
||
## Constructors | ||
|
||
- `Depth(int value)`: Initializes a new instance of the `Depth` struct with the specified depth value. | ||
|
||
## Examples | ||
|
||
Creating a new `Depth` instance: | ||
|
||
```csharp | ||
Depth depth = new Depth(10); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
// -------------------------------------------------------------------------- | ||
// | ||
// █▀▀█ ░█─── ▀█▀ ░█▀▀▀█ | ||
// ░█▄▄█ ░█─── ░█─ ─▀▀▀▄▄ | ||
// ░█─░█ ░█▄▄█ ▄█▄ ░█▄▄▄█ | ||
// | ||
// -------------------------------------------------------------------------- | ||
// File:ColorTest.cs | ||
// | ||
// Author:Pablo Perdomo Falcón | ||
// Web:https://www.pabllopf.dev/ | ||
// | ||
// Copyright (c) 2021 GNU General Public License v3.0 | ||
// | ||
// This program is free software:you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program.If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
// -------------------------------------------------------------------------- | ||
|
||
using Alis.Core.Aspect.Math.Definition; | ||
using Xunit; | ||
|
||
namespace Alis.Core.Aspect.Math.Test.Definition | ||
{ | ||
|
||
/// <summary> | ||
/// The color tests class | ||
/// </summary> | ||
public class ColorTests | ||
{ | ||
/// <summary> | ||
/// Tests that constructor sets properties correctly when given bytes | ||
/// </summary> | ||
[Fact] | ||
public void Constructor_SetsPropertiesCorrectly_WhenGivenBytes() | ||
{ | ||
// Arrange | ||
const byte r = 255; | ||
const byte g = 128; | ||
const byte b = 64; | ||
const byte a = 32; | ||
|
||
// Act | ||
Color color = new Color(r, g, b, a); | ||
|
||
// Assert | ||
Assert.Equal(r, color.R); | ||
Assert.Equal(g, color.G); | ||
Assert.Equal(b, color.B); | ||
Assert.Equal(a, color.A); | ||
} | ||
|
||
/// <summary> | ||
/// Tests that constructor sets properties correctly when given ints | ||
/// </summary> | ||
[Fact] | ||
public void Constructor_SetsPropertiesCorrectly_WhenGivenInts() | ||
{ | ||
// Arrange | ||
const int r = 255; | ||
const int g = 128; | ||
const int b = 64; | ||
const int a = 32; | ||
|
||
// Act | ||
Color color = new Color(r, g, b, a); | ||
|
||
// Assert | ||
Assert.Equal(r, color.R); | ||
Assert.Equal(g, color.G); | ||
Assert.Equal(b, color.B); | ||
Assert.Equal(a, color.A); | ||
} | ||
|
||
/// <summary> | ||
/// Tests that black returns correct color | ||
/// </summary> | ||
[Fact] | ||
public void Black_ReturnsCorrectColor() | ||
{ | ||
// Arrange | ||
Color expected = new Color(0, 0, 0, 255); | ||
|
||
// Act | ||
Color actual = Color.Black; | ||
|
||
// Assert | ||
Assert.Equal(expected.R, actual.R); | ||
Assert.Equal(expected.G, actual.G); | ||
Assert.Equal(expected.B, actual.B); | ||
Assert.Equal(expected.A, actual.A); | ||
} | ||
|
||
/// <summary> | ||
/// Tests that red returns correct color | ||
/// </summary> | ||
[Fact] | ||
public void Red_ReturnsCorrectColor() | ||
{ | ||
// Arrange | ||
Color expected = new Color(255, 0, 0, 255); | ||
|
||
// Act | ||
Color actual = Color.Red; | ||
|
||
// Assert | ||
Assert.Equal(expected.R, actual.R); | ||
Assert.Equal(expected.G, actual.G); | ||
Assert.Equal(expected.B, actual.B); | ||
Assert.Equal(expected.A, actual.A); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// -------------------------------------------------------------------------- | ||
// | ||
// █▀▀█ ░█─── ▀█▀ ░█▀▀▀█ | ||
// ░█▄▄█ ░█─── ░█─ ─▀▀▀▄▄ | ||
// ░█─░█ ░█▄▄█ ▄█▄ ░█▄▄▄█ | ||
// | ||
// -------------------------------------------------------------------------- | ||
// File:DepthTest.cs | ||
// | ||
// Author:Pablo Perdomo Falcón | ||
// Web:https://www.pabllopf.dev/ | ||
// | ||
// Copyright (c) 2021 GNU General Public License v3.0 | ||
// | ||
// This program is free software:you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program.If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
// -------------------------------------------------------------------------- | ||
|
||
using Alis.Core.Aspect.Math.Definition; | ||
using Xunit; | ||
|
||
namespace Alis.Core.Aspect.Math.Test.Definition | ||
{ | ||
|
||
/// <summary> | ||
/// The depth tests class | ||
/// </summary> | ||
public class DepthTests | ||
{ | ||
/// <summary> | ||
/// Tests that constructor sets value correctly | ||
/// </summary> | ||
[Fact] | ||
public void Constructor_SetsValueCorrectly() | ||
{ | ||
// Arrange | ||
const int expectedValue = 10; | ||
|
||
// Act | ||
Depth depth = new Depth(expectedValue); | ||
|
||
// Assert | ||
Assert.Equal(expectedValue, depth.Value); | ||
} | ||
} | ||
} |