public async Task ThrowsForIncorrectTypes(Type type) { var service = new StreamImageSourceService(); var imageSource = (ImageSourceStub)Activator.CreateInstance(type); await Assert.ThrowsAsync <InvalidCastException>(() => service.GetImageAsync(imageSource)); }
public async Task GetImageAsync(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.GetImageAsync(imageSource); var image = Assert.IsType <UIImage>(drawable.Value); image.AssertColorAtCenter(expectedColor); }