public static void Main() { // Create an instance of the IFormatProvider. IFormatProvider provider = new DummyProvider(); // Values to convert using DummyProvider. int int32A = -252645135; double doubleA = 61680.3855; object objDouble = (object)-98765.4321; DateTime dayTimeA = new DateTime(2009, 9, 11, 13, 45, 0); bool boolA = true; string stringA = "Qwerty"; char charA = '$'; TimeSpan tSpanA = new TimeSpan(0, 18, 0); object objOther = provider; object[] objects = { int32A, doubleA, objDouble, dayTimeA, boolA, stringA, charA, tSpanA, objOther }; // Call Convert.ToString(Object, provider) method for each value. foreach (object value in objects) { Console.WriteLine("{0,-20} --> {1,20}", value, Convert.ToString(value, provider)); } }
public void Notify(bool expectReply) { var provider = new DummyProvider(); using (var scope = Factory.Current.BeginLifetimeScope(builder => { builder.Register(ctx => provider).As <ISmsProvider>(); })) using (Factory.SetCurrentScope(scope)) { var notifier = new TwilioNotifier() { Name = "TwilioTest", TpAccountSid = TwilioTestHelper.TestAccountSid, TpAuthToken = TwilioTestHelper.TestAuthToken, TpSendingNumber = TwilioTestHelper.TestFromNumber_Valid }; var person = new Person(); var mobilePhoneField = Factory.ScriptNameResolver.GetInstance("Mobile phone", StringField.StringField_Type.Id); person.SetField(mobilePhoneField, TwilioTestHelper.TestToNumber_Valid); var notification = new Notification { NMessage = "TestMessage" }; TwilioRouter.Instance.Send(notifier, notification, person.ToEnumerable(), expectReply); var result = Entity.Get <Notification>(notification.Id).SendRecords; Assert.That(result, Is.Not.Null); Assert.That(result.Count, Is.EqualTo(1)); Assert.That(result.First().SrErrorMessage, Is.Null); } }
public void GetConfiguration_NoMatchingProvider_Throws() { // Arrange var otherProvider = new DummyProvider(Language.VBNET); var qp = new SonarQubeQualityProfile("key", "name", "language", false, DateTime.UtcNow); var testSubject = new CompositeBindingConfigProvider(otherProvider); // 1. Multiple matching providers -> config from the first matching provider returned Action act = () => testSubject.GetConfigurationAsync(qp, "org", Language.Cpp, CancellationToken.None).Wait(); act.Should().ThrowExactly <AggregateException>().And.InnerException.Should().BeOfType <ArgumentOutOfRangeException>(); }
static void Main( ) { // Create an instance of the IFormatProvider. DummyProvider provider = new DummyProvider( ); string converted; // Convert these values using DummyProvider. int Int32A = -252645135; double DoubleA = 61680.3855; object ObjDouble = (object)(-98765.4321); DateTime DayTimeA = new DateTime(2001, 9, 11, 13, 45, 0); bool BoolA = true; string StringA = "Qwerty"; char CharA = '$'; TimeSpan TSpanA = new TimeSpan(0, 18, 0); object ObjOther = (object)provider; Console.WriteLine("This example of " + "Convert.ToString( non-numeric, IFormatProvider ) \n" + "generates the following output. The provider type, " + "argument type, \nand argument value are displayed."); Console.WriteLine("\nNote: The IFormatProvider object is " + "not called for Boolean, String, \nChar, TimeSpan, " + "and non-numeric Object."); // The format provider is called for these conversions. Console.WriteLine( ); converted = Convert.ToString(Int32A, provider); Console.WriteLine("int {0}", converted); converted = Convert.ToString(DoubleA, provider); Console.WriteLine("double {0}", converted); converted = Convert.ToString(ObjDouble, provider); Console.WriteLine("object {0}", converted); converted = Convert.ToString(DayTimeA, provider); Console.WriteLine("DateTime {0}", converted); // The format provider is not called for these conversions. Console.WriteLine( ); converted = Convert.ToString(BoolA, provider); Console.WriteLine("bool {0}", converted); converted = Convert.ToString(StringA, provider); Console.WriteLine("string {0}", converted); converted = Convert.ToString(CharA, provider); Console.WriteLine("char {0}", converted); converted = Convert.ToString(TSpanA, provider); Console.WriteLine("TimeSpan {0}", converted); converted = Convert.ToString(ObjOther, provider); Console.WriteLine("object {0}", converted); }
public void Getting_ExchangeRate_Twice_Only_Queries_The_Internal_Provider_Once() { var inner = new DummyProvider(); var cached = new CachedExchangeRateProvider(inner); inner.Counter.Should().Be(0); cached.TryGet(EUR, USD); inner.Counter.Should().Be(1); cached.TryGet(EUR, USD); inner.Counter.Should().Be(1); cached.TryGet(EUR, CAD); inner.Counter.Should().Be(2); }
public async Task GetConfiguration_WithMatchingProvider_ExpectedConfigReturned() { // Arrange var otherProvider = new DummyProvider(Language.VBNET); var cppProvider1 = new DummyProvider(Language.Cpp); var cppProvider2 = new DummyProvider(Language.Cpp); var qp = new SonarQubeQualityProfile("key", "name", "language", false, DateTime.UtcNow); var testSubject = new CompositeBindingConfigProvider(otherProvider, cppProvider1, cppProvider2); // Act. Multiple matching providers -> config from the first matching provider returned var actualConfig = await testSubject.GetConfigurationAsync(qp, "org", Language.Cpp, CancellationToken.None); actualConfig.Should().Be(cppProvider1.ConfigToReturn); }
public void IsSupported_ReturnsTrueIfSupportedByAny() { // Arrange var p1 = new DummyProvider(Language.C); var p2 = new DummyProvider(Language.VBNET); var p3 = new DummyProvider(Language.CSharp); var testSubject = new CompositeBindingConfigProvider(p1, p2, p3); // 1. Supported languages testSubject.IsLanguageSupported(Language.C).Should().BeTrue(); testSubject.IsLanguageSupported(Language.VBNET).Should().BeTrue(); testSubject.IsLanguageSupported(Language.CSharp).Should().BeTrue(); // 2. Unsupported langauge testSubject.IsLanguageSupported(Language.Cpp).Should().BeFalse(); }
public static void Main( ) { // Create an instance of IFormatProvider. DummyProvider provider = new DummyProvider( ); string format = "{0,-17}{1,-17}{2}"; // Convert these values using DummyProvider. string Int32A = "-252645135"; string DoubleA = "61680.3855"; string DayTimeA = "2001/9/11 13:45"; string BoolA = "True"; string StringA = "Qwerty"; string CharA = "$"; Console.WriteLine("This example of selected " + "Convert.To<Type>( String, IFormatProvider ) \nmethods " + "generates the following output. The example displays " + "the \nprovider type if the IFormatProvider is called."); Console.WriteLine("\nNote: For the " + "ToBoolean, ToString, and ToChar methods, the \n" + "IFormatProvider object is not referenced."); // The format provider is called for the following conversions. Console.WriteLine( ); Console.WriteLine(format, "ToInt32", Int32A, Convert.ToInt32(Int32A, provider)); Console.WriteLine(format, "ToDouble", DoubleA, Convert.ToDouble(DoubleA, provider)); Console.WriteLine(format, "ToDateTime", DayTimeA, Convert.ToDateTime(DayTimeA, provider)); // The format provider is not called for these conversions. Console.WriteLine( ); Console.WriteLine(format, "ToBoolean", BoolA, Convert.ToBoolean(BoolA, provider)); Console.WriteLine(format, "ToString", StringA, Convert.ToString(StringA, provider)); Console.WriteLine(format, "ToChar", CharA, Convert.ToChar(CharA, provider)); }
public WrappingLogger(DummyProvider provider, ILogger logger) { _provider = provider; _logger = logger; }
public WrappingLoggerFactory(ILoggerFactory innerLoggerFactory) { _innerLoggerFactory = innerLoggerFactory; _provider = new DummyProvider(); AddProvider(_provider); }
public BackupSupportingClassesFactoryAnonymousInnerClass(DummyProvider outerInstance, Org.Neo4j.backup.impl.BackupModule backupModule) : base(backupModule) { this.outerInstance = outerInstance; }