private void MoveToResultsAsOutcomeType(OutcomeType outcomeType) { var answers = new Dictionary <IQuestion, IAnswer[]> { { new Question { Id = "1" }, new IAnswer[] { new Answer(), new Answer() } } }; var currentQuestion = new Question { Id = "2" }; _fakeQuestionManager.Setup(x => x.GetNextQuestion(currentQuestion.Id)).Returns((Question)null); _fakeHttpWrapper.Setup(x => x.Form).Returns(new NameValueCollection()); _fakeAnswerManager.Setup(x => x.GetNameValueCollection()).Returns(new NameValueCollection { { "freckle", "100" } }); _fakeAnswerManager.Setup(x => x.GetAnswers()).Returns(answers); _fakePersonaManager.Setup(x => x.GetOutcomeType(It.IsAny <IDictionary <string, IAnswer[]> >())).Returns(outcomeType); // Act var result = _controller.Index(currentQuestion, Constants.SubmitType.Results) as RedirectToRouteResult; // Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult)); Assert.AreEqual("Results", result.RouteValues["controller"]); Assert.AreEqual(outcomeType.ToString(), result.RouteValues["action"]); Assert.AreEqual("100", result.RouteValues["freckle"]); _fakeQuestionManager.Verify(x => x.GetNextQuestion(currentQuestion.Id), Times.Never); _fakeAnswerManager.Verify(x => x.StoreAnswerId(It.IsAny <string>(), It.IsAny <string>()), Times.Once); }
private ActionResult ShowResult(OutcomeType expectedOutcomeType) { var referrer = _httpWrapper.UrlReferrer; if (referrer == null || !referrer.IsRouteMatch(_httpWrapper.HttpContext, MVC.Questions.Name, MVC.Questions.ActionNames.Index)) { _answerManager.StoreAnswers(_httpWrapper.QueryString); } var answers = _answerManager.GetAnswers(); var questions = _questionManager.GetAllQuestions(); if (answers.Count < questions.Count) { return(RedirectToAction(MVC.Home.Index())); } var dictionary = answers.ToDictionary(x => x.Key.Id, x => x.Value); var persona = _personaManager.GetPersona(dictionary); var outcomeType = persona?.OutcomeType ?? OutcomeType.Unsure; if (outcomeType != expectedOutcomeType) { return(RedirectToOutcomeType(outcomeType)); } var visitor = new Visitor(outcomeType, persona?.Id, dictionary); var obligations = _obligationManager.GetObligationsForVisitor(visitor); return(View(MVC.Results.Views.ViewNames.Index, new ResultModel { Obligations = obligations, Answers = answers, OutcomeType = outcomeType })); }
internal PolicyResult(OutcomeType outcome, Exception finalException, ExceptionType?exceptionType, Context context) { Outcome = outcome; FinalException = finalException; ExceptionType = exceptionType; Context = context; }
public static OutcomeType DBCopy(this OutcomeType ot, VilkaEntities context) { if (ot == null) { return(null); } return(context.OutcomeTypes.Where((o) => o.ID == ot.ID).FirstOrDefault()); }
private ActionResult RedirectToOutcomeType(OutcomeType outcomeType) { switch (outcomeType) { case OutcomeType.Business: return(RedirectToAction(MVC.Results.Business().AddRouteValues(_httpWrapper.QueryString))); case OutcomeType.Hobby: return(RedirectToAction(MVC.Results.Hobby().AddRouteValues(_httpWrapper.QueryString))); default: return(RedirectToAction(MVC.Results.Unsure().AddRouteValues(_httpWrapper.QueryString))); } }
protected virtual string ConvertOutcome(OutcomeType type) { var outcome = string.Empty; switch (type) { case OutcomeType.Failure: outcome = "(Result = 0)"; break; case OutcomeType.Success: outcome = "(Result = 1)"; break; } return(outcome); }
private XDASv2Net.Model.Action CreateAction(SubEventType subEventType, OutcomeType outcomeType) { XDASv2Net.Model.Action action = new XDASv2Net.Model.Action() { Event = new Event(), SubEvent = new SubEvent() { Name = subEventType.ToString() }, Time = new Time() { Offset = (int)new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds() }, Outcome = outcomeType.ToString() }; BaseEventType baseEventType = subEventType.GetAttribute <EventTypeAttribute>().BaseEventType; switch (baseEventType) { case BaseEventType.Create: action.Event.Id = XDASv2Net.Model.EventType.CREATE_DATA_ITEM.GetAttribute <EventInformationAttribute>().EventIdentifier; action.Event.Name = XDASv2Net.Model.EventType.CREATE_DATA_ITEM.ToString(); break; case BaseEventType.Update: action.Event.Id = XDASv2Net.Model.EventType.MODIFY_DATA_ITEM_ATTRIBUTE.GetAttribute <EventInformationAttribute>().EventIdentifier; action.Event.Name = XDASv2Net.Model.EventType.MODIFY_DATA_ITEM_ATTRIBUTE.ToString(); break; case BaseEventType.Delete: action.Event.Id = XDASv2Net.Model.EventType.DELETE_DATA_ITEM.GetAttribute <EventInformationAttribute>().EventIdentifier; action.Event.Name = XDASv2Net.Model.EventType.DELETE_DATA_ITEM.ToString(); break; case BaseEventType.Read: default: action.Event.Id = XDASv2Net.Model.EventType.QUERY_DATA_ITEM_ATTRIBUTE.GetAttribute <EventInformationAttribute>().EventIdentifier; action.Event.Name = XDASv2Net.Model.EventType.QUERY_DATA_ITEM_ATTRIBUTE.ToString(); break; } return(action); }
public override void RunPostChaseBehavior() { skillActor.StartSkillGain(EWPetFightingSkill.kSkillGainRateNormal); OutcomeType outcomeType = OutcomeType.Succeed; outcomeType = (OutcomeType)RandomUtil.GetWeightedIndex(GetOutcomeWeights()); PlayFaceoffAnims(false); switch (outcomeType) { case OutcomeType.Succeed: if (Target.LotCurrent != Target.LotHome) { if (Target.IsHuman) { Target.RequestWalkStyle(WalkStyle.MeanChasedRun); } else { Target.RequestWalkStyle(WalkStyle.PetRun); } // Success! Actor drove the unwanted sim off the lot. skillActor.AddPoints(200f, true, true); // Successful driving off a foe gains skill MakeSimGoHome(Target, false); } break; case OutcomeType.Fight: if (!Actor.HasExitReason(ExitReason.Default) && !Target.HasExitReason(ExitReason.Default)) { if (Target.IsHuman) { EWPetAttackSim continuation = EWPetAttackSim.Singleton.CreateInstance(Target, Actor, new InteractionPriority(InteractionPriorityLevel.High), Autonomous, cancellableByPlayer: true) as EWPetAttackSim; continuation.SetParams(true, false); Actor.InteractionQueue.TryPushAsContinuation(this, continuation); } else { EWFightPet continuation = EWFightPet.Singleton.CreateInstance(Target, Actor, new InteractionPriority(InteractionPriorityLevel.High), Autonomous, cancellableByPlayer: true) as EWFightPet; continuation.SetParams(true, false); Actor.InteractionQueue.TryPushAsContinuation(this, continuation); } } break; case OutcomeType.Reversal: // In this situation, a pet target will mean chase the actor and a human target will scold PlayFaceoffAnims(true); if (!Actor.HasExitReason(ExitReason.Default) && !Target.HasExitReason(ExitReason.Default)) { if (Target.IsHuman) { // Scold naughty actor PlayScoldAnims(); } else { EWChaseMean chaseMean = InteractionUtil.CreateInstance(this, Singleton, Actor, Target) as EWChaseMean; if (chaseMean != null) { chaseMean.PreviouslyAccepted = true; chaseMean.NumLoops = Math.Max(0, NumLoops - 1); Target.InteractionQueue.TryPushAsContinuation(this, chaseMean); } } } break; case OutcomeType.ChaseAgain: if (!Actor.HasExitReason(ExitReason.Default) && !Target.HasExitReason(ExitReason.Default) && base.NumLoops > 0) { EWChaseOffLot chaseMean = InteractionUtil.CreateInstance(this, Singleton, Target, Actor) as EWChaseOffLot; if (chaseMean != null) { chaseMean.PreviouslyAccepted = true; chaseMean.NumLoops = Math.Max(0, NumLoops - 1); Actor.InteractionQueue.TryPushAsContinuation(this, chaseMean); } } break; } EventTracker.SendEvent(new SocialEvent(EventTypeId.kSocialInteraction, Actor, Target, "Chase Mean", wasRecipient: false, wasAccepted: true, actorWonFight: false, CommodityTypes.Undefined)); EventTracker.SendEvent(new SocialEvent(EventTypeId.kSocialInteraction, Target, Actor, "Chase Mean", wasRecipient: true, wasAccepted: true, actorWonFight: false, CommodityTypes.Undefined)); skillActor.StopSkillGain(); }
internal PolicyResult(OutcomeType outcome, Exception finalException, ExceptionType? exceptionType) { _outcome = outcome; _finalException = finalException; _exceptionType = exceptionType; }
public JobLogUpdateModelBuilder WithOutcomeType(OutcomeType outcomeType) { _outcomeType = outcomeType; return(this); }
internal PolicyResult(OutcomeType outcome, Exception finalException, ExceptionType?exceptionType) { _outcome = outcome; _finalException = finalException; _exceptionType = exceptionType; }
public ChoiceOutcome() { Type = OutcomeType.Unknown; }
public Visitor(OutcomeType outcomeType, string personaId, IDictionary <string, IAnswer[]> answers) { _outcomeType = outcomeType; Items = answers; PersonaId = personaId; }
public async Task ProcessJobCompletion_JobHasParentTwoChildrenOnlyBothCompleted_ThenParentCompleted(CompletionStatus childOneCompletionStatus, OutcomeType expectedOutcomeType) { // Arrange string parentJobId = "parent123"; string jobId = "child123"; Outcome outcomeOne = NewOutcome(); Outcome outcomeTwo = NewOutcome(); Outcome outcomeThree = NewOutcome(); Outcome outcomeFour = NewOutcome(); Job job = new Job { Id = jobId, JobDefinitionId = NewRandomString(), ParentJobId = parentJobId, CompletionStatus = childOneCompletionStatus, RunningStatus = RunningStatus.Completed, OutcomeType = OutcomeType.Succeeded, Outcome = NewRandomString(), Outcomes = new List <Outcome> { outcomeOne, outcomeTwo, outcomeThree } }; Job job2 = new Job { Id = "child456", JobDefinitionId = NewRandomString(), ParentJobId = parentJobId, CompletionStatus = CompletionStatus.Succeeded, RunningStatus = RunningStatus.Completed, OutcomeType = OutcomeType.Succeeded, Outcome = NewRandomString(), Outcomes = new List <Outcome> { outcomeFour } }; Job parentJob = new Job { Id = parentJobId, RunningStatus = RunningStatus.InProgress }; ILogger logger = CreateLogger(); IJobRepository jobRepository = CreateJobRepository(); jobRepository .GetJobById(Arg.Is(jobId)) .Returns(job); jobRepository .GetJobById(Arg.Is(parentJobId)) .Returns(parentJob); jobRepository .GetChildJobsForParent(Arg.Is(parentJobId)) .Returns(new List <Job> { job, job2 }); JobManagementService jobManagementService = CreateJobManagementService(jobRepository, logger: logger); JobSummary JobSummary = new JobSummary { JobId = jobId, RunningStatus = RunningStatus.Completed }; string json = JsonConvert.SerializeObject(JobSummary); Message message = new Message(Encoding.UTF8.GetBytes(json)); message.UserProperties["jobId"] = jobId; // Act await jobManagementService.Process(message); // Assert await jobRepository .Received(1) .UpdateJob(Arg.Is <Job>(_ => _.Id == parentJobId && _.RunningStatus == RunningStatus.Completed && _.OutcomeType == expectedOutcomeType && _.Completed.HasValue && _.Outcome == "All child jobs completed")); logger .Received(1) .Information(Arg.Is("Parent Job {ParentJobId} of Completed Job {JobId} has been completed because all child jobs are now complete"), Arg.Is(job.ParentJobId), Arg.Is(jobId)); Outcome expectedChildJobOneOutcome = NewOutcome(_ => _.WithJobDefinitionId(job.JobDefinitionId) .WithType(OutcomeType.Succeeded) .WithDescription(job.Outcome) .WithIsSuccessful(childOneCompletionStatus == CompletionStatus.Succeeded)); Outcome expectedChildJobTwoOutcome = NewOutcome(_ => _.WithJobDefinitionId(job2.JobDefinitionId) .WithType(OutcomeType.Succeeded) .WithDescription(job2.Outcome) .WithIsSuccessful(true)); //rolls up all outcomes to the parent job parentJob.Outcomes .Should() .BeEquivalentTo(new object[] { outcomeOne, outcomeTwo, outcomeThree, outcomeFour, expectedChildJobOneOutcome, expectedChildJobTwoOutcome }); }
public Outcome(OutcomeType theType, int theRef) { type = theType; reference = theRef; }
private Outcome(OutcomeType type, decimal winnings) { Type = type; _winnings = winnings; }
public OutcomeBuilder WithType(OutcomeType type) { _type = type; return(this); }
/// <inheritdoc/> public async Task AddDefaultEventAsync(ICustomPrincipal principal, object data, SubEventType subEventType, OutcomeType outcomeType = OutcomeType.Success) { try { Ensure.ArgumentNotNull(principal, nameof(principal)); if (!principal.IsInRole(RoleType.Service)) { XDASv2Event xdasEvent = CreateXDASEvent(principal, subEventType, outcomeType); Target target = new Target() { Entity = CreateTargetEntity() }; target.Data = data; xdasEvent.Target = target; var command = new CreateAuditEventCommand() { Event = xdasEvent }; await mediator.Send(command); } } catch (Exception e) { logger.LogError(e, e.Message); } }
private XDASv2Event CreateXDASEvent(ICustomPrincipal principal, SubEventType subEventType, OutcomeType outcomeType) { return(new XDASv2Event() { Initiator = CreateInitiator(principal), Observer = CreateObserver(), Action = CreateAction(subEventType, outcomeType) }); }