/
PlatformBitmapLoaderTests.cs
60 lines (56 loc) · 1.99 KB
/
PlatformBitmapLoaderTests.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
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
using System.Text;
using Xunit;
namespace Splat.Tests.Platform
{
/// <summary>
/// Unit tests for the platform specific Bitmap loader.
/// </summary>
public sealed class PlatformBitmapLoaderTests
{
#if !NETSTANDARD
/// <summary>
/// Check to ensure an instance is returned.
/// </summary>
[Fact]
public void Constructor_ReturnsInstance()
{
var instance = new Splat.PlatformBitmapLoader();
Assert.NotNull(instance);
}
#endif
#if ANDROID
/// <summary>
/// Checks to ensure a dynamic assembly behaves on android.
/// </summary>
/// <remarks>
/// Introduced because of Splat #330.
/// </remarks>
[Fact]
public void GetTypesFromAssembly_ReturnsResultsOnDynamicAssembly()
{
var name = new AssemblyName("SomeRandomDynamicAssembly");
var assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(
name, AssemblyBuilderAccess.Run);
// can't test with a logger, as it invokes the splat init, which puts the test in a false state as it will init the platform bitmap loader
var drawableList = Splat.PlatformBitmapLoader.GetTypesFromAssembly(assemblyBuilder, null);
Assert.NotNull(drawableList);
Assert.Equal(0, drawableList.Length);
}
/// <summary>
/// Checks to ensure a list of drawable items is returned.
/// </summary>
[Fact]
public void GetDrawableList_ReturnsResults()
{
// can't test with a logger, as it invokes the splat init, which puts the test in a false state as it will init the platform bitmap loader
var drawableList = Splat.PlatformBitmapLoader.GetDrawableList(null);
Assert.NotNull(drawableList);
Assert.True(drawableList.Count > 0);
}
#endif
}
}