protected override void ExecutePlugin() { if (this.TargetEntity.LogicalName != "account") { this.Logger.Error("Sample2Bad: should run on an account!"); } var query = new QueryExpression("contact") { Criteria = { Conditions = { new ConditionExpression("accountid", ConditionOperator.Equal, this.TargetEntity.Id) } } }; var contacts = this.OrganizationService.RetrieveMultiple(query); foreach (var contact in contacts.Entities) { var sampleLogic = new SampleLogic(this.OrganizationService); sampleLogic.SetAccountNameToContact(contact.Id, this.TargetEntity.Id); } }
public void GetValueTest() { var logic = new SampleLogic(); var result = logic.GetValue(); Assert.AreEqual("Value", result); }
public async Task SampleLogic_GetSamplesForSession_Should_Only_Get_Samples_For_Given_Session() { // Arrange var sessionRepository = new Mock <IRepository <Session> >(); var sampleRepository = new Mock <IRepository <Sample> >(); var session1 = new Session { Id = Guid.NewGuid() }; var session2 = new Session { Id = Guid.NewGuid() }; var samples = new[] { session1, session2, session1 }.Select(session => new Fixture().Build <Sample>().With(x => x.Session, session).Create()).ToList(); sampleRepository.Setup(r => r.Find(Any.Predicate <Sample>())).ExecutesAsyncPredicateOn(samples); var getSamplesForSessionResponseMapper = new GetSamplesForSessionResponseMapper(); var logic = new SampleLogic(sessionRepository.Object, sampleRepository.Object, getSamplesForSessionResponseMapper, null, null); // Act var result = await logic.GetSamplesForSession(session2.Id); // Assert result.SessionId.Should().Be(session2.Id); result.Samples.Should().HaveCount(1); }
protected override void ExecutePlugin() { var logic = new SampleLogic(this.OrganizationService); try { logic.SetNameToHelloWorldIfNullOrWhitespace(this.TargetEntity.Id, this.TargetEntity.LogicalName); } catch (Exception ex) { this.Logger.Error(ex); } }
public async Task SampleLogic_CreateSampleForSession_Should_Return_Null_For_Unknown_SessionId() { // Arrange var sessionRepository = new Mock <IRepository <Session> >(); var sessions = new Fixture().Build <Session>().With(x => x.Samples, new List <Sample>()).CreateMany(3).ToList(); sessionRepository.Setup(x => x.Single(Any.Predicate <Session>())).ExecutesAsyncPredicateOn(sessions); var sampleRepository = new Mock <IRepository <Sample> >(); var logic = new SampleLogic(sessionRepository.Object, sampleRepository.Object, null, null, null); // Act var result = await logic.CreateSampleForSession(Guid.NewGuid(), null); // Assert result.Should().BeNull(); }
public static object Min([ExcelArgument(Description = "The hash of a valid Sample object", Name = "Sample")] string hash) { return(Run(() => SampleLogic.Min(hash))); }
public static object SpreadVARAsync([ExcelArgument(Description = "The hash of a valid Sample object", Name = "Sample")] string hash) { return(RunAsync(() => SampleLogic.SpreadVAR(hash), "Lloyds.Async.Sample.SpreadVAR")); }
public static object PercentileAsync([ExcelArgument(Description = "The hash of a valid Sample object", Name = "Sample")] string hash, [ExcelArgument(Description = "The percentile rank. Between 0 and 1, inclussive.", Name = "Convidence Level")] object percentileRank) { return(RunAsync(() => SampleLogic.Percentile(hash, percentileRank), "Lloyds.Async.Sample.Percentile")); }
public static object VolatilityAsync([ExcelArgument(Description = "The hash of a valid Sample object", Name = "Sample")] string hash) { return(RunAsync(() => SampleLogic.Volatility(hash), "Lloyds.Async.Sample.Volatility")); }
public static object MedianAsync([ExcelArgument(Description = "The hash of a valid Sample object", Name = "Sample")] string hash) { return(RunAsync(() => SampleLogic.Median(hash), "Lloyds.Sample.Median")); }