Exemple #1
0
        public void TestHashCodeOnDifferingInstances()
        {
            using (
                Texture2D testTexture1 = new Texture2D(
                    this.mockedGraphicsDeviceService.GraphicsDevice,
                    128, 256
                    )
                ) {
                using (
                    Texture2D testTexture2 = new Texture2D(
                        this.mockedGraphicsDeviceService.GraphicsDevice,
                        256, 128
                        )
                    ) {
                    TextureRegion2D region1 = TextureRegion2D.FromTexels(
                        testTexture1, new Point(16, 32), new Point(48, 64)
                        );
                    TextureRegion2D region2 = TextureRegion2D.FromTexels(
                        testTexture1, new Point(80, 96), new Point(112, 128)
                        );

                    Assert.AreNotEqual(region1.GetHashCode(), region2.GetHashCode());
                }
            }
        }
Exemple #2
0
 /// <summary>
 ///   Determines whether the specified <see cref="TextureRegion2D" /> structure is equal
 ///   to the current instance
 /// </summary>
 /// <returns>
 ///   True if the specified <see cref="TextureRegion2D" /> structure is equal to the
 ///   current instance; otherwise, false
 /// </returns>
 /// <param name="other">
 ///   The <see cref="TextureRegion2D" /> structure to be compared with
 ///   the current instance
 /// </param>
 public bool Equals(TextureRegion2D other)
 {
     return
         ((other.Texture == this.Texture) &&
          (other.Min == this.Min) &&
          (other.Max == this.Max));
 }
    public void TestConstructor() {
      using(
        Texture2D testTexture = new Texture2D(
          this.mockedGraphicsDeviceService.GraphicsDevice,
          128, 128
        )
      ) {
        TextureRegion2D region = new TextureRegion2D(testTexture);

        Assert.AreSame(testTexture, region.Texture);
        Assert.AreEqual(Vector2.Zero, region.Min);
        Assert.AreEqual(Vector2.One, region.Max);
      }
    }
Exemple #4
0
        public void TestFloatConstructor()
        {
            using (
                Texture2D testTexture = new Texture2D(
                    this.mockedGraphicsDeviceService.GraphicsDevice,
                    128, 128
                    )
                ) {
                TextureRegion2D region = new TextureRegion2D(testTexture, 0.1f, 0.2f, 0.3f, 0.4f);

                Assert.AreSame(testTexture, region.Texture);
                Assert.AreEqual(new Vector2(0.1f, 0.2f), region.Min);
                Assert.AreEqual(new Vector2(0.3f, 0.4f), region.Max);
            }
        }
Exemple #5
0
        public void TestConstructor()
        {
            using (
                Texture2D testTexture = new Texture2D(
                    this.mockedGraphicsDeviceService.GraphicsDevice,
                    128, 128
                    )
                ) {
                TextureRegion2D region = new TextureRegion2D(testTexture);

                Assert.AreSame(testTexture, region.Texture);
                Assert.AreEqual(Vector2.Zero, region.Min);
                Assert.AreEqual(Vector2.One, region.Max);
            }
        }
Exemple #6
0
        public void TestToString()
        {
            using (
                Texture2D testTexture = new Texture2D(
                    this.mockedGraphicsDeviceService.GraphicsDevice,
                    128, 128
                    )
                ) {
                TextureRegion2D region = TextureRegion2D.FromTexels(
                    testTexture, new Point(16, 32), new Point(48, 64)
                    );

                Assert.IsNotNull(region.ToString());
            }
        }
Exemple #7
0
        public void TestEqualsOnNull()
        {
            using (
                Texture2D testTexture = new Texture2D(
                    this.mockedGraphicsDeviceService.GraphicsDevice,
                    128, 128
                    )
                ) {
                TextureRegion2D region = TextureRegion2D.FromTexels(
                    testTexture, new Point(16, 32), new Point(48, 64)
                    );

                Assert.IsFalse(region.Equals(null));
            }
        }
