public void CalculateShareMethodTest() { //Arrange ICalculationMethod calculationMethod = new CalculationMethod(); Calculation calculation = new Calculation(expenseRepository, tableRepository, calculationMethod, optymizer); //Act var resultdict = calculation.CalculateShare(1); var expecteddict = new Dictionary <string, decimal>() { { "Adam_Heniek", 1.75m }, { "Igor_Heniek", 8.2m } }; var keylist = new List <string>() { "Adam_Heniek", "Igor_Heniek" }; var valuelist = new List <decimal>() { 1.75m, 8.2m }; //Assert Assert.IsNotNull(resultdict); Assert.AreEqual(expecteddict.Count, resultdict.Count); Assert.AreEqual(keylist, resultdict.Keys.ToList()); Assert.AreEqual(valuelist, resultdict.Values.ToList()); }
public void DictionaryTest_Optimization() { //Arrange ICalculationMethod calculationMethod = new CalculationMethod(); Calculation calculation = new Calculation(expenseRepository, tableRepository, calculationMethod, optymizer); //Act var dict = calculationMethod.CalculateMembersExpenses(calculation); var optidict = calculationMethod.OptimizeDict(dict); var expecteddict = new Dictionary <string, decimal>() { { "Igor_Adam", 2.15m }, { "Adam_Heniek", 3.90m }, { "Igor_Heniek", 6.05m } }; var keylist = new List <string>() { "Igor_Adam", "Adam_Heniek", "Igor_Heniek" }; var valuelist = new List <decimal>() { 2.15m, 3.90m, 6.05m }; //Assert Assert.IsNotNull(optidict); Assert.AreEqual(expecteddict.Count, optidict.Count); Assert.Contains("Igor_Adam", optidict.Keys); Assert.AreEqual(keylist, optidict.Keys.ToList()); Assert.AreEqual(valuelist, optidict.Values.ToList()); }
public void CalculationsForTestRepo() { //Arrange var mockTestRepo = new Mock <IExpenseRepository>(); mockTestRepo.Setup(x => x.GetAllExpenses(1)).Returns(testRepo); ICalculationMethod calculationMethod = new CalculationMethod(); Calculation calculation = new Calculation(mockTestRepo.Object, tableRepository, calculationMethod, optymizer); //Act var resultdict = calculation.CalculateShare(1); var expecteddict = new Dictionary <string, decimal>() { { "Adam_Tomek", 1.0m }, { "Igor_Tomek", 3.0m } }; var keylist = new List <string>() { "Adam_Tomek", "Igor_Tomek" }; var valuelist = new List <decimal>() { 1.0m, 3.0m }; //Assert Assert.IsNotNull(resultdict); Assert.AreEqual(expecteddict.Count, resultdict.Count); Assert.Contains("Adam_Tomek", resultdict.Keys); Assert.AreEqual(keylist, resultdict.Keys.ToList()); Assert.AreEqual(valuelist, resultdict.Values.ToList()); }
public void DictionaryTest_Optimization_Simple() { //Arrange var simpledict = new Dictionary <string, decimal>() { { "Adam_Igor", 5.10m }, { "Igor_Adam", 3.05m } }; CalculationMethod calculationMethod = new CalculationMethod(); //Act var dict = calculationMethod.OptimizeDict(simpledict); var expecteddict = new Dictionary <string, decimal>() { { "Adam_Igor", 2.05m } }; //Assert Assert.IsNotNull(dict); Assert.AreEqual(expecteddict.Count, dict.Count); Assert.Contains("Adam_Igor", dict.Keys); Assert.Contains(2.05m, dict.Values); }
protected override void Context() { base.Context(); _c1 = new CalculationMethod { Name = "C1", Category = "C" }; _c1.AddSpecies(_originData.Species.Name); _c2 = new CalculationMethod { Name = "C2", Category = "C" }; _c2.AddSpecies(_originData.Species.Name); var modelConfiguration = new ModelConfiguration(); modelConfiguration.ModelName = "Model"; modelConfiguration.SpeciesName = "Species"; var category = new CalculationMethodCategory { Name = "C" }; category.Add(_c1); category.Add(_c2); modelConfiguration.AddCalculationMethodCategory(category); _oldModelProperties = new ModelProperties { ModelConfiguration = modelConfiguration }; _newModelProperties = new ModelProperties { ModelConfiguration = modelConfiguration }; _oldModelProperties.AddCalculationMethod(_c1); _newModelProperties.AddCalculationMethod(_c2); }
protected override void Context() { base.Context(); _notIndividualCategory = new CalculationMethodCategory { CategoryType = CategoryType.Model }; _humanCategory = new CalculationMethodCategory { CategoryType = CategoryType.Individual }; _dogCategory = new CalculationMethodCategory { CategoryType = CategoryType.Individual }; _cmHuman = new CalculationMethod(); _cmHuman.AddSpecies(CoreConstants.Species.Human); _humanCategory.Add(_cmHuman); _cmDog = new CalculationMethod(); _cmDog.AddSpecies("Dog"); _dogCategory.Add(_cmDog); _allCategories.Add(_notIndividualCategory); _allCategories.Add(_humanCategory); _allCategories.Add(_dogCategory); _species = new Species { Name = CoreConstants.Species.Human }; }
protected override void Context() { sut = new CategorialRunModeToCategorialRunModeDTOMapper(); _simulation1 = A.Fake <ISimulation>(); A.CallTo(() => _simulation1.CompoundNames).Returns(new[] { "Drug1", "Drug2" }); _simulation2 = A.Fake <ISimulation>(); A.CallTo(() => _simulation2.CompoundNames).Returns(new[] { "Drug2", "Drug3" }); _allSimulations = new List <ISimulation> { _simulation1, _simulation2 }; _category1 = new CategoryDTO().WithName("Category1"); _category2 = new CategoryDTO().WithName("Category2"); _cm1 = new CalculationMethod { Category = _category1.Name }.WithName("CM1"); _cm2 = new CalculationMethod { Category = _category1.Name }.WithName("CM2"); _cm3 = new CalculationMethod { Category = _category2.Name }.WithName("CM3"); _category1.Methods = new[] { _cm1, _cm2 }; _category2.Methods = new[] { _cm3 }; _allCategories = new[] { _category1, _category2 }; _runMode = new CategorialParameterIdentificationRunMode(); }
protected override void Context() { base.Context(); _organism = new Organism(); _individual = A.Fake <Individual>(); _origin = new OriginData(); var cm1 = new CalculationMethod { Id = "1", Name = "1" }; _cmDTO1 = new CategoryCalculationMethodDTO(); A.CallTo(_calculationMethodDTOMapper).WithReturnType <CategoryCalculationMethodDTO>().Returns(_cmDTO1); _origin.Species = new Species(); _origin.Population = new SpeciesPopulation(); _origin.SubPopulation = new SubPopulation(); _origin.AddCalculationMethod(cm1); _origin.Gender = new Gender(); _subPopulationDTO = A.Fake <IEnumerable <CategoryParameterValueVersionDTO> >(); _parameterAge = A.Fake <IParameter>().WithName(CoreConstants.Parameters.AGE); _parameterHeight = A.Fake <IParameter>().WithName(CoreConstants.Parameters.HEIGHT); _parameterWeight = A.Fake <IParameter>().WithName(CoreConstants.Parameters.WEIGHT); _parameterAgeDTO = A.Fake <ParameterDTO>(); _parameterHeightDTO = A.Fake <ParameterDTO>(); _parameterWeightDTO = A.Fake <ParameterDTO>(); A.CallTo(() => _subPopulationDTOMapper.MapFrom(_origin.SubPopulation)).Returns(_subPopulationDTO); A.CallTo(() => _parameterMapper.MapAsReadWriteFrom(_parameterAge)).Returns(_parameterAgeDTO); A.CallTo(() => _parameterMapper.MapAsReadWriteFrom(_parameterHeight)).Returns(_parameterHeightDTO); A.CallTo(() => _parameterMapper.MapAsReadWriteFrom(_parameterWeight)).Returns(_parameterWeightDTO); A.CallTo(() => _individual.Organism).Returns(_organism); _individual.OriginData = _origin; _organism.AddChildren(_parameterWeight, _parameterHeight, _parameterAge); }
/// <summary> /// Create a new instance of <see cref="PrayerCalculationSettings" /> object. /// </summary> public PrayerCalculationSettings() { ImsakParameter = new PrayerCalculationParameter(-10.0, PrayerCalculationParameterType.MinutesAdjust); CalculationMethod = new CalculationMethod(); JuristicMethod = new JuristicMethod(); HighLatitudeAdjustment = HighLatitudeAdjustment.None; }
protected override void Context() { base.Context(); _calculationMethod = new CalculationMethod { Name = "tralala" }; }
public void TestSetInvalidPresetError() { var method = new CalculationMethod(); Assert.Throws <ArgumentOutOfRangeException>(() => method.SetCalculationMethodPreset(SystemClock.Instance.GetCurrentInstant(), CalculationMethodPreset.Custom)); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { CalculationMethod temp = (CalculationMethod)parameter; this.method = (CalculationMethod)value; return((temp & this.method) != 0); }
protected override void Context() { base.Context(); _categoryName = "categoryName"; _calculationMethodCategory1 = new CalculationMethodCategory { Name = _categoryName + "1" }; _calculationMethodCategory2 = new CalculationMethodCategory { Name = _categoryName + "2" }; _cm1 = new CalculationMethod { Category = _categoryName + "1", Name = "name1" }; _cm2 = new CalculationMethod { Category = _categoryName + "2", Name = "name2" }; _cm3 = new CalculationMethod { Category = _categoryName + "2", Name = "name3" }; _calculationMethodCategory1.Add(_cm1); _calculationMethodCategory2.Add(_cm2); _calculationMethodCategory2.Add(_cm3); _allCalculationMethodCategories.Add(_calculationMethodCategory1); _allCalculationMethodCategories.Add(_calculationMethodCategory2); var compound = new Compound(); compound.CalculationMethodCache.AddCalculationMethod(_cm1); compound.CalculationMethodCache.AddCalculationMethod(_cm2); compound.CalculationMethodCache.AddCalculationMethod(_cm3); sut.Edit(compound, x => !string.Equals(x.Name, "categoryName2")); }
/// <summary> /// Generate CalculationParameters from fajr angle, isha interval, and calculation method /// </summary> /// <param name="fajrAngle">the angle for calculating fajr</param> /// <param name="ishaInterval">the amount of time after maghrib to have isha</param> /// <param name="method">the calculation method to use</param> public CalculationParameters(double fajrAngle, int ishaInterval, CalculationMethod method) { this.FajrAngle = fajrAngle; this.IshaAngle = 0.0; this.IshaInterval = ishaInterval; this.Method = method; }
protected override void Context() { base.Context(); _calculationMethodCache1 = new CalculationMethodCache(); _calculationMethodCache2 = new CalculationMethodCache(); _calculationMethodCat1Item1 = new CalculationMethod { Category = "Cat1", Name = "Item1", DisplayName = "Item1" }; _calculationMethodCat1Item2 = new CalculationMethod { Category = "Cat1", Name = "Item2", DisplayName = "Item2" }; _calculationMethodCat2Item3 = new CalculationMethod { Category = "Cat2", Name = "Item3", DisplayName = "Item3" }; _calculationMethodCat2Item4 = new CalculationMethod { Category = "Cat2", Name = "Item4", DisplayName = "Item4" }; _calculationMethodCat3Item5 = new CalculationMethod { Category = "Cat3", Name = "Item5", DisplayName = "Item5" }; _calculationMethodCache1.AddCalculationMethod(_calculationMethodCat1Item1); _calculationMethodCache1.AddCalculationMethod(_calculationMethodCat2Item3); _calculationMethodCache1.AddCalculationMethod(_calculationMethodCat3Item5); _calculationMethodCache2.AddCalculationMethod(_calculationMethodCat1Item2); _calculationMethodCache2.AddCalculationMethod(_calculationMethodCat2Item4); _object1 = _calculationMethodCache1; _object2 = _calculationMethodCache2; }
public void DictionaryTest_OnePersonInvolved() { //Arrange //var exp = expMaker.CreateExpense(1, "Adam", 12.60m, new List<string>() { "Igor" }); var exp = ExpenseMaker.CreateExpense(1, "Adam", 12.60m, new List <string>() { "Igor" }); var mockRepository = new Mock <IExpenseRepository>(); mockRepository.Setup(x => x.GetAllExpenses(1)).Returns(new List <Expense>() { exp }); ICalculationMethod calculationMethod = new CalculationMethod(); Calculation calculation = new Calculation(mockRepository.Object, tableRepository, calculationMethod, optymizer); calculation.TableNumber = 1; //Act var dict = calculationMethod.CalculateMembersExpenses(calculation); var expecteddict = new Dictionary <string, decimal>() { { "Igor_Adam", 6.30m } }; //Assert Assert.IsNotNull(dict); Assert.AreEqual(expecteddict.Count, dict.Count); Assert.Contains("Igor_Adam", dict.Keys); Assert.Contains(6.30m, dict.Values); }
protected override void Because() { _category = "category"; _oldCalculationMethod = A.Fake <CalculationMethod>(); _newCalculationMethod = A.Fake <CalculationMethod>(); sut.SetCalculationMethodForCompound(_category, _newCalculationMethod, _oldCalculationMethod); }
/// <summary> /// Retrieves a list of phrases depending on their values, calculation methods and alphabet. /// </summary> /// <param name="values">The values to search for</param> /// <param name="calculationMethod">The calculatiopn methods to search for</param> /// <param name="alphabet">The alphabet to search for</param> /// <returns>A list of phrases</returns> public async Task <List <Phrase> > RetrieveAsync(List <int> values, CalculationMethod calculationMethod, Alphabet alphabet) { List <Phrase> phrases = new List <Phrase>(); if (values != null && values.Count > 0 && calculationMethod != CalculationMethod.None && alphabet != Alphabet.None) { string query = $"SELECT Id, Text, OperationId FROM Phrase WHERE ({this.SQLValuesString(values, calculationMethod, alphabet)}) "; using (SQLiteConnection con = new SQLiteConnection(Database.ConnectionString)) { using (SQLiteCommand cmd = new SQLiteCommand(query, con)) { await con.OpenAsync(); using (var dare = await cmd.ExecuteReaderAsync()) { while (await dare.ReadAsync()) { Phrase phrase = new Phrase(dare["Text"].ToString(), dare["OperationId"] == DBNull.Value ? 0 : Convert.ToInt32(dare["OperationId"]), Convert.ToInt32(dare["Id"])); phrases.Add(phrase); } } } } } return(phrases); }
public string CalculatePerformance(CalculationMethod function) { timer.Reset(); timer.Start(); function(); return timer.Elapsed.TotalMilliseconds.ToString(); }
/// <summary> 构造函数 </summary> public MainFormMdi(ModelType type, CalculationMethod method, string modelName) { InitializeComponent(); // ModelForm = CreateModelForm(type, method); ModelForm.Model.ModelName = modelName; // }
public List <object> FindSavingPaymentPlan(CalculationMethod method)//'(decimal presentValue, decimal futureValue, decimal rateOfIntrest, ushort numOfYears, DateTime dateOfFirstPayment, Frequancy payFreq, decimal paymentAmount) { //if (Parameter.PresentValue < 0) // Parameter.PresentValue = -Parameter.PresentValue; // return BuildPlanForSavingRepaying_ByPaymentAmount_RateOfIntrest(false, method); return(BuildPlanForSavingRepaying_ByNumberOfPayment_RateOfIntrest(false, method)); }
public CalculateBL(Guid ElectionElectorateVacancyId, int Vacancies, CalculationMethod CalcMethod, TieMethodType TieMethod, IComputerCountResolver resolver, IReportingDAL reporting) : this(resolver, reporting) { _ElectionElectorateVacancyId = ElectionElectorateVacancyId; _Vacancies = Vacancies; TieMethodType = TieMethod; CalculationMethod = CalcMethod; }
public Rule(string title, DateRange activePeriod, ISpecification <Applicant> condition, CalculationMethod calculationMethod) : base(Guid.NewGuid()) { Title = title; Condition = condition; CalculationMethod = calculationMethod; ActivePeriod = activePeriod; IsActive = true; }
protected override void Context() { base.Context(); _compound = new Compound(); _compoundSpecificCalculationMethod = new CalculationMethod { Category = "C1", Name = "Compound Specific" }; _compound.AddCalculationMethod(_compoundSpecificCalculationMethod); }
// For Functions public EqOperator(string name, TokenCategory type, int maxArgs, CalculationMethod calculationMethod) { Name = name; Type = type; IsLeftAssociative = true; Precedence = 8; // functions have the highest precedence! _calculation = calculationMethod; MaxArguments = maxArgs; MinArguments = maxArgs; }
// For Functions public EqOperator(string name, TokenCategory type, int minArgs, int maxArgs, CalculationMethod calculationMethod) { Name = name; Type = type; IsLeftAssociative = true; Precedence = 0; _calculation = calculationMethod; MaxArguments = maxArgs; MinArguments = minArgs; }
private void addRow(string compound, CalculationMethod method, DataTable dataTable) { var row = dataTable.NewRow(); row["Compound"] = compound; row["Category"] = method.Category; row["Calculation Method"] = method.Name; row["Value"] = Convert.ToBoolean(0); dataTable.Rows.Add(row); }
// For Operators and Constants public EqOperator(string name, TokenCategory type, int precedence, int arguments, bool isLeftAssociated, CalculationMethod calculationMethod) { Name = name; Type = type; IsLeftAssociative = isLeftAssociated; Precedence = precedence; _calculation = calculationMethod; MaxArguments = -1; // Default Max Arguments - Unlimited MinArguments = arguments; }
private void radioButton_CheckedChanged(object sender, EventArgs e) { foreach (RadioButton r in tableLayoutPanel_Method.Controls) { if (r.Checked) { _calculationMethod = (CalculationMethod)r.Tag; break; } } }
public void CreatingOppositeKeyTest() { //Arrange CalculationMethod calculationMethod = new CalculationMethod(); //Act var newstring = calculationMethod.MakingOppositeKey("Igor_Adam"); //Assert Assert.AreEqual("Adam_Igor", newstring); }
public CategoryCalculationMethodDTO MapFrom(CalculationMethod calculationMethod) { var repInfo = _representationInfoRepository.InfoFor(RepresentationObjectType.CATEGORY, calculationMethod.Category); return(new CategoryCalculationMethodDTO { DisplayName = repInfo.DisplayName, Description = repInfo.Description, Category = calculationMethod.Category, CalculationMethod = calculationMethod }); }
// set the calculation method public void setCalcMethod(CalculationMethod methodID) { this.calcMethod = (int)methodID; }
/// <summary>TBD</summary> /// <param name="templateName">TBD</param> /// <param name="row">TBD</param> /// <param name="reportFields">TBD</param> /// <param name="calc">TBD</param> private void BuildReportRowWithComputedField(string templateName, DataRow row, string[] reportFields, CalculationMethod calc) { ArrayList fieldValueList = new ArrayList(); foreach (string field in reportFields) { fieldValueList.Add(Convert.ToString(row[field])); } //Add the computed field fieldValueList.Add(Convert.ToString(calc(row))); base.BuildRow(REPORT_ROW_TEMPLATE_NAME, (string[])fieldValueList.ToArray(typeof(string))); }