Files
SGU-CredentialProvider/tests/SGU.CredentialProvider.Tests/ProviderTileIconTests.cs
T

51 lines
1.8 KiB
C#

using System.Drawing;
using Lithnet.CredentialProvider;
using Xunit;
namespace SGU.CredentialProvider.Tests;
public sealed class ProviderTileIconTests
{
[Fact]
public void ProviderPublishesASeventyTwoPixelLogoForSignInOptions()
{
SguCredentialProvider provider = new();
CredentialProviderLogoControl logo = Assert.Single(
provider.GetControls(UsageScenario.Logon).OfType<CredentialProviderLogoControl>());
Assert.Equal(ProviderTileIcon.Size, logo.Bitmap.Width);
Assert.Equal(ProviderTileIcon.Size, logo.Bitmap.Height);
Assert.Equal(Color.FromArgb(0, 83, 155).ToArgb(), logo.Bitmap.GetPixel(0, 0).ToArgb());
int lightPixels = 0;
for (int x = 0; x < logo.Bitmap.Width; x++)
{
for (int y = 0; y < logo.Bitmap.Height; y++)
{
if (logo.Bitmap.GetPixel(x, y).GetBrightness() > 0.7f)
{
lightPixels++;
}
}
}
Assert.InRange(lightPixels, 200, 2_000);
}
[Fact]
public void ProviderPublishesABrandedDedicatedUserTileAndHeading()
{
SguCredentialProvider provider = new();
ControlBase[] controls = provider.GetControls(UsageScenario.Logon).ToArray();
UserTileControl userTile = Assert.Single(controls.OfType<UserTileControl>());
LargeLabelControl heading = Assert.Single(controls.OfType<LargeLabelControl>());
SguCredentialTile tile = Assert.IsType<SguCredentialTile>(provider.CreateGenericTile());
Assert.Equal(ProviderTileIcon.UserTileSize, userTile.Bitmap.Width);
Assert.Equal(ProviderTileIcon.UserTileSize, userTile.Bitmap.Height);
Assert.Equal("Acceso institucional SGU", heading.Label);
Assert.Equal(GenericTileDisplayMode.DisplayAsDedicatedTile, tile.GenericTileDisplayMode);
}
}