How to use UtcToLocal class of NBi.Core.Transformation.Transformer.Native package

Best NBi code snippet using NBi.Core.Transformation.Transformer.Native.UtcToLocal

TextTest.cs

Source:TextTest.cs Github

copy

Full Screen

...389 [TestCase("2019-11-01T19:58Z", "yyyy-MM-ddTHH:mmZ", "Brussels", "2019-11-01 20:58:00")]390 [TestCase("2019-10-01T19:58Z", "yyyy-MM-ddTHH:mmZ", "Brussels", "2019-10-01 21:58:00")]391 [TestCase("2019-10-01T19:58Z", "yyyy-MM-ddTHH:mmZ", "Moscow", "2019-10-01 22:58:00")]392 [TestCase("2019-10-01T19:58Z", "yyyy-MM-ddTHH:mmZ", "Pacific Standard Time", "2019-10-01 12:58:00")]393 public void Execute_TextToDateTimeAndUtcToLocal_Valid(string value, string format, string timeZone, DateTime expected)394 {395 var textToDateTime = new TextToDateTime(new LiteralScalarResolver<string>(format));396 var utcToLocal = new UtcToLocal(new LiteralScalarResolver<string>(timeZone));397 var result = utcToLocal.Evaluate(textToDateTime.Evaluate(value));398 Assert.That(result, Is.EqualTo(expected));399 Assert.That(((DateTime)result).Kind, Is.EqualTo(DateTimeKind.Unspecified));400 }401 [Test]402 [TestCase("20190317111223", "yyyyMMddhhmmss", "fr-fr", "2019-03-17 11:12:23")]403 [TestCase("mercredi 25-sept.-19", "dddd dd-MMM-yy", "fr-fr", "2019-09-25")]404 public void Execute_TextToDateTimeWithCulture_Valid(string value, string format, string culture, DateTime expected)405 {406 var function = new TextToDateTime(new LiteralScalarResolver<string>(format), new LiteralScalarResolver<string>(culture));407 var result = function.Evaluate(value);408 Assert.That(result, Is.EqualTo(expected));409 }410 [Test]...

Full Screen

Full Screen

NativeTransformationFactoryTest.cs

Source:NativeTransformationFactoryTest.cs Github

copy

Full Screen

...47 {48 var factory = new NativeTransformationFactory(new ServiceLocator(), null);;49 var result = factory.Instantiate("utc-to-local(Brussels)");50 Assert.That(result, Is.AssignableTo<INativeTransformation>());51 Assert.That(result, Is.TypeOf<UtcToLocal>());52 Assert.That((result as UtcToLocal).TimeZoneLabel, Is.AssignableTo<IScalarResolver>());53 Assert.That((result as UtcToLocal).TimeZoneLabel, Is.AssignableTo<IScalarResolver<string>>());54 Assert.That((result as UtcToLocal).TimeZoneLabel, Is.TypeOf<LiteralScalarResolver<string>>());55 Assert.That((result as UtcToLocal).TimeZoneLabel.Execute(), Is.EqualTo("Brussels"));56 }57 [Test]58 public void Instantiate_ExistingWithParameterIncludingSpaces_CorrectType()59 {60 var factory = new NativeTransformationFactory(new ServiceLocator(), null);;61 var result = factory.Instantiate("utc-to-local( Romance Standard Time )");62 Assert.That(result, Is.AssignableTo<INativeTransformation>());63 Assert.That(result, Is.TypeOf<UtcToLocal>());64 Assert.That((result as UtcToLocal).TimeZoneLabel.Execute(), Is.EqualTo("Romance Standard Time"));65 }66 [Test]67 public void Instantiate_ExistingWithParameterAndWhitespaces_CorrectType()68 {69 var factory = new NativeTransformationFactory(new ServiceLocator(), null);;70 var result = factory.Instantiate("\r\n\t\t\tutc-to-local(Brussels) \t\r\n");71 Assert.That(result, Is.AssignableTo<INativeTransformation>());72 Assert.That(result, Is.TypeOf<UtcToLocal>());73 Assert.That((result as UtcToLocal).TimeZoneLabel.Execute(), Is.EqualTo("Brussels"));74 }75 [Test]76 public void Instantiate_ExistingWithParameters_CorrectType()77 {78 var factory = new NativeTransformationFactory(new ServiceLocator(), null);;79 var result = factory.Instantiate("numeric-to-clip(10, 2000)");80 Assert.That(result, Is.AssignableTo<INativeTransformation>());81 Assert.That(result, Is.TypeOf<NumericToClip>());82 Assert.That((result as NumericToClip).Min.Execute(), Is.EqualTo(10));83 Assert.That((result as NumericToClip).Max.Execute(), Is.EqualTo(2000));84 }85 [Test]86 public void Instantiate_ExistingWithParametersAndWhitespaces_CorrectType()87 {...

Full Screen

Full Screen

TimeZoneTransformations.cs

Source:TimeZoneTransformations.cs Github

copy

Full Screen

...5using System.Text;6using System.Threading.Tasks;7namespace NBi.Core.Transformation.Transformer.Native8{9 class UtcToLocal : AbstractDateTimeTransformation10 {11 public IScalarResolver<string> TimeZoneLabel { get; }12 public UtcToLocal(IScalarResolver<string> timeZoneLabel)13 {14 TimeZoneLabel = timeZoneLabel;15 }16 protected override object EvaluateDateTime(DateTime value) =>17 TimeZoneInfo.ConvertTimeFromUtc(value, InstantiateTimeZoneInfo(TimeZoneLabel.Execute()));18 protected TimeZoneInfo InstantiateTimeZoneInfo(string label)19 {20 var zones = TimeZoneInfo.GetSystemTimeZones();21 var zone = zones.SingleOrDefault(z => z.Id == label)22 ?? zones.SingleOrDefault(z => Tokenize(z.DisplayName).Contains(label.Replace(" ", "")));23 return zone ?? throw new ArgumentOutOfRangeException($"TimeZone '{label}' is not existing on this computer.");24 }25 private string[] Tokenize(string label) =>26 label.Replace("(", ",")27 .Replace(")", ",")28 .Replace(":", ",")29 .Replace(" ", "")30 .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);31 }32 class LocalToUtc : UtcToLocal33 {34 public LocalToUtc(IScalarResolver<string> timeZoneLabel)35 : base(timeZoneLabel)36 { }37 protected override object EvaluateDateTime(DateTime value) =>38 TimeZoneInfo.ConvertTimeToUtc(value, InstantiateTimeZoneInfo(TimeZoneLabel.Execute()));39 }40}...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run NBi automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful