Пример #1
0
                public static async Task WhenParamIsNullResultExeptionAsync()
                {
                    var strngr = new Mock <IStreinger>();

                    strngr.Setup(ex => ex.Goods()).Returns(Task.FromResult((IEnumerable <Good>)null));
                    var algo   = new Mock <ITopAlgorithm>();
                    var search = new preparation.Controllers.SearchController(streinger: strngr.Object, topAlgorithm: algo.Object);

                    NUnitAssert.CatchAsync(async() => search.StackLogic(await strngr.Object.Goods() as IEnumerable <IProduct>));
                }
Пример #2
0
                public async Task WhenStreingerReturnNULLResultExeption()
                {
                    var strngr = new Mock <IStreinger>();

                    strngr.Setup(ex => ex.Goods()).Returns(Task.FromResult((IEnumerable <Good>)null));

                    var algo   = new TopAlgorithm();
                    var search = new preparation.Controllers.SearchController(streinger: strngr.Object, topAlgorithm: algo);

                    NUnitAssert.CatchAsync(async() => await search.Index());
                }
Пример #3
0
            public override void Execute(AsyncTestDelegate asyncUserCode)
            {
                var ex = (Exception)null;

                using (new TestExecutionContext.IsolatedContext())
                {
                    try
                    {
                        ex = Assert.CatchAsync(asyncUserCode);
                    }
                    catch { }
                }

                if (ex != null)
                {
                    ExceptionHelper.Rethrow(ex);
                }
            }
Пример #4
0
                public async Task WhenCompanyNameOrProductNameNullResultExeption()
                {
                    var goods = new Good[]
                    {
                        new Good()
                        {
                            Product = new Preparation()
                            {
                            },
                            Supplier = new Supplier()
                            {
                            }
                        }
                    }.AsEnumerable();

                    var strngr = new Mock <IStreinger>();

                    strngr.Setup(ex => ex.Goods()).Returns(Task.FromResult(goods));

                    var algo   = new TopAlgorithm();
                    var search = new preparation.Controllers.SearchController(streinger: strngr.Object, topAlgorithm: algo);

                    NUnitAssert.CatchAsync <ArgumentNullException>(async() => await search.Index());
                }