public void Inquirer_Gets_Expected_Range(Xiles xile, int size, int toXile, int fromXile) { var data = Helper.GetRandomDataSample(size).ToList(); var calculator = Helper.NewInquirer <TInquirer>(data); var expected = Helper.CalcNthXile(data, (int)xile, toXile) - Helper.CalcNthXile(data, (int)xile, fromXile); var actual = GetInterXileRangeMethod(xile).Invoke(calculator, new object[] {}); Assert.AreEqual(expected, actual); }
private static XileInfo AssertValidXile(int nTh, Xiles xile) { if (nTh < 1 || nTh > (int)xile) { var xileName = Enum.GetName(typeof(Xiles), xile); throw new StatisticsException(string.Format(ExceptionMessages.Invalid_Xile_Name_Format, xileName), new IndexOutOfRangeException(string.Format(ExceptionMessages.Invalid_Xile_Name_Number_Format, xileName, nTh))); } return(new XileInfo(xile, nTh)); }
public void Inquirer_Gets_All_Expected(Xiles xile, int size) { var data = Helper.GetRandomDataSample(size).ToList(); var calculator = Helper.NewInquirer <TInquirer>(data); var method = GetXileMethod(xile); var expected = GetXiles((int)xile, nTh => Helper.CalcNthXile(data, (int)xile, nTh)).ToList(); var actual = GetXiles((int)xile, nTh => (double)method.Invoke(calculator, new object[] { nTh })).ToList(); CollectionAssert.AreEqual(expected, actual); }
public XileInfo(Xiles xile, int nthXile) { this.Xile = xile; this.NthXile = nthXile; }
private static XileInfo AssertValidXile(int nTh, Xiles xile) { if (nTh < 1 || nTh > (int)xile) { var xileName = Enum.GetName(typeof(Xiles), xile); throw new StatisticsException(string.Format(ExceptionMessages.Invalid_Xile_Name_Format, xileName), new IndexOutOfRangeException(string.Format(ExceptionMessages.Invalid_Xile_Name_Number_Format, xileName, nTh))); } return new XileInfo(xile, nTh); }
private MethodInfo GetInterXileRangeMethod(Xiles xile) { return(typeof(TInquirer).GetMethod("GetInter" + Enum.GetName(typeof(Xiles), xile) + "Range")); }
private MethodInfo GetXileMethod(Xiles xile) { return(typeof(TInquirer).GetMethod("Get" + Enum.GetName(typeof(Xiles), xile))); }
public void When_Inquirer_Recieves_Tries_To_Get_Greater(Xiles xile, int size) { GetXileMethod(xile).Invoke(Helper.NewInquirer <TInquirer>(size: size), new object[] { (int)xile + 1 }); }
public void When_Inquirer_Recieves_Tries_To_Get_Negative(Xiles xile, int size) { GetXileMethod(xile).Invoke(Helper.NewInquirer <TInquirer>(size: size), new object[] { -1 }); }