| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183 | // Licensed to the .NET Foundation under one or more agreements.// The .NET Foundation licenses this file to you under the MIT License.// See the LICENSE file in the project root for more information. using System;using System.Linq;using System.Reactive;using System.Reactive.Linq;using System.Threading.Tasks;using Microsoft.Reactive.Testing;using Microsoft.VisualStudio.TestTools.UnitTesting;using Assert = Xunit.Assert;namespace ReactiveTests.Tests{#pragma warning disable IDE0039 // Use local function    [TestClass]    public class FromAsyncPatternTest : ReactiveTest    {        [TestMethod]        public void FromAsyncPattern_ArgumentChecking()        {            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern(null, iar => { }));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern(null, iar => 0));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int>(null, iar => { }));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int>(null, iar => 0));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int>(null, iar => { }));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int>(null, iar => 0));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int>(null, iar => { }));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int>(null, iar => 0));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int>(null, iar => { }));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int>(null, iar => 0));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int>(null, iar => { }));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int>(null, iar => 0));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int>(null, iar => { }));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int>(null, iar => 0));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int>(null, iar => { }));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int>(null, iar => 0));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int>(null, iar => { }));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int, int>(null, iar => 0));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int, int>(null, iar => { }));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int, int, int>(null, iar => 0));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int, int, int>(null, iar => { }));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int, int, int, int>(null, iar => 0));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int, int, int, int>(null, iar => { }));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int, int, int, int, int>(null, iar => 0));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int, int, int, int, int>(null, iar => { }));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int, int, int, int, int, int>(null, iar => 0));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int, int, int, int, int, int>(null, iar => { }));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int, int, int, int, int, int, int>(null, iar => 0));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int, int, int, int, int, int, int>(null, iar => { }));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int, int, int, int, int, int, int, int>(null, iar => 0));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern((cb, o) => null, default));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int>((cb, o) => null, default));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int>((a, cb, o) => null, default));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int>((a, cb, o) => null, default));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int>((a, b, cb, o) => null, default));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int>((a, b, cb, o) => null, default));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int>((a, b, c, cb, o) => null, default));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int>((a, b, c, cb, o) => null, default));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int>((a, b, c, d, cb, o) => null, default));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int>((a, b, c, d, cb, o) => null, default));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int>((a, b, c, d, e, cb, o) => null, default));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int>((a, b, c, d, e, cb, o) => null, default));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int>((a, b, c, d, e, f, cb, o) => null, default));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int>((a, b, c, d, e, f, cb, o) => null, default));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int>((a, b, c, d, e, f, g, cb, o) => null, default));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int>((a, b, c, d, e, f, g, cb, o) => null, default));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int>((a, b, c, d, e, f, g, h, cb, o) => null, default));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int, int>((a, b, c, d, e, f, g, h, cb, o) => null, default));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int, int>((a, b, c, d, e, f, g, h, i, cb, o) => null, default));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int, int, int>((a, b, c, d, e, f, g, h, i, cb, o) => null, default));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int, int, int>((a, b, c, d, e, f, g, h, i, j, cb, o) => null, default));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int, int, int, int>((a, b, c, d, e, f, g, h, i, j, cb, o) => null, default));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int, int, int, int>((a, b, c, d, e, f, g, h, i, j, k, cb, o) => null, default));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int, int, int, int, int>((a, b, c, d, e, f, g, h, i, j, k, cb, o) => null, default));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int, int, int, int, int>((a, b, c, d, e, f, g, h, i, j, k, l, cb, o) => null, default));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int, int, int, int, int, int>((a, b, c, d, e, f, g, h, i, j, k, l, cb, o) => null, default));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int, int, int, int, int, int>((a, b, c, d, e, f, g, h, i, j, k, l, m, cb, o) => null, default));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int, int, int, int, int, int, int>((a, b, c, d, e, f, g, h, i, j, k, l, m, cb, o) => null, default));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int, int, int, int, int, int, int>((a, b, c, d, e, f, g, h, i, j, k, l, m, n, cb, o) => null, default));            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.FromAsyncPattern<int, int, int, int, int, int, int, int, int, int, int, int, int, int, int>((a, b, c, d, e, f, g, h, i, j, k, l, m, n, cb, o) => null, default));        }        [TestMethod]        public void FromAsyncPattern0()        {            var x = new Result();            Func<AsyncCallback, object, IAsyncResult> begin = (cb, _) => { cb(x); return x; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 1; };            var res = Observable.FromAsyncPattern(begin, end)().Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnNext(1), Notification.CreateOnCompleted<int>()]));        }        [TestMethod]        public void FromAsyncPatternAction0()        {            var x = new Result();            Func<AsyncCallback, object, IAsyncResult> begin = (cb, _) => { cb(x); return x; };            Action<IAsyncResult> end = iar => { Assert.Same(x, iar); };            var res = Observable.FromAsyncPattern(begin, end)().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([new Unit()]));        }        [TestMethod]        public void FromAsyncPattern0_Error()        {            var x = new Result();            var ex = new Exception();            Func<AsyncCallback, object, IAsyncResult> begin = (cb, _) => { cb(x); return x; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); throw ex; };            var res = Observable.FromAsyncPattern(begin, end)().Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        [TestMethod]        public void FromAsyncPattern0_ErrorBegin()        {            var x = new Result();            var ex = new Exception();            Func<AsyncCallback, object, IAsyncResult> begin = (cb, _) => { cb(x); throw ex; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 0; };            var res = Observable.FromAsyncPattern(begin, end)().Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        [TestMethod]        public void FromAsyncPattern1()        {            var x = new Result();            Func<int, AsyncCallback, object, IAsyncResult> begin = (a, cb, _) =>            {                Assert.Equal(a, 2);                cb(x);                return x;            };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 1; };            var res = Observable.FromAsyncPattern(begin, end)(2).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnNext(1), Notification.CreateOnCompleted<int>()]));        }        [TestMethod]        public void FromAsyncPatternAction1()        {            var x = new Result();            Func<int, AsyncCallback, object, IAsyncResult> begin = (a, cb, _) =>            {                Assert.Equal(a, 2);                cb(x);                return x;            };            Action<IAsyncResult> end = iar => { Assert.Same(x, iar); };            var res = Observable.FromAsyncPattern(begin, end)(2).ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([new Unit()]));        }        [TestMethod]        public void FromAsyncPattern1_Error()        {            var x = new Result();            var ex = new Exception();            Func<int, AsyncCallback, object, IAsyncResult> begin = (a, cb, o) => { cb(x); return x; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); throw ex; };            var res = Observable.FromAsyncPattern(begin, end)(2).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        [TestMethod]        public void FromAsyncPattern1_ErrorBegin()        {            var x = new Result();            var ex = new Exception();            Func<int, AsyncCallback, object, IAsyncResult> begin = (a, cb, o) => { cb(x); throw ex; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 0; };            var res = Observable.FromAsyncPattern(begin, end)(2).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        [TestMethod]        public void FromAsyncPattern2()        {            var x = new Result();            Func<int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, cb, _) =>            {                Assert.Equal(a, 2);                Assert.Equal(b, 3);                cb(x);                return x;            };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 1; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnNext(1), Notification.CreateOnCompleted<int>()]));        }        [TestMethod]        public void FromAsyncPatternAction2()        {            var x = new Result();            Func<int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, cb, _) =>            {                Assert.Equal(a, 2);                Assert.Equal(b, 3);                cb(x);                return x;            };            Action<IAsyncResult> end = iar => { Assert.Same(x, iar); };            var res = Observable.FromAsyncPattern(begin, end)(2, 3).ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([new Unit()]));        }        [TestMethod]        public void FromAsyncPattern2_Error()        {            var x = new Result();            var ex = new Exception();            Func<int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, cb, o) => { cb(x); return x; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); throw ex; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        [TestMethod]        public void FromAsyncPattern2_ErrorBegin()        {            var x = new Result();            var ex = new Exception();            Func<int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, cb, o) => { cb(x); throw ex; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 0; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        [TestMethod]        public void FromAsyncPattern3()        {            var x = new Result();            Func<int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, cb, _) =>            {                Assert.Equal(a, 2);                Assert.Equal(b, 3);                Assert.Equal(c, 4);                cb(x);                return x;            };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 1; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnNext(1), Notification.CreateOnCompleted<int>()]));        }        [TestMethod]        public void FromAsyncPatternAction3()        {            var x = new Result();            Func<int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, cb, _) =>            {                Assert.Equal(a, 2);                Assert.Equal(b, 3);                Assert.Equal(c, 4);                cb(x);                return x;            };            Action<IAsyncResult> end = iar => { Assert.Same(x, iar); };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4).ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([new Unit()]));        }        [TestMethod]        public void FromAsyncPattern3_Error()        {            var x = new Result();            var ex = new Exception();            Func<int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, cb, o) => { cb(x); return x; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); throw ex; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        [TestMethod]        public void FromAsyncPattern3_ErrorBegin()        {            var x = new Result();            var ex = new Exception();            Func<int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, cb, o) => { cb(x); throw ex; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 0; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        [TestMethod]        public void FromAsyncPattern4()        {            var x = new Result();            Func<int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, cb, _) =>            {                Assert.Equal(a, 2);                Assert.Equal(b, 3);                Assert.Equal(c, 4);                Assert.Equal(d, 5);                cb(x);                return x;            };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 1; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnNext(1), Notification.CreateOnCompleted<int>()]));        }        [TestMethod]        public void FromAsyncPatternAction4()        {            var x = new Result();            Func<int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, cb, _) =>            {                Assert.Equal(a, 2);                Assert.Equal(b, 3);                Assert.Equal(c, 4);                Assert.Equal(d, 5);                cb(x);                return x;            };            Action<IAsyncResult> end = iar => { Assert.Same(x, iar); };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5).ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([new Unit()]));        }        [TestMethod]        public void FromAsyncPattern4_Error()        {            var x = new Result();            var ex = new Exception();            Func<int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, cb, o) => { cb(x); return x; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); throw ex; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        [TestMethod]        public void FromAsyncPattern4_ErrorBegin()        {            var x = new Result();            var ex = new Exception();            Func<int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, cb, o) => { cb(x); throw ex; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 0; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        [TestMethod]        public void FromAsyncPattern5()        {            var x = new Result();            Func<int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, cb, _) =>            {                Assert.Equal(a, 2);                Assert.Equal(b, 3);                Assert.Equal(c, 4);                Assert.Equal(d, 5);                Assert.Equal(e, 6);                cb(x);                return x;            };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 1; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnNext(1), Notification.CreateOnCompleted<int>()]));        }        [TestMethod]        public void FromAsyncPatternAction5()        {            var x = new Result();            Func<int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, cb, _) =>            {                Assert.Equal(a, 2);                Assert.Equal(b, 3);                Assert.Equal(c, 4);                Assert.Equal(d, 5);                Assert.Equal(e, 6);                cb(x);                return x;            };            Action<IAsyncResult> end = iar => { Assert.Same(x, iar); };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6).ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([new Unit()]));        }        [TestMethod]        public void FromAsyncPattern5_Error()        {            var x = new Result();            var ex = new Exception();            Func<int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, cb, o) => { cb(x); return x; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); throw ex; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        [TestMethod]        public void FromAsyncPattern5_ErrorBegin()        {            var x = new Result();            var ex = new Exception();            Func<int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, cb, o) => { cb(x); throw ex; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 0; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        [TestMethod]        public void FromAsyncPattern6()        {            var x = new Result();            Func<int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, cb, _) =>            {                Assert.Equal(a, 2);                Assert.Equal(b, 3);                Assert.Equal(c, 4);                Assert.Equal(d, 5);                Assert.Equal(e, 6);                Assert.Equal(f, 7);                cb(x);                return x;            };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 1; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnNext(1), Notification.CreateOnCompleted<int>()]));        }        [TestMethod]        public void FromAsyncPatternAction6()        {            var x = new Result();            Func<int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, cb, _) =>            {                Assert.Equal(a, 2);                Assert.Equal(b, 3);                Assert.Equal(c, 4);                Assert.Equal(d, 5);                Assert.Equal(e, 6);                Assert.Equal(f, 7);                cb(x);                return x;            };            Action<IAsyncResult> end = iar => { Assert.Same(x, iar); };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7).ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([new Unit()]));        }        [TestMethod]        public void FromAsyncPattern6_Error()        {            var x = new Result();            var ex = new Exception();            Func<int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, cb, o) => { cb(x); return x; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); throw ex; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        [TestMethod]        public void FromAsyncPattern6_ErrorBegin()        {            var x = new Result();            var ex = new Exception();            Func<int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, cb, o) => { cb(x); throw ex; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 0; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        [TestMethod]        public void FromAsyncPattern7()        {            var x = new Result();            Func<int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, cb, _) =>            {                Assert.Equal(a, 2);                Assert.Equal(b, 3);                Assert.Equal(c, 4);                Assert.Equal(d, 5);                Assert.Equal(e, 6);                Assert.Equal(f, 7);                Assert.Equal(g, 8);                cb(x);                return x;            };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 1; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnNext(1), Notification.CreateOnCompleted<int>()]));        }        [TestMethod]        public void FromAsyncPatternAction7()        {            var x = new Result();            Func<int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, cb, _) =>            {                Assert.Equal(a, 2);                Assert.Equal(b, 3);                Assert.Equal(c, 4);                Assert.Equal(d, 5);                Assert.Equal(e, 6);                Assert.Equal(f, 7);                Assert.Equal(g, 8);                cb(x);                return x;            };            Action<IAsyncResult> end = iar => { Assert.Same(x, iar); };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8).ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([new Unit()]));        }        [TestMethod]        public void FromAsyncPattern7_Error()        {            var x = new Result();            var ex = new Exception();            Func<int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, cb, o) => { cb(x); return x; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); throw ex; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        [TestMethod]        public void FromAsyncPattern7_ErrorBegin()        {            var x = new Result();            var ex = new Exception();            Func<int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, cb, o) => { cb(x); throw ex; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 0; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        [TestMethod]        public void FromAsyncPattern8()        {            var x = new Result();            Func<int, int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, h, cb, _) =>            {                Assert.Equal(a, 2);                Assert.Equal(b, 3);                Assert.Equal(c, 4);                Assert.Equal(d, 5);                Assert.Equal(e, 6);                Assert.Equal(f, 7);                Assert.Equal(g, 8);                Assert.Equal(h, 9);                cb(x);                return x;            };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 1; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8, 9).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnNext(1), Notification.CreateOnCompleted<int>()]));        }        [TestMethod]        public void FromAsyncPatternAction8()        {            var x = new Result();            Func<int, int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, h, cb, _) =>            {                Assert.Equal(a, 2);                Assert.Equal(b, 3);                Assert.Equal(c, 4);                Assert.Equal(d, 5);                Assert.Equal(e, 6);                Assert.Equal(f, 7);                Assert.Equal(g, 8);                Assert.Equal(h, 9);                cb(x);                return x;            };            Action<IAsyncResult> end = iar => { Assert.Same(x, iar); };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8, 9).ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([new Unit()]));        }        [TestMethod]        public void FromAsyncPattern8_Error()        {            var x = new Result();            var ex = new Exception();            Func<int, int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, h, cb, o) => { cb(x); return x; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); throw ex; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8, 9).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        [TestMethod]        public void FromAsyncPattern8_ErrorBegin()        {            var x = new Result();            var ex = new Exception();            Func<int, int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, h, cb, o) => { cb(x); throw ex; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 0; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8, 9).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        [TestMethod]        public void FromAsyncPattern9()        {            var x = new Result();            Func<int, int, int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, h, i, cb, _) =>            {                Assert.Equal(a, 2);                Assert.Equal(b, 3);                Assert.Equal(c, 4);                Assert.Equal(d, 5);                Assert.Equal(e, 6);                Assert.Equal(f, 7);                Assert.Equal(g, 8);                Assert.Equal(h, 9);                Assert.Equal(i, 10);                cb(x);                return x;            };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 1; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8, 9, 10).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnNext(1), Notification.CreateOnCompleted<int>()]));        }        [TestMethod]        public void FromAsyncPatternAction9()        {            var x = new Result();            Func<int, int, int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, h, i, cb, _) =>            {                Assert.Equal(a, 2);                Assert.Equal(b, 3);                Assert.Equal(c, 4);                Assert.Equal(d, 5);                Assert.Equal(e, 6);                Assert.Equal(f, 7);                Assert.Equal(g, 8);                Assert.Equal(h, 9);                Assert.Equal(i, 10);                cb(x);                return x;            };            Action<IAsyncResult> end = iar => { Assert.Same(x, iar); };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8, 9, 10).ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([new Unit()]));        }        [TestMethod]        public void FromAsyncPattern9_Error()        {            var x = new Result();            var ex = new Exception();            Func<int, int, int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, h, i, cb, o) => { cb(x); return x; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); throw ex; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8, 9, 10).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        [TestMethod]        public void FromAsyncPattern9_ErrorBegin()        {            var x = new Result();            var ex = new Exception();            Func<int, int, int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, h, i, cb, o) => { cb(x); throw ex; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 0; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8, 9, 10).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        [TestMethod]        public void FromAsyncPattern10()        {            var x = new Result();            Func<int, int, int, int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, h, i, j, cb, _) =>            {                Assert.Equal(a, 2);                Assert.Equal(b, 3);                Assert.Equal(c, 4);                Assert.Equal(d, 5);                Assert.Equal(e, 6);                Assert.Equal(f, 7);                Assert.Equal(g, 8);                Assert.Equal(h, 9);                Assert.Equal(i, 10);                Assert.Equal(j, 11);                cb(x);                return x;            };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 1; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8, 9, 10, 11).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnNext(1), Notification.CreateOnCompleted<int>()]));        }        [TestMethod]        public void FromAsyncPatternAction10()        {            var x = new Result();            Func<int, int, int, int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, h, i, j, cb, _) =>            {                Assert.Equal(a, 2);                Assert.Equal(b, 3);                Assert.Equal(c, 4);                Assert.Equal(d, 5);                Assert.Equal(e, 6);                Assert.Equal(f, 7);                Assert.Equal(g, 8);                Assert.Equal(h, 9);                Assert.Equal(i, 10);                Assert.Equal(j, 11);                cb(x);                return x;            };            Action<IAsyncResult> end = iar => { Assert.Same(x, iar); };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8, 9, 10, 11).ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([new Unit()]));        }        [TestMethod]        public void FromAsyncPattern10_Error()        {            var x = new Result();            var ex = new Exception();            Func<int, int, int, int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, h, i, j, cb, o) => { cb(x); return x; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); throw ex; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8, 9, 10, 11).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        [TestMethod]        public void FromAsyncPattern10_ErrorBegin()        {            var x = new Result();            var ex = new Exception();            Func<int, int, int, int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, h, i, j, cb, o) => { cb(x); throw ex; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 0; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8, 9, 10, 11).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        [TestMethod]        public void FromAsyncPattern11()        {            var x = new Result();            Func<int, int, int, int, int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, h, i, j, k, cb, _) =>            {                Assert.Equal(a, 2);                Assert.Equal(b, 3);                Assert.Equal(c, 4);                Assert.Equal(d, 5);                Assert.Equal(e, 6);                Assert.Equal(f, 7);                Assert.Equal(g, 8);                Assert.Equal(h, 9);                Assert.Equal(i, 10);                Assert.Equal(j, 11);                Assert.Equal(k, 12);                cb(x);                return x;            };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 1; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnNext(1), Notification.CreateOnCompleted<int>()]));        }        [TestMethod]        public void FromAsyncPatternAction11()        {            var x = new Result();            Func<int, int, int, int, int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, h, i, j, k, cb, _) =>            {                Assert.Equal(a, 2);                Assert.Equal(b, 3);                Assert.Equal(c, 4);                Assert.Equal(d, 5);                Assert.Equal(e, 6);                Assert.Equal(f, 7);                Assert.Equal(g, 8);                Assert.Equal(h, 9);                Assert.Equal(i, 10);                Assert.Equal(j, 11);                Assert.Equal(k, 12);                cb(x);                return x;            };            Action<IAsyncResult> end = iar => { Assert.Same(x, iar); };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12).ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([new Unit()]));        }        [TestMethod]        public void FromAsyncPattern11_Error()        {            var x = new Result();            var ex = new Exception();            Func<int, int, int, int, int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, h, i, j, k, cb, o) => { cb(x); return x; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); throw ex; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        [TestMethod]        public void FromAsyncPattern11_ErrorBegin()        {            var x = new Result();            var ex = new Exception();            Func<int, int, int, int, int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, h, i, j, k, cb, o) => { cb(x); throw ex; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 0; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        [TestMethod]        public void FromAsyncPattern12()        {            var x = new Result();            Func<int, int, int, int, int, int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, h, i, j, k, l, cb, _) =>            {                Assert.Equal(a, 2);                Assert.Equal(b, 3);                Assert.Equal(c, 4);                Assert.Equal(d, 5);                Assert.Equal(e, 6);                Assert.Equal(f, 7);                Assert.Equal(g, 8);                Assert.Equal(h, 9);                Assert.Equal(i, 10);                Assert.Equal(j, 11);                Assert.Equal(k, 12);                Assert.Equal(l, 13);                cb(x);                return x;            };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 1; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnNext(1), Notification.CreateOnCompleted<int>()]));        }        [TestMethod]        public void FromAsyncPatternAction12()        {            var x = new Result();            Func<int, int, int, int, int, int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, h, i, j, k, l, cb, _) =>            {                Assert.Equal(a, 2);                Assert.Equal(b, 3);                Assert.Equal(c, 4);                Assert.Equal(d, 5);                Assert.Equal(e, 6);                Assert.Equal(f, 7);                Assert.Equal(g, 8);                Assert.Equal(h, 9);                Assert.Equal(i, 10);                Assert.Equal(j, 11);                Assert.Equal(k, 12);                Assert.Equal(l, 13);                cb(x);                return x;            };            Action<IAsyncResult> end = iar => { Assert.Same(x, iar); };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13).ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([new Unit()]));        }        [TestMethod]        public void FromAsyncPattern12_Error()        {            var x = new Result();            var ex = new Exception();            Func<int, int, int, int, int, int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, h, i, j, k, l, cb, o) => { cb(x); return x; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); throw ex; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        [TestMethod]        public void FromAsyncPattern12_ErrorBegin()        {            var x = new Result();            var ex = new Exception();            Func<int, int, int, int, int, int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, h, i, j, k, l, cb, o) => { cb(x); throw ex; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 0; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        [TestMethod]        public void FromAsyncPattern13()        {            var x = new Result();            Func<int, int, int, int, int, int, int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, h, i, j, k, l, m, cb, _) =>            {                Assert.Equal(a, 2);                Assert.Equal(b, 3);                Assert.Equal(c, 4);                Assert.Equal(d, 5);                Assert.Equal(e, 6);                Assert.Equal(f, 7);                Assert.Equal(g, 8);                Assert.Equal(h, 9);                Assert.Equal(i, 10);                Assert.Equal(j, 11);                Assert.Equal(k, 12);                Assert.Equal(l, 13);                Assert.Equal(m, 14);                cb(x);                return x;            };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 1; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnNext(1), Notification.CreateOnCompleted<int>()]));        }        [TestMethod]        public void FromAsyncPatternAction13()        {            var x = new Result();            Func<int, int, int, int, int, int, int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, h, i, j, k, l, m, cb, _) =>            {                Assert.Equal(a, 2);                Assert.Equal(b, 3);                Assert.Equal(c, 4);                Assert.Equal(d, 5);                Assert.Equal(e, 6);                Assert.Equal(f, 7);                Assert.Equal(g, 8);                Assert.Equal(h, 9);                Assert.Equal(i, 10);                Assert.Equal(j, 11);                Assert.Equal(k, 12);                Assert.Equal(l, 13);                Assert.Equal(m, 14);                cb(x);                return x;            };            Action<IAsyncResult> end = iar => { Assert.Same(x, iar); };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14).ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([new Unit()]));        }        [TestMethod]        public void FromAsyncPattern13_Error()        {            var x = new Result();            var ex = new Exception();            Func<int, int, int, int, int, int, int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, h, i, j, k, l, m, cb, o) => { cb(x); return x; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); throw ex; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        [TestMethod]        public void FromAsyncPattern13_ErrorBegin()        {            var x = new Result();            var ex = new Exception();            Func<int, int, int, int, int, int, int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, h, i, j, k, l, m, cb, o) => { cb(x); throw ex; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 0; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        [TestMethod]        public void FromAsyncPattern14()        {            var x = new Result();            Func<int, int, int, int, int, int, int, int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, h, i, j, k, l, m, n, cb, _) =>            {                Assert.Equal(a, 2);                Assert.Equal(b, 3);                Assert.Equal(c, 4);                Assert.Equal(d, 5);                Assert.Equal(e, 6);                Assert.Equal(f, 7);                Assert.Equal(g, 8);                Assert.Equal(h, 9);                Assert.Equal(i, 10);                Assert.Equal(j, 11);                Assert.Equal(k, 12);                Assert.Equal(l, 13);                Assert.Equal(m, 14);                Assert.Equal(n, 15);                cb(x);                return x;            };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 1; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnNext(1), Notification.CreateOnCompleted<int>()]));        }        [TestMethod]        public void FromAsyncPatternAction14()        {            var x = new Result();            Func<int, int, int, int, int, int, int, int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, h, i, j, k, l, m, n, cb, _) =>            {                Assert.Equal(a, 2);                Assert.Equal(b, 3);                Assert.Equal(c, 4);                Assert.Equal(d, 5);                Assert.Equal(e, 6);                Assert.Equal(f, 7);                Assert.Equal(g, 8);                Assert.Equal(h, 9);                Assert.Equal(i, 10);                Assert.Equal(j, 11);                Assert.Equal(k, 12);                Assert.Equal(l, 13);                Assert.Equal(m, 14);                Assert.Equal(n, 15);                cb(x);                return x;            };            Action<IAsyncResult> end = iar => { Assert.Same(x, iar); };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15).ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([new Unit()]));        }        [TestMethod]        public void FromAsyncPattern14_Error()        {            var x = new Result();            var ex = new Exception();            Func<int, int, int, int, int, int, int, int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, h, i, j, k, l, m, n, cb, o) => { cb(x); return x; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); throw ex; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        [TestMethod]        public void FromAsyncPattern14_ErrorBegin()        {            var x = new Result();            var ex = new Exception();            Func<int, int, int, int, int, int, int, int, int, int, int, int, int, int, AsyncCallback, object, IAsyncResult> begin = (a, b, c, d, e, f, g, h, i, j, k, l, m, n, cb, o) => { cb(x); throw ex; };            Func<IAsyncResult, int> end = iar => { Assert.Same(x, iar); return 0; };            var res = Observable.FromAsyncPattern(begin, end)(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15).Materialize().ToEnumerable().ToArray();            Assert.True(res.SequenceEqual([Notification.CreateOnError<int>(ex)]));        }        private class Result : IAsyncResult        {            public object AsyncState            {                get { throw new NotImplementedException(); }            }            public System.Threading.WaitHandle AsyncWaitHandle            {                get { throw new NotImplementedException(); }            }            public bool CompletedSynchronously            {                get { throw new NotImplementedException(); }            }            public bool IsCompleted            {                get { throw new NotImplementedException(); }            }        }    }#pragma warning restore IDE0039 // Use local function}
 |