public EconDesignXmlInput( [JsonProperty(PropertyName = "material", Required = Required.Always)] IEnumerable <EconDesignXmlMaterial> materials) { Material = new DictionaryContainer <string, EconDesignXmlMaterial>(materials, key => key.Id, StringComparer.OrdinalIgnoreCase); }
/// <summary> /// Registers the dependencies. /// </summary> /// <param name="container">The container to register the dependencies in.</param> public override void RegisterDependencies(DictionaryContainer container) { container.Register <FakeScope>(c => FakeScope.Current); container.Register <IFakeObjectContainer>(c => c.Resolve <FakeScope>().FakeObjectContainer); container.RegisterSingleton <IProxyGenerator>(c => new FakeItEasy.DynamicProxy.DynamicProxyProxyGenerator()); container.RegisterSingleton <IExpressionCallMatcherFactory>(c => new ExpressionCallMatcherFactory { Container = c }); container.RegisterSingleton <ArgumentValidatorFactory>(c => new ArgumentValidatorFactory()); container.RegisterSingleton <ExpressionCallRule.Factory>(c => callSpecification => new ExpressionCallRule(new ExpressionCallMatcher(callSpecification, c.Resolve <ArgumentValidatorFactory>(), c.Resolve <MethodInfoManager>()))); container.RegisterSingleton <IFakeAssertionsFactory>(c => new FakeAssertionsFactory { Container = c }); container.RegisterSingleton <MethodInfoManager>(c => new MethodInfoManager()); container.RegisterSingleton <FakeAsserter.Factory>(c => x => new FakeAsserter(x, c.Resolve <CallWriter>())); container.Register <FakeObjectFactory>(c => new FakeObjectFactory(c.Resolve <IFakeObjectContainer>(), c.Resolve <IProxyGenerator>(), c.Resolve <FakeObject.Factory>())); container.RegisterSingleton <FakeObject.Factory>(c => () => new FakeObject()); container.RegisterSingleton <CallWriter>(c => new CallWriter()); container.RegisterSingleton <RecordingManager.Factory>(c => x => new RecordingManager(x)); container.RegisterSingleton <IFileSystem>(c => new FileSystem()); container.RegisterSingleton <FileStorage.Factory>(c => x => new FileStorage(x, c.Resolve <IFileSystem>())); container.RegisterSingleton <IExpressionParser>(c => new ExpressionParser()); container.Register <IFakeObjectGeneratorFactory>(c => c.Resolve <FakeObjectFactory>()); container.RegisterSingleton <IFakeObjectBuilder>(c => new FakeObjectBuilder(c.Resolve <FakeObjectFactory>())); }
public override void RegisterDependencies(DictionaryContainer container) { container.RegisterSingleton <RecordedCallRule.Factory>(c => () => new RecordedCallRule(c.Resolve <MethodInfoManager>())); container.RegisterSingleton <IRecordingCallRuleFactory>(c => new RecordingCallRuleFactory() { Container = c }); container.RegisterSingleton <IConfigurationFactory>(c => new ConfigurationFactory() { Container = c }); container.RegisterSingleton <IStartConfigurationFactory>(c => new StartConfigurationFactory() { Container = c }); container.RegisterSingleton <RuleBuilder.Factory>(c => rule => new RuleBuilder(rule)); }
/// <summary> /// Registers the dependencies. /// </summary> /// <param name="container">The container to register the dependencies in.</param> public override void RegisterDependencies(DictionaryContainer container) { container.Register <FakeScope>(c => FakeScope.Current); container.RegisterSingleton <IFakeProxyGenerator>(c => new FakeItEasy.DynamicProxy.DynamicProxyGenerator()); container.RegisterSingleton <FakeObjectFactory.Creator>(c => () => new FakeObjectFactory(c.Resolve <IFakeObjectContainer>())); container.RegisterSingleton <ExpressionCallMatcher.Factory>(c => expression => new ExpressionCallMatcher(expression, c.Resolve <ArgumentValidatorFactory>())); container.Register <IFakeObjectContainer>(c => c.Resolve <FakeScope>().FakeObjectContainer); container.RegisterSingleton <ArgumentValidatorFactory>(c => new ArgumentValidatorFactory()); container.RegisterSingleton <ExpressionCallRule.Factory>(c => callSpecification => new ExpressionCallRule(c.Resolve <ExpressionCallMatcher.Factory>().Invoke(callSpecification))); container.RegisterSingleton <ICallCollectionFactory>(c => new CallCollectionFactory { Container = c }); container.RegisterSingleton <IFakeAssertionsFactory>(c => new FakeAssertionsFactory { Container = c }); }
static ServiceLocator() { var container = new DictionaryContainer(); new RootModule().RegisterDependencies(container); Current = container; }
public override void RegisterDependencies(DictionaryContainer container) { container.RegisterSingleton <RecordedCallRule.Factory>(c => () => new RecordedCallRule(c.Resolve <MethodInfoManager>())); container.RegisterSingleton <IRecordingCallRuleFactory>(c => new RecordingCallRuleFactory { Container = c }); container.RegisterSingleton <IConfigurationFactory>(c => new ConfigurationFactory { Container = c }); container.RegisterSingleton <IStartConfigurationFactory>(c => new StartConfigurationFactory { Container = c }); container.RegisterSingleton <RuleBuilder.Factory>(c => (rule, fake) => new RuleBuilder(rule, fake, c.Resolve <FakeAsserter.Factory>())); container.RegisterSingleton <IFakeConfigurationManager>(c => new FakeConfigurationManager(c.Resolve <IConfigurationFactory>(), c.Resolve <IExpressionParser>(), c.Resolve <ExpressionCallRule.Factory>(), c.Resolve <ICallExpressionParser>(), c.Resolve <IInterceptionAsserter>())); }
public void ObjectAppenderDictionaryEqualsTest() { // setup string nameA = "Timmy"; var itemsA = new Dictionary <string, string> { { "a", "apple" }, { "b", "banana" } }; string nameB = "Timmy"; var itemsB = new Dictionary <string, string> { { "a", "apple" }, { "b", "banana" } }; var dictionaryContainerA = new DictionaryContainer { Name = nameA, Items = itemsA }; var dictionaryContainerB = new DictionaryContainer { Name = nameB, Items = itemsB }; // test var equal = dictionaryContainerA.Equals(dictionaryContainerB); // assert Assert.IsTrue(equal); }
public void DictionaryNotEqualsTest() { // setup string nameA = "Timmy"; var itemsA = new Dictionary <string, string> { { "a", "appleA" }, { "b", "bananaA" } }; string nameB = "Timmy"; var itemsB = new Dictionary <string, string> { { "aa", "appleB" }, { "bb", "bananaB" } }; var dictionaryContainerA = new DictionaryContainer { Name = nameA, Items = itemsA }; var dictionaryContainerB = new DictionaryContainer { Name = nameB, Items = itemsB }; // test var equal = dictionaryContainerA.Equals(dictionaryContainerB); // assert Assert.IsFalse(equal); }
public RewardTableXml([JsonProperty(PropertyName = "name", Required = Required.Always, Order = 1)] string name, [JsonProperty(PropertyName = "rewards", Required = Required.Always, Order = 2)] IEnumerable <RewardTableXmlRewards> rewards) { Name = name; Rewards = new DictionaryContainer <string, RewardTableXmlRewards>(rewards, key => key.Key, StringComparer.OrdinalIgnoreCase); }
private FakeObjectFactory CreateFactory() { this.container = new DictionaryContainer { RegisteredTypes = new Dictionary <Type, object>() }; return(new FakeObjectFactory(this.container)); }
static ServiceLocator() { var container = new DictionaryContainer(); RootModule.RegisterDependencies(container); ConfigurationModule.RegisterDependencies(container); ImportsModule.RegisterDependencies(container); Current = container; }
public void ReturnsTheDefaultValueWhenTheRequestedTypeHasNotBeenRegistered() { var def = new object(); var sut = new DictionaryContainer<object>(def); var result = sut.Find<SomeCommand>(); Assert.AreEqual(def, result); }
public void ReturnsTheDefaultValueWhenTheRequestedTypeHasNotBeenRegistered() { var def = new object(); var sut = new DictionaryContainer <object>(def); var result = sut.Find <SomeCommand>(); Assert.AreEqual(def, result); }
public void ToStringAppendExpressionNull() { // setup var dictionaryContainer = new DictionaryContainer(); var toStringBuilder = new ToStringBuilder <DictionaryContainer>(dictionaryContainer); // test toStringBuilder.Append <string>(null); }
public void FindsTheCorrectKey() { var sut = new DictionaryContainer<object>(null); var o = new object(); sut.Register<SomeCommand>(() => o); var result = sut.Find<SomeCommand>(); Assert.AreEqual(o, result); }
public override void RegisterDependencies(DictionaryContainer container) { container.RegisterSingleton <TypeCatalogueInstanceProvider>(c => new TypeCatalogueInstanceProvider(c.Resolve <ITypeCatalogue>())); container.RegisterSingleton <ITypeCatalogue>(c => new ApplicationDirectoryAssembliesTypeCatalogue()); RegisterEnumerableInstantiatedFromTypeCatalogue <IArgumentValueFormatter>(container); RegisterEnumerableInstantiatedFromTypeCatalogue <IDummyDefinition>(container); RegisterEnumerableInstantiatedFromTypeCatalogue <IFakeConfigurator>(container); }
public void FindsTheCorrectKey() { var sut = new DictionaryContainer <object>(null); var o = new object(); sut.Register <SomeCommand>(() => o); var result = sut.Find <SomeCommand>(); Assert.AreEqual(o, result); }
public void ToStringAppendNull() { // setup var dictionaryContainer = new DictionaryContainer(); var toStringBuilder = new ToStringBuilder <DictionaryContainer>(dictionaryContainer); // test toStringBuilder.Append(null, "NullName"); var toString = toStringBuilder.ToString(); // assert Assert.AreEqual("DictionaryContainer:{NullName=null}", toString); }
private IDictionaryContainer CreateDictionaryResource(IEnumerable <KeyValuePair <string, string> > items = null) { var dictContainer = new DictionaryContainer(); foreach (var kvp in items.EmptyIfNull()) { dictContainer.Map.Add(kvp); } Save(dictContainer); var dictResource = Client.DictionaryContainers.Get(dictContainer.Id); return(dictResource); }
public static void Test() { var container = new DictionaryContainer(); container.Values["one"] = "first"; container.Values["two"] = "second"; container.Values["three"] = "third"; Debug.Assert(container.Values.GetType() == typeof(MyDictionary <string, string>)); // No assert var json = JsonConvert.SerializeObject(container, Formatting.Indented); var container2 = JsonConvert.DeserializeObject <DictionaryContainer>(json); Debug.Assert(container.Values.GetType() == container2.Values.GetType()); // No assert }
public static void RegisterDependencies(DictionaryContainer container) { container.RegisterSingleton <IConfigurationFactory>(c => new ConfigurationFactory(c)); container.RegisterSingleton <IStartConfigurationFactory>(c => new StartConfigurationFactory(c)); container.RegisterSingleton <RuleBuilder.Factory>(c => (rule, fake) => new RuleBuilder(rule, fake, c.Resolve <FakeAsserter.Factory>())); container.RegisterSingleton <IFakeConfigurationManager>(c => new FakeConfigurationManager(c.Resolve <IConfigurationFactory>(), c.Resolve <ExpressionCallRule.Factory>(), c.Resolve <ICallExpressionParser>(), c.Resolve <IInterceptionAsserter>())); }
public AllianceXmlRank( [Range(-1, int.MaxValue)][JsonProperty(PropertyName = "percentileindex", Required = Required.Always)] int percentileIndex, [Range(0, int.MaxValue)][JsonProperty(PropertyName = "titleid", Required = Required.Always)] string titleId, [JsonProperty(PropertyName = "iconpath", Required = Required.Always)] string iconPath, [JsonProperty(PropertyName = "passives", Required = Required.Always)] IEnumerable <AllianceXmlPassive> passives) { PercentileIndex = percentileIndex; TitleId = titleId; IconPath = iconPath; Passives = new DictionaryContainer <string, AllianceXmlPassive>(passives, key => key.Tech, StringComparer.OrdinalIgnoreCase); }
public void Creating_fakes_will_use_the_container_of_the_current_scope() { var container = new DictionaryContainer { RegisteredTypes = new Dictionary <Type, object> { { typeof(string), "fake string" }, { typeof(int), 100 } } }; using (Fake.CreateScope(container)) { Assert.That(A.Dummy <string>(), Is.EqualTo("fake string")); Assert.That(A.Dummy <int>(), Is.EqualTo(100)); } }
public void CollectionToStringTest() { // setup var dictionaryContainer = new DictionaryContainer() { Name = "testName", Items = new Dictionary <string, string> { { "MemberA", "aaa" } } }; // test var dictionaryContainerString = dictionaryContainer.ToString(); // assert Assert.AreEqual("DictionaryContainer:{Name=testName,Items=[ [MemberA, aaa] ]}", dictionaryContainerString); }
public override void RegisterDependencies(DictionaryContainer container) { var bootstrapper = BootstrapperLocator.FindBootstrapper(); container.RegisterSingleton <TypeCatalogueInstanceProvider>(c => new TypeCatalogueInstanceProvider(c.Resolve <ITypeCatalogue>())); container.RegisterSingleton <ITypeCatalogue>(c => { var typeCatalogue = new TypeCatalogue(); typeCatalogue.Load(bootstrapper.GetAssemblyFileNamesToScanForExtensions()); return(typeCatalogue); }); RegisterEnumerableInstantiatedFromTypeCatalogue <IArgumentValueFormatter>(container); RegisterEnumerableInstantiatedFromTypeCatalogue <IDummyDefinition>(container); RegisterEnumerableInstantiatedFromTypeCatalogue <IFakeConfigurator>(container); }
public RandomMapSetXml([JsonProperty(PropertyName = "id", Required = Required.Always, Order = 1)] string id, [JsonProperty(PropertyName = "displayNameID", Required = Required.Always, Order = 1)] int displayNameId, [JsonProperty(PropertyName = "imagepath", Required = Required.Always, Order = 3)] string imagepath, [JsonProperty(PropertyName = "helpTextID", Required = Required.Always, Order = 4)] int helpTextId, [JsonProperty(PropertyName = "cannotReplace", Required = Required.Always, Order = 5)] bool isCannotReplace, [JsonProperty(PropertyName = "map", Required = Required.Always, Order = 6)] IEnumerable <RandomMapSetXmlMap> map) { Id = !string.IsNullOrWhiteSpace(id) ? id : throw new ArgumentNullException(nameof(id)); DisplayNameId = displayNameId; ImagePath = !string.IsNullOrWhiteSpace(imagepath) ? imagepath : throw new ArgumentNullException(nameof(imagepath)); HelpTextId = helpTextId; CannotReplace = isCannotReplace; Map = new DictionaryContainer <string, RandomMapSetXmlMap>(map, key => key.Path, StringComparer.OrdinalIgnoreCase); }
public void TestMergeDictionaryNewKeyValue() { var baseDic = new DictionaryContainer() { Items = new Dictionary <string, string>() { { "A", "AValue" }, { "B", "BValue" }, { "C", "CValue" }, } }; var newDic = new DictionaryContainer() { Items = new Dictionary <string, string>(baseDic.Items) }; var newBaseDic = new DictionaryContainer() { Items = new Dictionary <string, string>() { { "A", "AValue" }, { "B", "BValue" }, { "C", "CValue" }, { "D", "DValue" }, } }; var diff = new AssetDiff(AssetCloner.Clone(baseDic), newDic, AssetCloner.Clone(newBaseDic)) { UseOverrideMode = true }; var result = AssetMerge.Merge(diff, AssetMergePolicies.MergePolicyAsset2AsNewBaseOfAsset1); Assert.False(result.HasErrors); Assert.AreEqual(4, newDic.Items.Count); }
public static void SaveDictionary(Dictionary <string, Dictionary <string, string> > dict) { //Serialize dict to list DataContainer languages = new DataContainer(); foreach (string language in dict.Keys.ToList()) { DoubleDictionaryContainer languageData = new DoubleDictionaryContainer { dataName = language }; Dictionary <string, string> dialogs; dict.TryGetValue(language, out dialogs); foreach (string dialog in dialogs.Keys.ToList()) { DictionaryContainer dialogData = new DictionaryContainer { dataName = dialog, data = dialogs[dialog] }; languageData.data.Add(dialogData); } languages.availableLanguages.Add(languageData); } //Convert object to JSON string jsonData = JsonUtility.ToJson(languages); //Finally write the json string to a file string filePath = Application.dataPath + "/Resources/LocalizationData.json"; File.WriteAllText(filePath, jsonData); Debug.Log("Localization Manager: Changes saved to JSON!"); }
public void DictionaryNotGetHashCodeTest() { // setup string nameA = "Timmy"; var itemsA = new Dictionary <string, string> { { "a", "appleA" }, { "b", "bananaA" } }; string nameB = "Timmy"; var itemsB = new Dictionary <string, string> { { "aa", "appleB" }, { "bb", "bananaB" } }; var dictionaryContainerA = new DictionaryContainer { Name = nameA, Items = itemsA }; var dictionaryContainerB = new DictionaryContainer { Name = nameB, Items = itemsB }; // test var dictionaryContainerAHash = dictionaryContainerA.GetHashCode(); var dictionaryContainerBHash = dictionaryContainerB.GetHashCode(); // assert Assert.AreNotEqual(dictionaryContainerAHash, dictionaryContainerBHash); }
public EconDesignXmlInput() { Material = new DictionaryContainer <string, EconDesignXmlMaterial>(key => key.Id, StringComparer.OrdinalIgnoreCase); }
public override void RegisterDependencies(DictionaryContainer container) { container.Register(c => FakeScope.Current); container.Register(c => c.Resolve <FakeScope>().FakeObjectContainer); container.RegisterSingleton <IExpressionCallMatcherFactory>(c => new ExpressionCallMatcherFactory { Container = c }); container.RegisterSingleton(c => new ExpressionArgumentConstraintFactory(c.Resolve <IArgumentConstraintTrapper>())); container.RegisterSingleton <ExpressionCallRule.Factory>(c => callSpecification => new ExpressionCallRule(new ExpressionCallMatcher(callSpecification, c.Resolve <ExpressionArgumentConstraintFactory>(), c.Resolve <MethodInfoManager>(), c.Resolve <ICallExpressionParser>()))); container.RegisterSingleton(c => new MethodInfoManager()); container.Register <FakeAsserter.Factory>(c => x => OrderedAssertion.CurrentAsserterFactory.Invoke(x)); container.RegisterSingleton <FakeManager.Factory>(c => (fakeObjectType, proxy) => new FakeManager(fakeObjectType, proxy)); container.RegisterSingleton <FakeCallProcessorProvider.Factory>(c => (typeOfFake, fakeOptions) => new FakeManagerProvider(c.Resolve <FakeManager.Factory>(), c.Resolve <IFakeManagerAccessor>(), c.Resolve <IFakeObjectContainer>(), c.Resolve <IFakeWrapperConfigurer>(), typeOfFake, fakeOptions)); container.RegisterSingleton <IFakeObjectCallFormatter>(c => new DefaultFakeObjectCallFormatter(c.Resolve <ArgumentValueFormatter>(), c.Resolve <IFakeManagerAccessor>())); container.RegisterSingleton(c => new ArgumentValueFormatter(c.Resolve <IEnumerable <IArgumentValueFormatter> >())); container.RegisterSingleton(c => new CallWriter(c.Resolve <IFakeObjectCallFormatter>(), c.Resolve <IEqualityComparer <IFakeObjectCall> >())); container.RegisterSingleton <RecordingManager.Factory>(c => x => new RecordingManager(x)); container.RegisterSingleton <IFileSystem>(c => new FileSystem()); #if !SILVERLIGHT container.RegisterSingleton <FileStorage.Factory>(c => x => new FileStorage(x, c.Resolve <IFileSystem>())); #endif container.RegisterSingleton <ICallExpressionParser>(c => new CallExpressionParser()); container.RegisterSingleton <IExpressionParser>(c => new ExpressionParser(c.Resolve <ICallExpressionParser>())); container.RegisterSingleton <RecordingRuleBuilder.Factory>(c => (rule, fakeObject) => new RecordingRuleBuilder(rule, c.Resolve <RuleBuilder.Factory>().Invoke(rule, fakeObject))); container.Register <IFakeCreatorFacade>(c => new DefaultFakeCreatorFacade(c.Resolve <IFakeAndDummyManager>())); container.Register <IFakeAndDummyManager>(c => { var fakeCreator = new FakeObjectCreator(c.Resolve <IProxyGenerator>(), c.Resolve <IExceptionThrower>(), c.Resolve <FakeCallProcessorProvider.Factory>()); var session = new DummyValueCreationSession(c.Resolve <IFakeObjectContainer>(), new SessionFakeObjectCreator { Creator = fakeCreator }); return(new DefaultFakeAndDummyManager(session, fakeCreator)); }); container.RegisterSingleton(c => new CastleDynamicProxyGenerator(c.Resolve <CastleDynamicProxyInterceptionValidator>())); container.RegisterSingleton(c => new DelegateProxyGenerator()); container.RegisterSingleton <IProxyGenerator>(c => new ProxyGeneratorSelector(c.Resolve <DelegateProxyGenerator>(), c.Resolve <CastleDynamicProxyGenerator>())); container.RegisterSingleton( c => new CastleDynamicProxyInterceptionValidator(c.Resolve <MethodInfoManager>())); container.RegisterSingleton <IExceptionThrower>(c => new DefaultExceptionThrower()); container.RegisterSingleton <IFakeManagerAccessor>(c => new DefaultFakeManagerAccessor()); container.Register <IFakeWrapperConfigurer>(c => new DefaultFakeWrapperConfigurer()); container.Register(c => new FakeFacade(c.Resolve <IFakeManagerAccessor>(), c.Resolve <IFakeScopeFactory>(), c.Resolve <IFixtureInitializer>())); container.RegisterSingleton <IFakeScopeFactory>(c => new FakeScopeFactory()); container.Register <IFixtureInitializer>(c => new DefaultFixtureInitializer(c.Resolve <IFakeAndDummyManager>(), c.Resolve <ISutInitializer>())); container.RegisterSingleton <IEqualityComparer <IFakeObjectCall> >(c => new FakeCallEqualityComparer()); container.Register <IInterceptionAsserter>(c => new DefaultInterceptionAsserter(c.Resolve <IProxyGenerator>())); container.Register <IArgumentConstraintTrapper>(c => new ArgumentConstraintTrap()); container.Register <IArgumentConstraintManagerFactory>(c => new ArgumentConstraintManagerFactory()); container.RegisterSingleton <IOutputWriter>(c => new DefaultOutputWriter(Console.Write)); container.Register <ISutInitializer>(c => new DefaultSutInitializer(c.Resolve <IFakeAndDummyManager>())); container.RegisterSingleton(c => new EventHandlerArgumentProviderMap()); }
public override void RegisterDependencies(DictionaryContainer container) { container.RegisterSingleton(c => this.ImportedArgumentValueFormatters); container.RegisterSingleton(c => this.ImportedDummyDefinitions); container.RegisterSingleton(c => this.ImportedFakeConfigurators); }
public override void RegisterDependencies(DictionaryContainer container) { container.RegisterSingleton(c => Enumerable.Empty<IFakeConfigurator>()); container.RegisterSingleton(c => Enumerable.Empty<IDummyFactory>()); container.RegisterSingleton(c => Enumerable.Empty<IArgumentValueFormatter>()); }
/// <summary> /// Registers the components of this module. /// </summary> /// <param name="container">The container to register components in.</param> public abstract void RegisterDependencies(DictionaryContainer container);
private static void RegisterEnumerableInstantiatedFromTypeCatalogue <T>(DictionaryContainer container) { container.RegisterSingleton <IEnumerable <T> >(c => c.Resolve <TypeCatalogueInstanceProvider>().InstantiateAllOfType <T>()); }
public void TestMergeDictionaryNewKeyValue() { var baseDic = new DictionaryContainer() { Items = new Dictionary<string, string>() { { "A", "AValue" }, { "B", "BValue" }, { "C", "CValue" }, } }; var newDic = new DictionaryContainer() { Items = new Dictionary<string, string>(baseDic.Items) }; var newBaseDic = new DictionaryContainer() { Items = new Dictionary<string, string>() { { "A", "AValue" }, { "B", "BValue" }, { "C", "CValue" }, { "D", "DValue" }, } }; var diff = new AssetDiff(AssetCloner.Clone(baseDic), newDic, AssetCloner.Clone(newBaseDic)) { UseOverrideMode = true }; var result = AssetMerge.Merge(diff, AssetMergePolicies.MergePolicyAsset2AsNewBaseOfAsset1); Assert.False(result.HasErrors); Assert.AreEqual(4, newDic.Items.Count); }