TileMapPropertiesTest.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. // Copyright (c) Craftwork Games. All rights reserved.
  2. // Licensed under the MIT license.
  3. // See LICENSE file in the project root for full license information.
  4. namespace MonoGame.Extended.Tiled.Tests;
  5. public class TileMapPropertiesTest
  6. {
  7. // NullReferenceException in TiledMapProperties
  8. // https://github.com/craftworkgames/MonoGame.Extended/issues/901
  9. [Fact]
  10. public void TryGetValue_InvalidKey_ReturnsFalse()
  11. {
  12. TiledMapProperties properties = new TiledMapProperties();
  13. var result = properties.TryGetValue("invalid", out string value);
  14. Assert.False(result);
  15. Assert.True(string.IsNullOrEmpty(value));
  16. }
  17. [Fact]
  18. public void TryGetValue_ValidKey_ReturnsFalse()
  19. {
  20. var expected = "value";
  21. TiledMapProperties properties = new TiledMapProperties();
  22. properties.Add("test", new TiledMapPropertyValue(expected));
  23. var result = properties.TryGetValue("test", out string actual);
  24. Assert.True(result);
  25. Assert.Equal(expected, actual);
  26. }
  27. }