public void Constructor_FullConfiguration_Works() { // ARRANGE var expected = new RemindMeWhenSettings { AzureStorage = new AzureStorageSettings { ConnectionString = GetRandomString(), ProcessDocumentQueueName = GetRandomString(), DocumentBlobContainerName = GetRandomString(), DocumentMetadataTableName = GetRandomString() }, RottenTomatoes = new RottenTomatoesSettings { ApiKey = GetRandomString() } }; using (var configurationFile = new ConfigurationFile(expected)) { // ACT RemindMeWhenConfiguration configuration = configurationFile.GetConfiguration(); // ASSERT RemindMeWhenSettings actual = configuration.GetSettings(); actual.ShouldBeEquivalentTo(expected); configurationFile.Delete = true; } }
public void TestTweetConfigGetConfigurationFromString() { Type tweeterType = typeof(Tweeter); ITang tang = TangFactory.GetTang(); IConfiguration conf = tang.NewConfigurationBuilder(new string[] { FileNames.Examples }) .BindImplementation(GenericType <ITweetFactory> .Class, GenericType <MockTweetFactory> .Class) .BindImplementation(GenericType <ISMS> .Class, GenericType <MockSMS> .Class) .BindNamedParameter <Tweeter.PhoneNumber, long>( GenericType <Tweeter.PhoneNumber> .Class, "8675309") .Build(); ConfigurationFile.WriteConfigurationFile(conf, "tweeterConf.txt"); string s = ConfigurationFile.ToConfigurationString(conf); IConfiguration conf2 = ConfigurationFile.GetConfiguration(s); IInjector injector = tang.NewInjector(conf2); var tweeter = (Tweeter)injector.GetInstance(tweeterType); tweeter.sendMessage(); }
public void TestSetConfig() { IConfiguration conf = TangFactory.GetTang().NewConfigurationBuilder() .BindSetEntry <SetOfNumbers, string>(GenericType <SetOfNumbers> .Class, "four") .BindSetEntry <SetOfNumbers, string>(GenericType <SetOfNumbers> .Class, "five") .BindSetEntry <SetOfNumbers, string>(GenericType <SetOfNumbers> .Class, "six") .Build(); Box b = (Box)TangFactory.GetTang().NewInjector(conf).GetInstance(typeof(Box)); ConfigurationFile.WriteConfigurationFile(conf, "SetOfNumbersConf.txt"); string s = ConfigurationFile.ToConfigurationString(conf); IConfiguration conf2 = ConfigurationFile.GetConfiguration(s); Box b2 = (Box)TangFactory.GetTang().NewInjector(conf2).GetInstance(typeof(Box)); ISet <string> actual = b2.Numbers; Assert.True(actual.Contains("four")); Assert.True(actual.Contains("five")); Assert.True(actual.Contains("six")); }