public void CalBundlesTest() { FilledResult actual = MiniumBundleCalculator.CalBundles(28, new List <int> { 9, 6, 3 }); Assert.AreEqual(2, actual.Offset); Assert.IsTrue(actual.filledNumbers.SequenceEqual(new List <int> { 3, 0, 1 })); }
public static FilledMediaOrder CalMediaOrder(MediaOrder mediaOrderItem) { MediaBundles mediaBundles = AllMediaBundles.allBundles[mediaOrderItem.MediaType]; FilledMediaOrder filledMediaOrder = new FilledMediaOrder(mediaOrderItem.MediaType, mediaOrderItem.TargetPosts); try { FilledResult filledResult = MiniumBundleCalculator.CalBundles(mediaOrderItem.TargetPosts, mediaBundles.BundleList.Select(item => item.PostsCount).ToList()); filledMediaOrder.offset = filledResult.Offset; for (int i = 0; i < filledResult.filledNumbers.Count; i++) { FilledSingleBundle filledSingleBundle = new FilledSingleBundle(mediaBundles.BundleList[i]); filledSingleBundle.CountNeeded = filledResult.filledNumbers[i]; filledMediaOrder.filledBundleList.Add(filledSingleBundle); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return(filledMediaOrder); }