#region CPL License /* Nuclex Framework Copyright (C) 2002-2009 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library 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 IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #endregion #if UNITTEST using System; using System.Collections.Generic; using System.Reflection; using System.Runtime.InteropServices; using Microsoft.Xna.Framework.Graphics; using NUnit.Framework; namespace Nuclex.Graphics { /// Unit tests for the vertex helper functions [TestFixture] internal class VertexHelperTest { /// /// Verifies that the primitive count for a line strip is correctly calculated /// [Test] public void TestLineStripPrimitiveCount() { Assert.AreEqual( 122, VertexHelper.GetPrimitiveCount(123, PrimitiveType.LineStrip) ); } /// /// Verifies that the primitive count for a line list is correctly calculated /// [Test] public void TestLineListPrimitiveCount() { Assert.AreEqual( 62, VertexHelper.GetPrimitiveCount(124, PrimitiveType.LineList) ); } /// /// Verifies that the primitive count for a triangle strip is correctly calculated /// [Test] public void TestTriangleStripPrimitiveCount() { Assert.AreEqual( 121, VertexHelper.GetPrimitiveCount(123, PrimitiveType.TriangleStrip) ); } /// /// Verifies that the primitive count for a triangle strip is correctly calculated /// [Test] public void TestTriangleListPrimitiveCount() { Assert.AreEqual( 41, VertexHelper.GetPrimitiveCount(123, PrimitiveType.TriangleList) ); } /// /// Tests whether passing an invalid primitive type to the GetPrimitiveCount() /// method causes it to throw the right exception /// [Test] public void TestInvalidTypePrimitiveCount() { Assert.Throws( delegate() { VertexHelper.GetPrimitiveCount(123, (PrimitiveType)(-1)); } ); } /// /// Verifies that the helper can determine whether a vertex count is valid /// for a line strip /// [Test] public void TestIsValidVertexCountWithLineStrip() { Assert.IsFalse(VertexHelper.IsValidVertexCount(1, PrimitiveType.LineStrip)); Assert.IsTrue(VertexHelper.IsValidVertexCount(123, PrimitiveType.LineStrip)); } /// /// Verifies that the helper can determine whether a vertex count is valid /// for a line list /// [Test] public void TestIsValidVertexCountWithLineList() { Assert.IsFalse(VertexHelper.IsValidVertexCount(123, PrimitiveType.LineList)); Assert.IsTrue(VertexHelper.IsValidVertexCount(124, PrimitiveType.LineList)); } /// /// Verifies that the helper can determine whether a vertex count is valid /// for a triangle strip /// [Test] public void TestIsValidVertexCountWithTriangleStrip() { Assert.IsFalse(VertexHelper.IsValidVertexCount(2, PrimitiveType.TriangleStrip)); Assert.IsTrue(VertexHelper.IsValidVertexCount(123, PrimitiveType.TriangleStrip)); } /// /// Verifies that the helper can determine whether a vertex count is valid /// for a triangle list /// [Test] public void TestIsValidVertexCountWithTriangleList() { Assert.IsFalse(VertexHelper.IsValidVertexCount(122, PrimitiveType.TriangleList)); Assert.IsTrue(VertexHelper.IsValidVertexCount(123, PrimitiveType.TriangleList)); } /// /// Tests whether passing an invalid primitive type to the IsValidVertexCount() /// method causes it to throw the right exception /// [Test] public void TestIsValidVertexCountWithInvalidPrimitiveType() { Assert.Throws( delegate() { VertexHelper.IsValidVertexCount(123, (PrimitiveType)(-1)); } ); } } } // namespace Nuclex.Graphics #endif // UNITTEST