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>)); }
public async Task WhenParamValidResultOKAsync() { var goods = new Good[] { new Good() { Product = new Preparation() { Name = "2" }, Supplier = new Supplier() { } }, new Good() { Product = new Preparation() { Name = "1" }, Supplier = new Supplier() { } } }.AsEnumerable(); var strngr = new Mock <IStreinger>(); strngr.Setup(ex => ex.Goods()).Returns(Task.FromResult(goods)); var algo = new Mock <ITopAlgorithm>(); var search = new preparation.Controllers.SearchController(streinger: strngr.Object, topAlgorithm: algo.Object); var actual = search.StackLogic(await strngr.Object.Goods() as IEnumerable <IProduct>); NUnitAssert.IsNotNull(actual); NUnitAssert.AreEqual(2, actual.Count()); goods = new Good[] { new Good() { Product = new Preparation() { Name = "1" }, Supplier = new Supplier() { } }, new Good() { Product = new Preparation() { Name = "1" }, Supplier = new Supplier() { } } }.AsEnumerable(); actual = search.StackLogic(goods as IEnumerable <IProduct>); NUnitAssert.IsNotNull(actual); NUnitAssert.AreEqual(1, actual.Count()); }