public StubExecutor(bool authenticationRequired = true) { AuthenticationRequired = authenticationRequired; RegisterHandler(typeof(GetVersion).FullName, p => { var service = new GetVersionService(); return(service.Execute((GetVersion)p)); }); RegisterHandler(typeof(Calculate).FullName, p => { var service = new CalculateService(); return(service.Execute((Calculate)p)); }); RegisterHandler(typeof(DelayRequest).FullName, p => { var service = new DelayService(); return(service.Execute((DelayRequest)p)); }); RegisterHandler(typeof(EventBroadcaster).FullName, p => { var context = RequestContext.Current; var service = new EventBroadcasterService(context.Server); service.Execute((EventBroadcaster)p); return(null); }); }
public ActionResult RunMrp() { // [Bind(Include = "OrderType,MergeMethod")] CalculateSetting setting = new CalculateSetting() { TaskType = "MRP", OrderType = Request.Form.Get("OrderType"), PartType = (PartType)int.Parse(Request.Form.Get("PartType")), MergeMethod = new MergeMethod() { FirstDay = DateTime.Parse(Request.Form.Get("FirstDay")), Count = int.Parse(Request.Form.Get("Count")), MergeType = Request.Form.Get("MergeType") } }; Message msg = new Message() { Result = false }; try { ICalculateService cs = new CalculateService(Settings.Default.db); cs.Start(Settings.Default.mrpQueue, setting); msg.Result = true; msg.Msg = "MRP 任务运行成功!"; } catch (Exception e) { msg.Msg = e.Message; } return(Json(msg)); }
// to implement //protected double ExpectedDamagePerSecond = 3.7d; //protected double ExpectedMainHandChanceToHit = 0.89d; //protected double ExpectedAttacksPerSecond = 1.2d; //protected int ExpectedMainHandPhysicalDamageMin = 2; //protected int ExpectedMainHandPhysicalDamageMax = 5; //protected double ExpectedBleedingDamagePerSecondFromMainHandHitsMin = 1.4d; //protected double ExpectedBleedingDamagePerSecondFromMainHandHitsMax = 3.5d; //protected double ExpectedPoisonDamagePerSecondFromMainHandHitsMin = 0.4d; //protected double ExpectedPoisonDamagePerSecondFromMainHandHitsMax = 1.0d; protected Abstract_Character_Tests(CharacterClass characterClass, int level = 1) { CalculateService = new CalculateService { Character = new Character(characterClass) { Level = level } }; Character = CalculateService.Character; switch (characterClass) { case CharacterClass.Shadow: ExpectedLife = 57; ExpectedMana = 52; ExpectedDexterity = 23; ExpectedStrength = 14; ExpectedIntelligence = 23; ExpectedManaRegenerationPerSecond = 0.9; ExpectedEvasionRating = 59; ExpectedMainHandAccuracyRating = 46; ExpectedEnergieShield = 0; break; default: throw new NotImplementedException(); } }
public void Setup() { Fixture = new Fixture(); MathServiceMock = new Mock <IMathService>(); Service = new CalculateService(MathServiceMock.Object); }
public void Execute(IJobExecutionContext context) { try { DateTime date = DateTime.Now.Date; //(DateTime)context.MergedJobDataMap.Get("Date"); LogUtil.Logger.Info("start gen StockSumRecordJob"); //IStockSumRecordService ss = new StockSumRecordService(Properties.Settings.Default.db); //ss.Generate(date); CalculateSetting setting = new CalculateSetting() { TaskType = "SumStock", Parameters = DateTime.Now.Date.ToString() //new Dictionary<string, string>() }; // setting.Parameters.Add("date", DateTime.Now.Date.ToString()); ICalculateService cs = new CalculateService(Settings.Default.db); cs.Start(Settings.Default.mrpQueue, setting); LogUtil.Logger.Info("end gen StockSumRecordJob"); } catch (Exception ex) { LogUtil.Logger.Error("StockSumRecordJob exec error!"); LogUtil.Logger.Error(ex.Message); LogUtil.Logger.Error(ex.StackTrace); LogUtil.Logger.Info("[Refire] StockSumRecordJob"); JobExecutionException e2 = new JobExecutionException(ex); e2.RefireImmediately = true; throw e2; } }
public void Sin() { CalculateService calc = new CalculateService(); var res = calc.Sin(30); Assert.AreEqual(res, "0.5"); }
public void Shoul_Calculate_When_Pass_Null() { var instance = new CalculateService(); int expectedResult = instance.Calculate(null); Assert.That(expectedResult, Is.EqualTo(0)); }
public void AddNumbersTest(int number1, int number2, int expectedResult) { CalculateService service = new CalculateService(); var result = service.AddTwoNumbers(number1, number2); Assert.AreEqual(expectedResult, result); }
public void Should_Calculate_More_Then_One_Digit_Format_When_Pass_String_Any_Symbol_Separated() { var instance = new CalculateService(); int expectedResult = instance.Calculate("12,34"); Assert.That(expectedResult, Is.EqualTo(46)); }
public void Should_Calculate_When_Pass_String_Any_Symbol_Separated() { var instance = new CalculateService(); int expectedResult = instance.Calculate("1;2,3+4"); Assert.That(expectedResult, Is.EqualTo(10)); }
public static void EnterEquation() { Console.WriteLine("Enter your equation:"); string equation = Console.ReadLine(); Console.WriteLine("The result of the equation is: " + CalculateService.CalculateRNP(equation)); Console.WriteLine(); }
public void CalculateService_ProcessInvoice_ShouldExchangeRate_1() { var request = dataFormatService.FormatParameter("2020-08-05", "CAD", "123.45", "CAD"); var calculateService = new CalculateService(rateServiceMock.Object); var response = calculateService.ProcessInvoice(request).Result; Assert.AreEqual(1m, response.ExchangeRate); }
public IndexModel(ApplicationContext database) { _context = database; _calculate = new CalculateService(database); CalculateResult = new ArrayList { false, false, string.Empty, string.Empty, string.Empty, 0, 0 }; }
public void TestPower2() { CalculateService calc = new CalculateService(); var result = calc.Calculate2("2^3+1"); Assert.AreEqual(result, "16"); }
public void Debug_Write_Accuracy_Per_Level() { for (var l = 1; l < 101; l++) { Character.Level = l; Debug.WriteLine($"Accurracy level {l} : " + CalculateService.Accuracy()); } }
public void throw_exception_if_income_not_larger_than_0() { //arrange var service = new CalculateService(); // assert Assert.Catch <ArgumentException>(() => service.Calculate(_taxRate, -0.1m)); Assert.Catch <ArgumentException>(() => service.Calculate(_taxRate, 0m)); }
public void CalculateService_ProcessInvoice_ShouldBeSameAmount() { var request = dataFormatService.FormatParameter("2020-08-05", "CAD", "123.45", "USD"); var expected = new ResponseModel(0.11m, 123.45m, 0.753855m); var calculateService = new CalculateService(rateServiceMock.Object); var response = calculateService.ProcessInvoice(request).Result; Assert.AreEqual(expected.ConvertedTotal, response.ConvertedTotal); }
public void TotalForCartItem() { // Arrrange var cartItem = GetCartItem(); var calculateService = new CalculateService(); // Act var totalForCartItem = calculateService.TotalForCartItem(cartItem); // Assert Assert.Equal(45, totalForCartItem); }
public void TotalForCart() { // Arrange var cart = GetCart(); var service = new CalculateService(); // Act var calculateCart = service.TotalForCart(cart); // Assert Assert.Equal(55, calculateCart); }
public void Shadow_Level_1_With_Flat_Life_Passives_Tests() { Character.Level = 1; var flat = 12.0; ExpectedLife += (int)flat; Character.AddPassiveStat(Key.Life, Operand.Flat, flat); Assert.True(CalculateService.Life() == ExpectedLife); }
public void Shadow_Level_1_With_Flat_Intelligence_Tests() { Character.Level = 1; var flat = 30.0; ExpectedIntelligence += (int)flat; Character.AddPassiveStat(Key.Intelligence, Operand.Flat, flat); Assert.True(CalculateService.Intelligence() == ExpectedIntelligence); }
public ActionResult Index(int?page) { int pageIndex = PagingHelper.GetPageIndex(page); MRPSearchModel q = new MRPSearchModel(); ICalculateService cs = new CalculateService(Settings.Default.db); IPagedList <MrpRound> rounds = cs.Search(q).ToPagedList(pageIndex, Settings.Default.pageSize); ViewBag.Query = q; SetMrpRoundStatusList(null); return(View(rounds)); }
static void Main(string[] args) { //Calling Forex Service ForexConversionService forex = new ForexConversionService(); //forex.CalculatorService("EUR", "AUD"); forex.GetExchangeRateConversionService("EUR", "AUD"); //Calling Calculate Service CalculateService calService = new CalculateService(); calService.CalculatorService(); }
public void calculate_tax_200000() { //arrange var service = new CalculateService(); // act var result = service.Calculate(_taxRate, 200000m); // assert Assert.IsNotEmpty(result.Description); Assert.AreEqual(200000m, result.TaxableIncome); Assert.AreEqual(67426.16m, result.TotalAmount); }
public void calculate_tax_19404() { //arrange var service = new CalculateService(); // act var result = service.Calculate(_taxRate, 19404.004m); // assert Assert.IsNotEmpty(result.Description); Assert.AreEqual(19404.004m, result.TaxableIncome); Assert.AreEqual(228.76076m, result.TotalAmount); }
public void Execute(IJobExecutionContext context) { try { LogUtil.Logger.Info("start gen AutoStockJob"); List <string> files = FileUtility.GetAllFilesFromDirectory(Settings.Default.autoStockFilePath); //Regex r = new Regex(Settings.Default.autoStockFileRegex); LogUtil.Logger.Error(files); if (files != null && files.Count > 0) { foreach (string file in files) { // if (r.IsMatch(Path.GetFileName(file))){ string fileName = Path.GetFileName(file); if (Settings.Default.autoStockFileRegex.Split(';').Contains(fileName)) { if (FileUtility.IsFileOpen(file)) { string newFile = Process(file); if (!string.IsNullOrWhiteSpace(newFile)) { CalculateSetting setting = new CalculateSetting() { TaskType = "AutoStock", Parameters = newFile //new Dictionary<string, string>() }; // setting.Parameters.Add("file", newFile); ICalculateService cs = new CalculateService(Settings.Default.db); cs.Start(Settings.Default.mrpQueue, setting); } } } // } } } LogUtil.Logger.Info("end gen AutoStockJob"); } catch (Exception ex) { LogUtil.Logger.Error("AutoStockJob exec error!"); LogUtil.Logger.Error(ex.Message); LogUtil.Logger.Error(ex.StackTrace); throw ex; } }
public void Calculate_SimpleStringInputMoreThanTwoValues_Add_CorrectOutput() { ICalculateService calService = new CalculateService(); Calculator cal = new Calculator(new DelimiterService(), new ParseService(), calService); cal.SetStringSequence("5,10,15"); int[] numbers = { 5, 10, 15 }; string expectedValue = numbers.Sum().ToString(); string value = cal.Calculate(Calculator.CalculateOperation.ADD); Assert.IsTrue(value.Contains(expectedValue)); Assert.IsTrue(value.Equals(calService.Sum(numbers.ToList()))); }
public void Shadow_Level_37_With_Flat_And_Increased_Mana_Passives_Tests() { Character.Level = 37; var flat = 15.0; var increased = 0.23; ExpectedMana = 348; Character.AddPassiveStat(Key.Mana, Operand.Flat, flat); Character.AddPassiveStat(Key.Mana, Operand.Increased, increased); Assert.True(CalculateService.Mana() == ExpectedMana); }
public void Shadow_Level_37_With_Flat_And_Increased_Life_Passives_Tests() { Character.Level = 37; var flat = 12.0; var increased = 0.42; ExpectedLife = 711; Character.AddPassiveStat(Key.Life, Operand.Flat, flat); Character.AddPassiveStat(Key.Life, Operand.Increased, increased); Assert.True(CalculateService.Life() == ExpectedLife); }
public void Shadow_Level_1_With_Flat_Mana_Passives_Tests() { Character.Level = 1; var flat = 10.0; ExpectedMana += (int)flat; ExpectedManaRegenerationPerSecond = 1.1; Character.AddPassiveStat(Key.Mana, Operand.Flat, flat); Assert.True(CalculateService.Mana() == ExpectedMana); Assert.True(CalculateService.ManaRegenerationPerSecond() == ExpectedManaRegenerationPerSecond); }