private void ADC(StepInfo info) { var a = A; var b = Read(info.Address); var c = C; A = (byte)(a + b + c); SetZN(A); if (a + b + c > 0xff) { C = 1; } else { C = 0; } if (((a ^ b) & 0x80) == 0 && ((a ^ A) & 0x80) != 0) { V = 1; } else { V = 0; } }
private RunnableStep[] ProvideSteps(IMetadataInfo parent, IEnumerable <StepDescriptor> stepDescriptors, object context, IDependencyContainer container, string groupPrefix, Func <Exception, bool> shouldAbortSubStepExecutionFn) { var descriptors = stepDescriptors.ToArray(); if (!descriptors.Any()) { throw new InvalidOperationException("At least one step has to be provided"); } var metadataProvider = _context.IntegrationContext.MetadataProvider; var totalSteps = descriptors.Length; var steps = new RunnableStep[totalSteps]; string previousStepTypeName = null; var extensions = _context.IntegrationContext.ExecutionExtensions; var stepContext = new RunnableStepContext(_context.ExceptionProcessor, _context.ProgressNotifier, container, context, ProvideSteps, shouldAbortSubStepExecutionFn); for (var stepIndex = 0; stepIndex < totalSteps; ++stepIndex) { var descriptor = descriptors[stepIndex]; var stepInfo = new StepInfo(parent, metadataProvider.GetStepName(descriptor, previousStepTypeName), stepIndex + 1, totalSteps, groupPrefix); var arguments = descriptor.Parameters.Select(p => new MethodArgument(p, metadataProvider.GetValueFormattingServiceFor(p.ParameterInfo))).ToArray(); steps[stepIndex] = new RunnableStep(stepContext, stepInfo, descriptor, arguments, extensions.StepDecorators.Concat(metadataProvider.GetStepDecorators(descriptor))); previousStepTypeName = stepInfo.Name.StepTypeName?.OriginalName; } return(steps); }
public void ShouldReportCorrectCurrentTopLevelStepIfWeHaveStepsMoreThan1Deep() { IObjectContainer container; var mockTracer = new Mock <ITestTracer>(); TestObjectFactories.CreateTestRunner(out container, objectContainer => objectContainer.RegisterInstanceAs(mockTracer.Object)); var contextManager = container.Resolve <IContextManager>(); var firstStepInfo = new StepInfo(StepDefinitionType.Given, "I have called initialise once", null, string.Empty); contextManager.InitializeStepContext(firstStepInfo); Assert.AreEqual(firstStepInfo, contextManager.CurrentTopLevelStep.StepInfo); contextManager.CleanupStepContext(); var secondStepInfo = new StepInfo(StepDefinitionType.When, "I have called initialise twice", null, string.Empty); contextManager.InitializeStepContext(secondStepInfo); Assert.AreEqual(secondStepInfo, contextManager.CurrentTopLevelStep.StepInfo); var thirdStepInfo = new StepInfo(StepDefinitionType.When, "I have called initialise a third time", null, string.Empty); contextManager.InitializeStepContext(thirdStepInfo); //Call sub step Assert.AreEqual(secondStepInfo, contextManager.CurrentTopLevelStep.StepInfo); var fourthStepInfo = new StepInfo(StepDefinitionType.When, "I have called initialise a forth time", null, string.Empty); contextManager.InitializeStepContext(fourthStepInfo); //call sub step of sub step contextManager.CleanupStepContext(); // return from sub step of sub step Assert.AreEqual(secondStepInfo, contextManager.CurrentTopLevelStep.StepInfo); contextManager.CleanupStepContext(); // return from sub step Assert.AreEqual(secondStepInfo, contextManager.CurrentTopLevelStep.StepInfo); contextManager.CleanupStepContext(); // finish 2nd step Assert.AreEqual(secondStepInfo, contextManager.CurrentTopLevelStep.StepInfo); var fifthStepInfo = new StepInfo(StepDefinitionType.When, "I have called initialise a fifth time", null, string.Empty); contextManager.InitializeStepContext(fifthStepInfo); Assert.AreEqual(fifthStepInfo, contextManager.CurrentTopLevelStep.StepInfo); }
private StepInfo findPrevInstanze(StepInfo child) { StepInfo parent = child.Parent; int index = parent.Children.IndexOf(child); if (IsRoot(parent)) { if (index > 0) { return(Last(parent.Children.ElementAt(index - 1))); } else { return(new StepInfo("")); } } else { if (!parent.IsInstanze) { return(findPrevInstanze(parent)); } if (index > 0) { return(parent.Children.ElementAt(index - 1)); } else { return(parent); } } }
/// <summary> /// Reports a failed step, and throws an AssertInconclusiveException if needed. /// </summary> /// <param name="assert">The calling assert.</param> /// <param name="step">The <see cref="StepInfo"/> to report to.</param> /// <param name="actualState">The message to include as the actual result in the step, and in the exception.</param> /// <param name="continueOnError">If true, not exception is thrown. if false, <see cref="AssertFailedException"/> is thrown if the condition fails.</param> /// <exception cref="AssertInconclusiveException">Thrown if condition fails and <paramref name="continueOnError"/> is false.</exception> public static void ReportInconclusive(this Assert assert, StepInfo step, string actualState, bool continueOnError = false) { if (actualState != null) { step.Actual.Add(actualState); } if (((int)StepStatusEnum.Fail) > ((int)step.Outcome)) { step.Outcome = StepStatusEnum.Fail; } if (!continueOnError) { //StringBuilder message = new StringBuilder(); //StringBuilder numberedLines; //message.AppendLine(String.Format("STEP {0} [{1}]: Description = {2}", (String.IsNullOrEmpty(step.Name)) ? "" : step.Name, Timestamp.UnixTimestampToDateTime(step.StartTime).ToString(ConsoleReporter.TimeFormat), step.Description)); //numberedLines = NormalizeListToString(step.Expected); //message.AppendLine($"Expected = {numberedLines.ToString()}"); //numberedLines = NormalizeListToString(step.Actual); //message.AppendLine($"Actual = {numberedLines.ToString()}"); //message.AppendLine(String.Format("Outcome = {0}", Enum.GetName(typeof(StepStatusEnum), step.Outcome))); //numberedLines = NormalizeListToString(step.Messages); //message.AppendLine($"Messages: {numberedLines.ToString()}"); throw new AssertInconclusiveException(ConsoleReporter.CreateStepReport(step)); } }
public IHttpActionResult Get() { if (HttpContext.Current.Session?["UserId"] == null) { return(Unauthorized()); } string userId = HttpContext.Current.Session["UserId"] as string; var random = new Random(); //生成近30天的数据,每天10条 for (int i = 0; i < 30; i++) { for (int j = 0; j < 10; j++) { var steps = random.Next(100, 10000); var stepInfo = new StepInfo { TimeStamp = (long)(DateTime.Now - TimeSpan.FromDays(i) - UnixStartTime).TotalMilliseconds, TodaySteps = steps, Calories = steps * 0.1f, Distance = steps * 0.3f, UserId = userId }; db.StepInfoes.Add(stepInfo); } } db.SaveChanges(); return(StatusCode(HttpStatusCode.NoContent)); }
private RunnableStep ToRunnableStep(StepDescriptor descriptor, int stepIndex, int totalStepsCount, string previousStepTypeName, ExtendableExecutor extendableExecutor, object scenarioContext) { var stepInfo = new StepInfo(_metadataProvider.GetStepName(descriptor, previousStepTypeName), stepIndex + 1, totalStepsCount); var arguments = descriptor.Parameters.Select(p => new MethodArgument(p, _metadataProvider.GetParameterFormatter(p.ParameterInfo))).ToArray(); return(new RunnableStep(stepInfo, descriptor.StepInvocation, arguments, _exceptionToStatusMapper, _progressNotifier, extendableExecutor, scenarioContext)); }
List <StepInfo> GetStepInfos(string stepsText) { var result = new List <StepInfo>(); string s = stepsText; string[] steps = s.Substring(0, s.Length - 1).Split(','); StepInfo info = new StepInfo(); for (int i = 0; i < steps.Length; i++) { if (i % 3 == 0) { int.TryParse(steps[i], out info.Row); } else if (i % 3 == 1) { int.TryParse(steps[i], out info.Col); } else if (i % 3 == 2) { int.TryParse(steps[i], out info.StepCount); result.Add(info); info = new StepInfo(); } } return(result); }
public GameObject ActivateStep(int id) { StepInfo stepInfo = null; for (int i = 0; i < steps.Count; i++) { if (steps[i].id != id) { continue; } stepInfo = steps[i]; break; } if (stepInfo == null) { Debug.Log("与えられたID(" + id + ")を持つ足場がありませんでした。"); return(null); } var obj = stepInfo._pool.GetObject(); activeStepList.Add(obj); return(obj); }
/// <summary> /// Create an instance of step Node for each Gherkin Step defined /// </summary> /// <param name="StepInfo"></param> /// <returns></returns> private ExtentTest GetStepNode(StepInfo StepInfo) { string StepType = StepInfo.StepInstance.StepDefinitionType.ToString(); ExtentTest StepNode = null; switch (StepType) { case "Given": StepNode = extentScenario.CreateNode <Given>(StepInfo.Text); break; case "When": StepNode = extentScenario.CreateNode <When>(StepInfo.Text); break; case "Then": StepNode = extentScenario.CreateNode <Then>(StepInfo.Text); break; case "And": StepNode = extentScenario.CreateNode <And>(StepInfo.Text); break; } return(StepNode); }
private static void Wrapup() { By buttonWrapup = By.XPath("//button[contains(@id, 'btnWrapup') and not(contains(@id, 'info'))]"); if (Driver.wait.IsElementPresent(buttonWrapup)) { StepInfo currentStep = new StepInfo(); currentStep.controlName = "buttonWrapup"; currentStep.action = "Click"; currentStep.flags = "ifPresent"; currentStep.Execute(); currentStep = new StepInfo(); currentStep.controlName = "wrapupSelectDisposition"; currentStep.action = "SelectOptionByText"; currentStep.parameters = "X-Research"; currentStep.Execute(); // Locate and select YesNo Select option Yes currentStep = new StepInfo(); currentStep.controlName = "wrapupSelectYesNo"; currentStep.action = "SelectOptionByText"; currentStep.parameters = "Yes"; currentStep.Execute(); driver.Sleep(2); // Locate and click confirm button currentStep = new StepInfo(); currentStep.controlName = "wrapupConfirmButton"; currentStep.action = "Click"; currentStep.Execute(); } driver.Sleep(2); }
private static List <StepInfo> GetStepsInfoFromTableOnReactionID(DataTable stepsData, DataTable partpntsData, DataTable conditionsData, int reactionID) { List <StepInfo> lstSteps = null; try { if (stepsData != null) { EnumerableRowCollection <DataRow> rows = from row in stepsData.AsEnumerable() where row.Field <Int64>("REACTION_ID") == reactionID select row; lstSteps = new List <StepInfo>(); foreach (DataRow drow in rows) { StepInfo stepInfo = new StepInfo(); stepInfo.ReactionID = reactionID; stepInfo.StepID = Convert.ToInt32(drow["RXN_STEP_ID"]); stepInfo.StepYield = drow["YIELD"].ToString(); stepInfo.SerialNo = Convert.ToInt32(drow["RXN_STEP_SNO"].ToString()); stepInfo.StepParticipants = GetParticipantsFromTableOnStepID(partpntsData, Convert.ToInt32(drow["RXN_STEP_ID"])); stepInfo.StepConditions = GetConditionsFromTableOnStepID(conditionsData, Convert.ToInt32(drow["RXN_STEP_ID"])); lstSteps.Add(stepInfo); } } } catch (Exception ex) { ErrorHandling.WriteErrorLog(ex.ToString()); } return(lstSteps); }
public void MultiStep(int stepCount) { StepInfo stepInfos = new StepInfo(); for (int step = 0; step < stepCount; step++) { StepInfo stepInfo = area.NextStep(); foreach (Cell cell in stepInfo.ChangedCells) { stepInfos.AddCell(cell); } } foreach (Cell cell in stepInfos.ChangedCells) { if (!rectangles.ContainsKey(cell)) { continue; } Rectangle rectangle = rectangles[cell]; if (rectangle != null) { RefreshRectangle(rectangle, cell); } } }
private static void StartStep(StepInfo stepInfo, string containerId) { var stepResult = new StepResult { name = $"{stepInfo.StepDefinitionType} {stepInfo.Text}" }; allure.StartStep(containerId, AllureHelper.NewId(), stepResult); if (stepInfo.Table != null) { var csvFile = $"{Guid.NewGuid().ToString()}.csv"; using (var csv = new CsvWriter(File.CreateText(csvFile))) { foreach (var item in stepInfo.Table.Header) { csv.WriteField(item); } csv.NextRecord(); foreach (var row in stepInfo.Table.Rows) { foreach (var item in row.Values) { csv.WriteField(item); } csv.NextRecord(); } } allure.AddAttachment("table", "text/csv", csvFile); } }
public void AvailableDisplayFieldsTest() { // Arrange var typeEditor = new StepInfo(0, string.Empty, string.Empty, string.Empty, 1, true, string.Empty); var crStepEdit = ReverseCrossRefRequiredStepEdit.NewStep(new StepInfo(0, string.Empty, string.Empty, string.Empty, 1, true, string.Empty), FieldEdit.New()); var fieldVm = Mock.Create<ProcessFieldViewModel>(); var vm = new ReverseCrossRefRequiredStepViewModel(crStepEdit, typeEditor, fieldVm); AddCurrentStateField(vm.AvailableFields); AddField(vm.AvailableFields); AddField(vm.AvailableFields); // Act const int AllFieldsExpectedCount = 3; const int DisplayFieldsExpectedCount = 3; var allFieldsActualCount = vm.AvailableFields.Count; var displayFieldsActualCount = vm.AvailableDisplayFields.Count; var isCurrentStateInAllFields = vm.AvailableFields.Any(f => f.SystemName.Equals(Constants.CurrentStateColumnName)); var isCurrentStateInDisplayFields = vm.AvailableDisplayFields.Any(f => f.SystemName.Equals(Constants.CurrentStateColumnName)); // Assert Assert.AreEqual(AllFieldsExpectedCount, allFieldsActualCount); Assert.AreEqual(DisplayFieldsExpectedCount, displayFieldsActualCount); Assert.IsTrue(isCurrentStateInAllFields); Assert.IsTrue(isCurrentStateInDisplayFields); }
public ExecutionContext.StepDetails StepFrom(StepInfo currentStep) { if (currentStep == null || currentStep.Step == null) return new ExecutionContext.StepDetails(); return new ExecutionContext.StepDetails(currentStep.Step.ActualStepText, currentStep.IsFailed); }
public ReadSourceModel(StepInfo stepInfo) { this.StepInfo = stepInfo; RootNode = ""; SchemaName = ""; IsGenerated = false; }
/// <summary> /// /// </summary> /// <remarks></remarks> /// <seealso cref=""/> /// <param>NA</param> public void GoToNext() { //this.currentStepInfo.SetStatus(StepStatus.success); StepInfo temp = this.currentStepInfo; this.currentStepInfo = this.Next(); }
/// <summary> /// 根据数据加载相关方格 /// </summary> /// <param name="_stepInfo"></param> public void LoadCorrelationGrid(StepInfo _stepInfo) { if (_stepInfo.unit != null) { foreach (var v in tileList.Where(x => x.activitiesAllowUnit.moveSpriteRenderer.enabled == false)) { v.activitiesAllowUnit.SetMoveGrid(true); } _stepInfo.unit.currentPos = _stepInfo.unitCurrentPos; _stepInfo.unit.transform.position = _stepInfo.unitCurrentPos; for (int i = 0; i < _stepInfo.tileCommand.Length; i++) { TileSaveData temp = tileList.FirstOrDefault(x => x.widthHeighValue.Vector3IntRangeValue(_stepInfo.tileCommand[i].pos) == 0); if (temp != null) { temp.aliasName = _stepInfo.tileCommand[i].aliasName; temp.isChange = _stepInfo.tileCommand[i].isChange; temp.path = _stepInfo.tileCommand[i].path; temp.activitiesAllowUnit.SetMoveGrid(_stepInfo.tileCommand[i].moveEnable); } } RefreshCommanderCircleGird(_stepInfo.unit); } }
public void InitializeStepContext(StepInfo stepInfo) { var newContext = new ScenarioStepContext(stepInfo); stepContextManager.Init(newContext); ScenarioStepContext.Current = newContext; }
public void initSteps() { string[] sName = Enum.GetNames(typeof(eSteps)); steps = new StepInfo[sName.Length]; steps[0] = new StepInfo(sName[0], "Get Dice in Summoned\n" + "Sum total of Die's Score value\n" + "Move each Die to Stored"); steps[1] = new StepInfo(sName[1], "Move 5 Die from Supply to Support\n" + "If Supply = 0, move all Die from Stored to Supply\n" + "If Supply = 0 and Store = 0, continue"); steps[2] = new StepInfo(sName[2], "Roll all Die in Support\n" + "Move all die to Servicable"); steps[3] = new StepInfo(sName[3], "Total Energy on Die\n" + "Buy from Market\n" + "Summon creature\n" + "Extra special things"); steps[4] = new StepInfo(sName[4], "Attack all players\n" + "Other Players defend"); steps[5] = new StepInfo(sName[5], "Move all Die from Servicable to Stored\n" + "Move all Die from Spent to Store"); }
public static int ReinstallService(Service service) { var reinstallInfo = new GameHostingReinstallInfo { ServiceId = service.ServiceId, Variables = service.Variables.ToString() }; var taskInfo = new TaskInfo { CreatedBy = 3, RunNow = true, UserId = service.UserId, DisplayName = "Reinstall Service " + service.IpAddress, Source = service.GetType().ToString(), SourceId = service.ServiceId.ToString() }; var stepInfo = new StepInfo(string.Empty, "d3b2aa93-7e2b-4e0d-8080-67d14b2fa8a9", 5, service.ServerId, ObjectXml.ObjectToXml(reinstallInfo)); taskInfo.AddStep(stepInfo); var taskData = new TaskData { Service = service, StepInfo = stepInfo, TaskInfo = taskInfo }; var action = new ActionsTab(taskData, new Server(service.ServerId)); return(action.TaskId); }
private Guid USER_SETTINGS_CHARACTERISTIC = new Guid("00000008-0000-3512-2118-0009af100700"); // Xiaomi User Info Characteristic on Mi Band 3 /// <summary> /// Get steps and activity info. /// </summary> /// <returns>StepInfo object as Activity data.</returns> public async Task <StepInfo> GetStepInfoAsync() { var characteristic = await Gatt.GetCharacteristicByServiceUuid(MI_BAND_SERVICE, STEP_INFO_CHARACTERISTIC); var gattReadResult = await characteristic.ReadValueAsync(BluetoothCacheMode.Uncached); StepInfo stepInfo = new StepInfo(); if (gattReadResult.Status == GattCommunicationStatus.ProtocolError) { Debug.WriteLine("Protocol error. Trying to take values from cache"); gattReadResult = await characteristic.ReadValueAsync(BluetoothCacheMode.Cached); } var data = gattReadResult.Value.ToArray(); int totalSteps = ((data[1] & 255) | ((data[2] & 255) << 8)); int distance = ((((data[5] & 255) | ((data[6] & 255) << 8)) | (data[7] & 16711680)) | ((data[8] & 255) << 24)); int calories = ((((data[9] & 255) | ((data[10] & 255) << 8)) | (data[11] & 16711680)) | ((data[12] & 255) << 24)); stepInfo.Steps = totalSteps; stepInfo.Distance = distance; stepInfo.Calories = calories; return(stepInfo); }
private void AddStepToWizard(StepInfo stepInfo, WizardArgs wArgs) { Type ctrl = stepInfo.Control; Assert.IsNotNull(ctrl, "The {0} step contains null as a control".FormatWith(stepInfo.Title)); var fullName = ctrl.FullName; Assert.IsTrue(ctrl.IsClass, "Control {0} is not class".FormatWith(fullName)); if (!ctrl.GetInterfaces().Contains(typeof(IWizardStep))) { Log.Debug("Control {0} does not implement IWizardStep".FormatWith(fullName)); } var param = stepInfo.Param; var wizardStep = (UserControl)(!string.IsNullOrEmpty(param) ? ReflectionUtil.CreateObject(ctrl, param) : ReflectionUtil.CreateObject(ctrl)); this.ProcessorArgs = wArgs; this.TabControl.Items.Insert(this.TabControl.Items.Count - 2, new TabItem { AllowDrop = false, Content = wizardStep, Visibility = Visibility.Collapsed }); }
private StepInfo findNextInstanze(StepInfo child) { //if (child.IsInstanze) //{ StepInfo parent = child.Parent; int index = parent.Children.IndexOf(child); if (index + 1 < parent.Children.Count) { // return next child return(parent.Children.ElementAt(index + 1)); } else { if (IsRoot(parent)) { return(new StepInfo("")); } else { return(findNextInstanze(parent)); } } //} //else //{ // return findNextInstanze(child.Parent); //} }
/// <summary> /// /// </summary> /// <remarks></remarks> /// <seealso cref=""/> /// <param name="xmlDocument"></param> /// <returns></returns> public static new EasyUploadTaskManager Bind(XmlDocument xmlDocument) { XmlNodeList xmlStepInfos = xmlDocument.GetElementsByTagName("stepInfo"); EasyUploadTaskManager tm = new EasyUploadTaskManager(); tm.StepInfos = new List <StepInfo>(); foreach (XmlNode xmlStepInfo in xmlStepInfos) { StepInfo si = new StepInfo(xmlStepInfo.Attributes.GetNamedItem("title").Value) { GetActionInfo = new ActionInfo { ActionName = xmlStepInfo.Attributes.GetNamedItem("action").Value, ControllerName = xmlStepInfo.Attributes.GetNamedItem("controller").Value, AreaName = xmlStepInfo.Attributes.GetNamedItem("area").Value }, PostActionInfo = new ActionInfo { ActionName = xmlStepInfo.Attributes.GetNamedItem("action").Value, ControllerName = xmlStepInfo.Attributes.GetNamedItem("controller").Value, AreaName = xmlStepInfo.Attributes.GetNamedItem("area").Value } }; tm.StepInfos.Add(si); } tm.currentStepInfo = tm.StepInfos.First(); return(tm); }
private void BRK(StepInfo info) { Push16(PC); PHP(info); SEI(info); PC = Read16(0xFFFE); }
public void LogStep() { StepInfo stepInfo = _context.StepContext.StepInfo; ScenarioExecutionStatus status = _context.ScenarioExecutionStatus; LogStatus logStatus = LogStatus.Pass; switch (status) { case ScenarioExecutionStatus.OK: break; case ScenarioExecutionStatus.Skipped: logStatus = LogStatus.Skip; break; default: // everything else is a fail logStatus = LogStatus.Fail; break; } if (logStatus == LogStatus.Fail) { test.Log(logStatus, stepInfo.Text, $"<pre>{_context.TestError.Message}</pre>"); } else { test.Log(logStatus, stepInfo.Text, ""); } }
// Search the given list for the step with the lowest f score. For ties, the first node found will be chosen. private static StepInfo GetLowestFScore(List <StepInfo> stepList, out int index) { index = 0; if (stepList.Count == 0) { Debug.LogWarning("AStar.GetLowestFScore called with an empty list. Result will be null."); return(null); } else { StepInfo lowest = stepList[0]; for (int i = 1, count = stepList.Count; i < count; i++) { if (stepList[i].f < lowest.f) { lowest = stepList[i]; index = i; } } return(lowest); } }
private void SBC(StepInfo info) { var a = A; var b = Read(info.Address); var c = C; A = (byte)(a - b - (byte)(1 - c)); SetZN(A); if ((int)a - (int)b - (int)(1 - c) >= 0) { C = 1; } else { C = 0; } if (((a ^ b) & 0x80) == 0 && ((a ^ A) & 0x80) != 0) { V = 1; } else { V = 0; } }
private void INC(StepInfo info) { var value = (byte)(Read(info.Address) + 1); Write(info.Address, value); SetZN(value); }
public void PropertiesTest() { var typeEditor = new StepInfo(0, string.Empty, string.Empty, string.Empty, 1, true, string.Empty); var crStepEdit = CrossRefRequiredStepEdit.NewStep(new StepInfo(0, string.Empty, string.Empty, string.Empty, 1, true, string.Empty), FieldEdit.New()); var fieldVm = Mock.Create<Veyron.ProcessBuilder.ViewModels.Tabs.ProcessFieldViewModel>(); var vm = new ProcessFieldCrossRefRequiredStepViewModel(crStepEdit, typeEditor, fieldVm); TestsHelper.TestPublicPropertiesGetSet(vm, x=>x.SelectedProcess, x=>x.SelectedField); }
public void Ctor() { // arrange var textOptionsStepEdit = new TextOptionsStepEdit(); var stepInfo = new StepInfo(1); var processFieldViewModel = new ProcessFieldViewModel(null, null); // act var vm = new ProcessFieldTextOptionsStepViewModel(textOptionsStepEdit, stepInfo, processFieldViewModel); // assert Assert.IsNotNull(vm); }
public void FileFieldsShouldNotBeInAvailableDisplayFields() { // Arrange var typeEditor = new StepInfo(0, string.Empty, string.Empty, string.Empty, 1, true, string.Empty); var crStepEdit = CrossRefRequiredStepEdit.NewStep(new StepInfo(0, string.Empty, string.Empty, string.Empty, 1, true, string.Empty), FieldEdit.New()); var fieldVm = Mock.Create<Veyron.ProcessBuilder.ViewModels.Tabs.ProcessFieldViewModel>(); var vm = new ProcessFieldCrossRefRequiredStepViewModel(crStepEdit, typeEditor, fieldVm); AddField(vm.AvailableFields, ColumnTypes.File); // Assert Assert.IsFalse(vm.AvailableDisplayFields.Any(f => f.Model.ColumnType == ColumnTypes.File)); }
public void ShouldReportCorrectCurrentTopLevelStep() { IObjectContainer container; var mockTracer = new Mock<ITestTracer>(); TestObjectFactories.CreateTestRunner(out container, objectContainer => objectContainer.RegisterInstanceAs(mockTracer.Object)); var contextManager = container.Resolve<IContextManager>(); var firstStepInfo = new StepInfo(StepDefinitionType.Given, "I have called initialise once", null, string.Empty); contextManager.InitializeStepContext(firstStepInfo); Assert.AreEqual(firstStepInfo, contextManager.CurrentTopLevelStep.StepInfo); var secondStepInfo = new StepInfo(StepDefinitionType.When, "I have called initialise twice", null, string.Empty); contextManager.InitializeStepContext(secondStepInfo); Assert.AreEqual(firstStepInfo, contextManager.CurrentTopLevelStep.StepInfo); contextManager.CleanupStepContext(); Assert.AreEqual(firstStepInfo, contextManager.CurrentTopLevelStep.StepInfo); contextManager.CleanupStepContext(); Assert.AreEqual(firstStepInfo, contextManager.CurrentTopLevelStep.StepInfo); }
public void PropertiesTest() { TestsHelper.TestPublicPropertiesGetSet(new StepInfo()); var item = new StepInfo(1, "name", "vc", "bo", 2, true, "vm"); Assert.AreEqual(1, item.Id); Assert.AreEqual("name", item.Name); Assert.AreEqual("vc", item.ViewClass); Assert.AreEqual("bo", item.Class); Assert.AreEqual(2, item.StepNumber); Assert.AreEqual(true, item.DefinesFieldType); Assert.AreEqual("vm", item.ViewModelClass); item = new StepInfo(1); Assert.AreEqual(1, item.Id); new StepInfo(); }
/// <summary> /// Creates the step vm. /// </summary> /// <param name="stepEdit">The step edit.</param> /// <param name="typeEditor">The type editor.</param> /// <param name="processFieldViewModel">The process field view model.</param> /// <returns>IProcessFieldStepViewModel.</returns> public virtual IProcessFieldStepViewModel CreateStepVM(IStepEdit stepEdit, StepInfo typeEditor, ProcessFieldViewModel processFieldViewModel) { //if there is a specific ViewModel defined for the passed step type - create it otherwise use base "ProcessFeieldStepViewModel" class var step = (from lazyStepVM in StepViewModels where lazyStepVM.Metadata.StepType == stepEdit.GetType() select lazyStepVM).Select(result => (IProcessFieldStepViewModel) Activator.CreateInstance(result.Metadata.DeclaringType, stepEdit, typeEditor, processFieldViewModel)) .FirstOrDefault() ?? new ProcessFieldStepViewModel<IStepEdit>(stepEdit, typeEditor, processFieldViewModel); //DeploymentService.Container.ComposeParts(step); DeploymentService.Container.SatisfyImportsOnce(step); foreach (var stepModifier in StepModifiers) if (processFieldViewModel.Model.FieldType.ColumnType == stepModifier.Metadata.ColumnType && stepModifier.Metadata.StepType == stepEdit.GetType()) stepModifier.Value.Modify(stepEdit); return step; }
//get to desiredValue with least amount of coins //now tracks the type of coins/bills as well public List<int> CalculateCoins(int desiredValue) { //const int infinity = 1000000000; int[] coinValues = _coinValues; int numUniqueCoins = coinValues.Length; StepInfo[] steps = new StepInfo[desiredValue + 1]; for (int i = 0; i < steps.Length; i++) { steps[i] = new StepInfo(); } steps[0].MinAmountCoins = 0; for (int stepValue = 1; stepValue <= desiredValue; stepValue++) { // int? minimumAmountCoins = infinity; List<int> stepCoinValues = new List<int>(); for (int cvIndex = 0; cvIndex < numUniqueCoins; cvIndex++) { if (coinValues[cvIndex] <= stepValue) { int? tempMinAmountCoins = steps[stepValue - coinValues[cvIndex]].MinAmountCoins + 1; if (steps[stepValue].MinAmountCoins > tempMinAmountCoins || steps[stepValue].MinAmountCoins == null) { //minimumAmountCoins = tempMinAmountCoins; //stepCoinValues.Clear(); //stepCoinValues.AddRange(steps[stepValue - coinValues[cvIndex]].CoinValues); //stepCoinValues.Add(coinValues[cvIndex]); steps[stepValue].MinAmountCoins = tempMinAmountCoins; steps[stepValue].CoinValues.Clear(); steps[stepValue].CoinValues.AddRange(steps[stepValue - coinValues[cvIndex]].CoinValues); steps[stepValue].CoinValues.Add(coinValues[cvIndex]); } } } // steps[stepValue].MinAmountCoins = minimumAmountCoins; // steps[stepValue].CoinValues = stepCoinValues; } return steps[desiredValue].CoinValues; }
public void AddSortFieldCommand_ExecuteTest() { // Arrange. var stepInfo = new StepInfo(123); var step = DisplayListRequiredStepEdit.NewStep(123); var parentField = Mock.Create<ProcessFieldViewModel>(Constructor.Mocked, Behavior.Loose); var viewModel = new ProcessFieldDisplayListRequiredStepViewModel(step, stepInfo, parentField); // Act. viewModel.AddSortFieldCommand.Execute(null); viewModel.AddSortFieldCommand.Execute(null); viewModel.AddSortFieldCommand.Execute(null); // Assert. Assert.AreEqual(3, step.SortFields.Count); Assert.AreEqual(0, step.SortFields[0].Order); Assert.AreEqual(1, step.SortFields[1].Order); Assert.AreEqual(2, step.SortFields[2].Order); }
private static ReverseCrossRefRequiredStepViewModel CreateRcrRequiredStepVm() { var typeEditor = new StepInfo(0, string.Empty, string.Empty, string.Empty, 1, true, string.Empty); var crStepEdit = ReverseCrossRefRequiredStepEdit.NewStep(new StepInfo(0, string.Empty, string.Empty, string.Empty, 1, true, string.Empty), FieldEdit.New()); var fieldVm = Mock.Create<Veyron.ProcessBuilder.ViewModels.Tabs.ProcessFieldViewModel>(); Mock.Arrange(() => fieldVm.Model).Returns(new FieldEdit()); var vm = new ReverseCrossRefRequiredStepViewModel(crStepEdit, typeEditor, fieldVm) { Model = CreateProcessFieldsViewModel("p1"), ProcessFieldsViewModel = CreateProcessFieldsViewModel("p2"), EventAggregator = Mock.Create<IEventAggregator>(), }; Mock.NonPublic.Arrange<ProcessEdit>(vm, "GetParentProcess").Returns(CreateProcess(string.Empty)); return vm; }
public void MoveDisplayFieldDownCommand_ExecuteTest() { // Arrange. var stepInfo = new StepInfo(123); var displayField1 = DisplayListFieldEdit.NewDisplayListFieldEdit(); displayField1.Order = 1; var displayField2 = DisplayListFieldEdit.NewDisplayListFieldEdit(); displayField2.Order = 2; var displayField3 = DisplayListFieldEdit.NewDisplayListFieldEdit(); displayField3.Order = 3; var step = DisplayListRequiredStepEdit.NewStep(123); step.SelectedFields.Add(displayField1); step.SelectedFields.Add(displayField2); step.SelectedFields.Add(displayField3); var parentField = Mock.Create<ProcessFieldViewModel>(Constructor.Mocked, Behavior.Loose); var viewModel = new ProcessFieldDisplayListRequiredStepViewModel(step, stepInfo, parentField); var selectedFields = viewModel.OrderedSelectedFields.View.Cast<ProcessFieldDisplayListRequiredStepViewModel.SelectedFieldViewModel>().ToArray(); // Act. viewModel.MoveDisplayFieldDownCommand.Execute(selectedFields[0]); // Assert. Assert.IsTrue(step.SelectedFields.OrderBy(f => f.Order).SequenceEqual(new[] { displayField2, displayField1, displayField3 })); Assert.IsTrue( viewModel.OrderedSelectedFields.View.Cast<ProcessFieldDisplayListRequiredStepViewModel.SelectedFieldViewModel>() .SequenceEqual(new[] { selectedFields[1], selectedFields[0], selectedFields[2] })); }
private static ProcessFieldCrossRefRequiredStepViewModel CreateCrossRefRequiredStepVm() { var typeEditor = new StepInfo(0, string.Empty, string.Empty, string.Empty, 1, true, string.Empty); var crStepEdit = CrossRefRequiredStepEdit.NewStep(new StepInfo(0, string.Empty, string.Empty, string.Empty, 1, true, string.Empty), FieldEdit.New()); var fieldVm = Mock.Create<Veyron.ProcessBuilder.ViewModels.Tabs.ProcessFieldViewModel>(); var vm = new ProcessFieldCrossRefRequiredStepViewModel(crStepEdit, typeEditor, fieldVm) { DynamicManager = CreateDynamicTypeManager(), Model = CreateProcessFieldsViewModel("p1"), EventAggregator = Mock.Create<IEventAggregator>() }; return vm; }
public void RemoveDisplayFieldCommand_CanExecuteTest() { // Arrange. var stepInfo = new StepInfo(123); var displayField1 = DisplayListFieldEdit.NewDisplayListFieldEdit(); displayField1.Order = 1; var displayField2 = DisplayListFieldEdit.NewDisplayListFieldEdit(); displayField2.Order = 2; var step = DisplayListRequiredStepEdit.NewStep(123); step.SelectedFields.Add(displayField1); var parentField = Mock.Create<ProcessFieldViewModel>(Constructor.Mocked, Behavior.Loose); var viewModel = new ProcessFieldDisplayListRequiredStepViewModel(step, stepInfo, parentField); var notSelectedField = new ProcessFieldDisplayListRequiredStepViewModel.SelectedFieldViewModel(); notSelectedField.Initialize(displayField2, viewModel); var selectedFields = viewModel.OrderedSelectedFields.View.Cast<ProcessFieldDisplayListRequiredStepViewModel.SelectedFieldViewModel>().ToArray(); // Act / Assert. Assert.IsFalse(viewModel.RemoveDisplayFieldCommand.CanExecute(null)); Assert.IsTrue(viewModel.RemoveDisplayFieldCommand.CanExecute(selectedFields[0])); Assert.IsFalse(viewModel.RemoveDisplayFieldCommand.CanExecute(notSelectedField)); }
public void ShouldReportCorrectCurrentTopLevelStepIfWeHaveStepsMoreThan1Deep() { IObjectContainer container; var mockTracer = new Mock<ITestTracer>(); TestObjectFactories.CreateTestRunner(out container, objectContainer => objectContainer.RegisterInstanceAs(mockTracer.Object)); var contextManager = container.Resolve<IContextManager>(); var firstStepInfo = new StepInfo(StepDefinitionType.Given, "I have called initialise once", null, string.Empty); contextManager.InitializeStepContext(firstStepInfo); Assert.AreEqual(firstStepInfo, contextManager.CurrentTopLevelStep.StepInfo); contextManager.CleanupStepContext(); var secondStepInfo = new StepInfo(StepDefinitionType.When, "I have called initialise twice", null, string.Empty); contextManager.InitializeStepContext(secondStepInfo); Assert.AreEqual(secondStepInfo, contextManager.CurrentTopLevelStep.StepInfo); var thirdStepInfo = new StepInfo(StepDefinitionType.When, "I have called initialise a third time", null, string.Empty); contextManager.InitializeStepContext(thirdStepInfo); //Call sub step Assert.AreEqual(secondStepInfo, contextManager.CurrentTopLevelStep.StepInfo); var fourthStepInfo = new StepInfo(StepDefinitionType.When, "I have called initialise a forth time", null, string.Empty); contextManager.InitializeStepContext(fourthStepInfo); //call sub step of sub step contextManager.CleanupStepContext(); // return from sub step of sub step Assert.AreEqual(secondStepInfo, contextManager.CurrentTopLevelStep.StepInfo); contextManager.CleanupStepContext(); // return from sub step Assert.AreEqual(secondStepInfo, contextManager.CurrentTopLevelStep.StepInfo); contextManager.CleanupStepContext(); // finish 2nd step Assert.AreEqual(secondStepInfo, contextManager.CurrentTopLevelStep.StepInfo); var fifthStepInfo = new StepInfo(StepDefinitionType.When, "I have called initialise a fifth time", null, string.Empty); contextManager.InitializeStepContext(fifthStepInfo); Assert.AreEqual(fifthStepInfo, contextManager.CurrentTopLevelStep.StepInfo); }
public void ShouldReportSetValuesCorrectly() { var table = new Table("header1","header2"); const string multlineText = @" some example multiline text"; var stepInfo = new StepInfo(StepDefinitionType.Given, "Step text", table, multlineText); stepInfo.StepDefinitionType.Should().Be(StepDefinitionType.Given); stepInfo.Text.Should().Be("Step text"); stepInfo.Table.Should().Be(table); stepInfo.MultilineText.Should().Be(multlineText); }
public void RemoveDisplayFieldCommand_ExecuteTest() { // Arrange. var stepInfo = new StepInfo(123); var displayField1 = DisplayListFieldEdit.NewDisplayListFieldEdit(); displayField1.Order = 1; var displayField2 = DisplayListFieldEdit.NewDisplayListFieldEdit(); displayField2.Order = 2; var step = DisplayListRequiredStepEdit.NewStep(123); step.SelectedFields.Add(displayField1); step.SelectedFields.Add(displayField2); var parentField = Mock.Create<ProcessFieldViewModel>(Constructor.Mocked, Behavior.Loose); var viewModel = new ProcessFieldDisplayListRequiredStepViewModel(step, stepInfo, parentField); var selectedFields = viewModel.OrderedSelectedFields.View.Cast<ProcessFieldDisplayListRequiredStepViewModel.SelectedFieldViewModel>().ToArray(); // Act. viewModel.RemoveDisplayFieldCommand.Execute(selectedFields[0]); // Assert. Assert.AreEqual(1, step.SelectedFields.Count); Assert.IsFalse(step.SelectedFields.Contains(displayField1)); Assert.AreEqual(1, viewModel.SelectedDisplayFields.Count); Assert.IsFalse(viewModel.SelectedDisplayFields.Contains(selectedFields[0])); }
public void CanSelectFieldShouldIncludeImage() { // Arrange var typeEditor = new StepInfo(0, string.Empty, string.Empty, string.Empty, 1, true, string.Empty); var crStepEdit = CrossRefRequiredStepEdit.NewStep(new StepInfo(0, string.Empty, string.Empty, string.Empty, 1, true, string.Empty), FieldEdit.New()); var fieldVm = Mock.Create<Veyron.ProcessBuilder.ViewModels.Tabs.ProcessFieldViewModel>(); var vm = new ProcessFieldCrossRefRequiredStepViewModel(crStepEdit, typeEditor, fieldVm); var field = Mock.Create<FieldInfo>(); Mock.Arrange(() => field.ColumnType).Returns(ColumnTypes.Image); // Assert Assert.IsTrue(vm.CanSelectField(field)); }
public SpecInfo Run(SpecInfo spec, MessageFormatter formatter) { var givenSteps = new StepInfo[_given.Count]; for (int i = 0; i < _given.Count; i++) { var given = _given[i]; int i1 = i; given.DescribeTo(s => { var stepInfo = new StepInfo(s); givenSteps[i1] = stepInfo; return spec.ReportGivenStep(stepInfo); }, formatter); } var prepareStep = new StepInfo("Setup completed"); spec.ReportGivenStep(prepareStep); _when.DescribeTo(spec.ReportWhenStep, formatter); var token = new CancellationTokenSource(); var events = new List<object>(); try { //wireup Action<object> sink = events.Add; var router = _wireup(sink); if (_given.Count == 0) { var step = new StepInfo("No history"); spec.ReportGivenStep(step); step.Pass(); } else for (int i = 0; i < _given.Count; i++) { var g = _given[i]; g.RunTo(router); givenSteps[i].Pass(); } events.Clear(); prepareStep.Pass(); //run when _when.RunTo(router); spec.When.Pass(); } catch { _expectations.DescribeTo(spec, formatter); throw; } finally { token.Cancel(); } //then _expectations.Verify(events.ToArray(), spec, formatter); return spec; }
public void RemoveSortFieldCommand_ExecuteTest() { // Arrange. var stepInfo = new StepInfo(123); var sortField1 = DisplayListSortFieldEdit.NewField(); var sortField2 = DisplayListSortFieldEdit.NewField(); var step = DisplayListRequiredStepEdit.NewStep(123); step.SortFields.Add(sortField1); step.SortFields.Add(sortField2); var parentField = Mock.Create<ProcessFieldViewModel>(Constructor.Mocked, Behavior.Loose); var viewModel = new ProcessFieldDisplayListRequiredStepViewModel(step, stepInfo, parentField); // Act. viewModel.RemoveSortFieldCommand.Execute(sortField1); // Assert. Assert.AreEqual(1, step.SortFields.Count); Assert.IsFalse(step.SortFields.Contains(sortField1)); }