forked from MonoGame/MonoGame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TextureContentTests.cs
126 lines (105 loc) · 5.28 KB
/
TextureContentTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
using NUnit.Framework;
namespace MonoGame.Tests.ContentPipeline
{
class TextureContentTests
{
[Test]
public void Texture2DContent()
{
var content = new Texture2DContent();
Assert.NotNull(content.Faces);
Assert.AreEqual(1, content.Faces.Count);
Assert.NotNull(content.Faces[0]);
Assert.AreEqual(0, content.Faces[0].Count);
Assert.NotNull(content.Mipmaps);
Assert.AreEqual(content.Faces[0], content.Mipmaps);
Assert.AreEqual(0, content.Mipmaps.Count);
content.Faces[0] = new MipmapChain(new PixelBitmapContent<Color>(2,2));
Assert.AreEqual(content.Faces[0], content.Mipmaps);
Assert.AreEqual(1, content.Faces[0].Count);
Assert.AreEqual(1, content.Mipmaps.Count);
content.Faces[0].Add(new PixelBitmapContent<Color>(1, 1));
Assert.AreEqual(2, content.Faces[0].Count);
Assert.AreEqual(2, content.Mipmaps.Count);
Assert.Throws<NotSupportedException>(() => content.Faces.Clear());
Assert.Throws<NotSupportedException>(() => content.Faces.RemoveAt(0));
Assert.Throws<NotSupportedException>(() => content.Faces.Add(new MipmapChain()));
Assert.Throws<NotSupportedException>(() => content.Faces.Insert(0, new MipmapChain()));
Assert.Throws<NotSupportedException>(() => content.Faces.Remove(content.Faces[0]));
}
[Test]
public void Texture3DContent()
{
var content = new Texture3DContent();
Assert.NotNull(content.Faces);
Assert.AreEqual(0, content.Faces.Count);
var face0 = new MipmapChain(new PixelBitmapContent<Color>(2, 2));
content.Faces.Add(face0);
Assert.AreEqual(1, content.Faces.Count);
Assert.AreEqual(face0, content.Faces[0]);
Assert.AreEqual(1, content.Faces[0].Count);
content.Faces[0].Add(new PixelBitmapContent<Color>(1, 1));
Assert.AreEqual(2, content.Faces[0].Count);
var face2 = new MipmapChain(new PixelBitmapContent<Color>(2, 2));
content.Faces.Add(face2);
Assert.AreEqual(face2, content.Faces[1]);
Assert.AreEqual(2, content.Faces.Count);
var face1 = new MipmapChain(new PixelBitmapContent<Color>(2, 2));
content.Faces.Insert(1, face1);
Assert.AreEqual(face1, content.Faces[1]);
Assert.AreEqual(3, content.Faces.Count);
content.Faces.RemoveAt(0);
Assert.AreEqual(2, content.Faces.Count);
Assert.AreEqual(face1, content.Faces[0]);
Assert.AreEqual(face2, content.Faces[1]);
content.Faces.Remove(face1);
Assert.AreEqual(1, content.Faces.Count);
Assert.AreEqual(face2, content.Faces[0]);
content.Faces.Clear();
Assert.AreEqual(0, content.Faces.Count);
}
[Test]
public void TextureCubeContent()
{
var content = new TextureCubeContent();
Assert.NotNull(content.Faces);
Assert.AreEqual(6, content.Faces.Count);
Assert.NotNull(content.Faces[0]);
Assert.NotNull(content.Faces[1]);
Assert.NotNull(content.Faces[2]);
Assert.NotNull(content.Faces[3]);
Assert.NotNull(content.Faces[4]);
Assert.NotNull(content.Faces[5]);
Assert.AreEqual(0, content.Faces[0].Count);
Assert.AreEqual(0, content.Faces[1].Count);
Assert.AreEqual(0, content.Faces[2].Count);
Assert.AreEqual(0, content.Faces[3].Count);
Assert.AreEqual(0, content.Faces[4].Count);
Assert.AreEqual(0, content.Faces[5].Count);
var face0 = new MipmapChain(new PixelBitmapContent<Color>(2, 2));
content.Faces[0] = face0;
Assert.AreEqual(face0, content.Faces[0]);
Assert.AreEqual(1, content.Faces[0].Count);
content.Faces[0].Add(new PixelBitmapContent<Color>(1, 1));
Assert.AreEqual(2, content.Faces[0].Count);
content.Faces[1].Add(new PixelBitmapContent<Color>(2, 2));
content.Faces[2].Add(new PixelBitmapContent<Color>(2, 2));
content.Faces[3].Add(new PixelBitmapContent<Color>(2, 2));
content.Faces[4].Add(new PixelBitmapContent<Color>(2, 2));
content.Faces[5].Add(new PixelBitmapContent<Color>(2, 2));
Assert.AreEqual(1, content.Faces[1].Count);
Assert.AreEqual(1, content.Faces[2].Count);
Assert.AreEqual(1, content.Faces[3].Count);
Assert.AreEqual(1, content.Faces[4].Count);
Assert.AreEqual(1, content.Faces[5].Count);
Assert.Throws<NotSupportedException>(() => content.Faces.Clear());
Assert.Throws<NotSupportedException>(() => content.Faces.RemoveAt(0));
Assert.Throws<NotSupportedException>(() => content.Faces.Add(new MipmapChain()));
Assert.Throws<NotSupportedException>(() => content.Faces.Insert(0, new MipmapChain()));
Assert.Throws<NotSupportedException>(() => content.Faces.Remove(content.Faces[0]));
}
}
}