Exemple #8
0
        public void TestInequalityOnEquivalentInstances()
        {
            using (
                Texture2D testTexture = new Texture2D(
                    this.mockedGraphicsDeviceService.GraphicsDevice,
                    128, 128
                    )
                ) {
                TextureRegion2D region1 = TextureRegion2D.FromTexels(
                    testTexture, new Point(16, 32), new Point(48, 64)
                    );
                TextureRegion2D region2 = TextureRegion2D.FromTexels(
                    testTexture, new Point(16, 32), new Point(48, 64)
                    );

                Assert.IsFalse(region1 != region2);
            }
        }
Exemple #9
0
        public void TestEqualsWithDifferingInstances()
        {
            using (
                Texture2D testTexture = new Texture2D(
                    this.mockedGraphicsDeviceService.GraphicsDevice,
                    128, 128
                    )
                ) {
                TextureRegion2D region1 = TextureRegion2D.FromTexels(
                    testTexture, new Point(16, 32), new Point(48, 64)
                    );
                TextureRegion2D region2 = TextureRegion2D.FromTexels(
                    testTexture, new Point(80, 96), new Point(112, 128)
                    );

                Assert.IsFalse(region1.Equals(region2));
            }
        }
Exemple #10
0
        public void TestHashCodeOnEquivalentInstances()
        {
            using (
                Texture2D testTexture = new Texture2D(
                    this.mockedGraphicsDeviceService.GraphicsDevice,
                    128, 128
                    )
                ) {
                TextureRegion2D region1 = TextureRegion2D.FromTexels(
                    testTexture, new Point(16, 32), new Point(48, 64)
                    );
                TextureRegion2D region2 = TextureRegion2D.FromTexels(
                    testTexture, new Point(16, 32), new Point(48, 64)
                    );

                Assert.AreEqual(region1.GetHashCode(), region2.GetHashCode());
            }
        }
Exemple #11
0
        public void TestFromTexelPoints()
        {
            using (
                Texture2D testTexture = new Texture2D(
                    this.mockedGraphicsDeviceService.GraphicsDevice,
                    128, 256
                    )
                ) {
                TextureRegion2D region = TextureRegion2D.FromTexels(
                    testTexture, new Point(16, 32), new Point(96, 112)
                    );

                Vector2 min = new Vector2(16.0f / 128.0f, 32.0f / 256.0f);
                Vector2 max = new Vector2(96.0f / 128.0f, 112.0f / 256.0f);

                Assert.AreSame(testTexture, region.Texture);
                Assert.AreEqual(min, region.Min);
                Assert.AreEqual(max, region.Max);
            }
        }
    public void TestFloatConstructor() {
      using(
        Texture2D testTexture = new Texture2D(
          this.mockedGraphicsDeviceService.GraphicsDevice,
          128, 128
        )
      ) {
        TextureRegion2D region = new TextureRegion2D(testTexture, 0.1f, 0.2f, 0.3f, 0.4f);

        Assert.AreSame(testTexture, region.Texture);
        Assert.AreEqual(new Vector2(0.1f, 0.2f), region.Min);
        Assert.AreEqual(new Vector2(0.3f, 0.4f), region.Max);
      }
    }
 /// <summary>
 ///   Determines whether the specified <see cref="TextureRegion2D" /> structure is equal
 ///   to the current instance
 /// </summary>
 /// <returns>
 ///   True if the specified <see cref="TextureRegion2D" /> structure is equal to the
 ///   current instance; otherwise, false
 /// </returns>
 /// <param name="other">
 ///   The <see cref="TextureRegion2D" /> structure to be compared with
 ///   the current instance
 /// </param>
 public bool Equals(TextureRegion2D other) {
   return
     (other.Texture == this.Texture) &&
     (other.Min == this.Min) &&
     (other.Max == this.Max);
 }