65 lines
2.5 KiB
C#
65 lines
2.5 KiB
C#
using System.Drawing;
|
|
using Lithnet.CredentialProvider;
|
|
using Xunit;
|
|
|
|
namespace SGU.CredentialProvider.Tests;
|
|
|
|
public sealed class ProviderTileIconTests
|
|
{
|
|
[Fact]
|
|
public void ProviderPublishesAHighResolutionLogoForSignInOptions()
|
|
{
|
|
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(0, logo.Bitmap.GetPixel(0, 0).A);
|
|
Assert.Equal(0, logo.Bitmap.GetPixel(ProviderTileIcon.Size - 1, 0).A);
|
|
Assert.Equal(0, logo.Bitmap.GetPixel(0, ProviderTileIcon.Size - 1).A);
|
|
Assert.Equal(0, logo.Bitmap.GetPixel(ProviderTileIcon.Size - 1, ProviderTileIcon.Size - 1).A);
|
|
int redPixels = 0;
|
|
int navyPixels = 0;
|
|
for (int x = 0; x < logo.Bitmap.Width; x++)
|
|
{
|
|
for (int y = 0; y < logo.Bitmap.Height; y++)
|
|
{
|
|
Color pixel = logo.Bitmap.GetPixel(x, y);
|
|
if (pixel.R > 160 && pixel.G < 100 && pixel.B < 100)
|
|
{
|
|
redPixels++;
|
|
}
|
|
|
|
if (pixel.B > pixel.R && pixel.B > pixel.G && pixel.R < 70)
|
|
{
|
|
navyPixels++;
|
|
}
|
|
}
|
|
}
|
|
|
|
Assert.InRange(redPixels, 1_000, 30_000);
|
|
Assert.InRange(navyPixels, 1_000, 50_000);
|
|
}
|
|
|
|
[Fact]
|
|
public void ProviderPublishesASingleBrandedImageAndLargeHeading()
|
|
{
|
|
SguCredentialProvider provider = new();
|
|
ControlBase[] controls = provider.GetControls(UsageScenario.Logon).ToArray();
|
|
|
|
Assert.Empty(controls.OfType<UserTileControl>());
|
|
Assert.Single(controls.OfType<CredentialProviderLogoControl>());
|
|
CredentialProviderLabelControl providerLabel = Assert.Single(controls.OfType<CredentialProviderLabelControl>());
|
|
LargeLabelControl heading = Assert.Single(controls.OfType<LargeLabelControl>());
|
|
SguCredentialTile tile = Assert.IsType<SguCredentialTile>(provider.CreateGenericTile());
|
|
|
|
Assert.Equal("La Salle · Acceso SGU", providerLabel.Label);
|
|
Assert.Equal("Acceso institucional SGU", heading.Label);
|
|
Assert.Equal(FieldState.DisplayInSelectedTile, heading.State);
|
|
Assert.Equal(GenericTileDisplayMode.DisplayAsDedicatedTile, tile.GenericTileDisplayMode);
|
|
Assert.IsAssignableFrom<CredentialTile3>(tile);
|
|
}
|
|
}
|