public ActionResult ExecuteTestCase(ExecuteTestCaseModel model) { if (!ModelState.IsValid) { return(RedirectToAction("Index")); } try { IOperationCreator creator = new OperationCreator(); ITestCaseService service = new TestCaseService(creator); var result = service.Execute(model.Content); TestCaseResultModel resultModel = new TestCaseResultModel() { Conten = model.Content, Result = result }; return(View("Result", resultModel)); } catch { return(View("Error")); } }
public void CreateOperation_ValidOperator(decimal firstNumber, decimal secondNumber, string operatorValue) { IOperation operation = OperationCreator.Create(firstNumber, secondNumber, operatorValue); Assert.NotNull(operation); Assert.AreEqual(firstNumber, operation.FirstNumber); Assert.AreEqual(secondNumber, operation.SecondNumber); Assert.IsInstanceOf <SumOperation>(operation); }
public Canvas(int width, int height, OperationCreator operations) { MainBitmap = new Bitmap(width + 500, height + 500); Graphics = Graphics.FromImage(MainBitmap); Pen = new Pen(Color.Black, 1); PreviousBitmaps = new LinkedList <Bitmap>(); PreviousBitmaps.AddLast(MainBitmap); LastPoint = new Point(0, 0); _operations = operations; Fabric = new PenFabric(); Figures = new List <AbstractFigure>(); RenewFigure(); }
public async Task <IActionResult> AddNewOperation( [FromServices] IOperationsRepository operationsRepository, [FromServices] OperationCreator operationCreator, [FromBody] AddOperationBinding binding, [FromServices] IQueryProcessor queryProcessor, CancellationToken cancellationToken) { var operation = await operationsRepository.Get(binding.Id, cancellationToken); if (operation != null) { if (operation.Amount != binding.Amount || operation.UserId != binding.UserId || operation.DocumentId != binding.DocumentId || operation.GuildId != HttpContext.GetGuildId() || operation.Type != binding.Type) { throw new ApiException(HttpStatusCode.Conflict, ErrorCodes.OperationAlreadyExists, $"Operation {binding.Id} already exists", new { operation.Id, operation.Amount, operation.Description, operation.Type, operation.UserId }.ToDictionary()); } return(Ok(operation)); } try{ operation = await operationCreator.Create( binding.Id, HttpContext.GetGuildId(), binding.UserId, binding.DocumentId, binding.Amount, binding.Type, binding.Description, binding.ParentOperationId, cancellationToken); } catch (DocumentNotFoundException e) { throw new ApiException(HttpStatusCode.NotFound, ErrorCodes.DocumentNotFound, e.Message); } await operationsRepository.Save(operation, cancellationToken); return(Ok(await queryProcessor.Process <GetOperationQuery, OperationView>( new GetOperationQuery( guildId: HttpContext.GetGuildId(), operationId: binding.Id) , cancellationToken))); }
public void Execute() { if (!creator.IsValid) { return; } try { operations.Add(creator.Create()); error = ""; } catch (ArgumentException e) { error = e.Message; } creator = new OperationCreator(); }
protected void when_creating_operations() { Operations = OperationCreator.CreateOperations(Handlers); }
public void CreateOperation_InvalidOperator_ThrowException(decimal firstNumber, decimal secondNumber, string operatorValue) { var ex = Assert.Throws <InvalidOperationException>(() => OperationCreator.Create(firstNumber, secondNumber, operatorValue)); }
public static void Create(int width, int height, OperationCreator operation) { _obj = new Canvas(width, height, operation); }
public void ClearAll() => creator = new OperationCreator();
public Calculator() { operations = new List <IOperation>(); creator = new OperationCreator(); error = ""; }