public async Task ThrowsForIncorrectTypes(Type type) { var service = new StreamImageSourceService(); var imageSource = (ImageSourceStub)Activator.CreateInstance(type); await Assert.ThrowsAsync <InvalidCastException>(() => service.GetDrawableAsync(imageSource, MauiProgram.DefaultContext)); }
public async Task GetDrawableAsync(string colorHex) { var expectedColor = Color.FromArgb(colorHex).ToNative(); var service = new StreamImageSourceService(); var imageSource = new StreamImageSourceStub(CreateBitmapStream(100, 100, expectedColor)); using var drawable = await service.GetDrawableAsync(imageSource, Platform.DefaultContext); var bitmapDrawable = Assert.IsType <BitmapDrawable>(drawable.Value); var bitmap = bitmapDrawable.Bitmap; bitmap.AssertColorAtCenter(expectedColor); }