public void ContainsTest() { Assert.False(_customers.Contains("NotExists")); Assert.True(_customers.Contains("Customer#1")); Assert.True(_customers.Contains("Customer#2")); Assert.True(_employees.Contains("Employee#1")); }
public void ContainsMethodReturnsTrueWhenGivenAMatchingName() { var defaultFoo = new Foo("default"); var barFoo = new Foo("bar"); var bazFoo = new Foo("baz"); var values = new[] { defaultFoo, barFoo, bazFoo }; var collection = new NamedCollection <Foo>(values, f => f.Name); collection.Contains("bar").Should().Be(true); collection.Contains("baz").Should().Be(true); }
public void ContainsMethodReturnsFalseWhenGivenANonDefaultNameThatIsNotFound() { var defaultFoo = new Foo("default"); var barFoo = new Foo("bar"); var bazFoo = new Foo("baz"); var values = new[] { defaultFoo, barFoo, bazFoo }; var collection = new NamedCollection <Foo>(values, f => f.Name); collection.Contains("qux").Should().Be(false); }
public void ContainsMethodReturnsTrueWhenGivenADefaultNameAndThereIsADefaultValue(string name) { var defaultFoo = new Foo("default"); var barFoo = new Foo("bar"); var bazFoo = new Foo("baz"); var values = new[] { defaultFoo, barFoo, bazFoo }; var collection = new NamedCollection <Foo>(values, f => f.Name); collection.Contains(name).Should().Be(true); }
public void ContainsMethodReturnsFalseWhenGivenADefaultNameAndThereIsNoDefaultValue() { var barFoo = new Foo("bar"); var bazFoo = new Foo("baz"); var values = new[] { barFoo, bazFoo }; var collection = new NamedCollection <Foo>(values, f => f.Name); foreach (var defaultName in new[] { "default", null, "" }) { collection.Contains(defaultName).Should().Be(false); } }
/// <summary> /// Tries to retrieve an <see cref="Asset"/> from cache. /// </summary> /// <typeparam name="T">The type of <see cref="Asset"/> to get.</typeparam> /// <param name="name">The name (full ID) of the <see cref="Asset"/> to get.</param> /// <returns>The <see cref="Asset"/> if found, <c>null</c> otherwise.</returns> /// <exception cref="InvalidOperationException">A different type of asset with this <paramref name="name"/> was found instead.</exception> internal T GetAsset <T>(string name) where T : Asset { if (_assetCache.Contains(name)) { var asset = _assetCache[name] as T; if (asset == null) { throw new System.IO.InvalidDataException(Resources.WrongAssetType + name); // Incorrect asset type } return(asset); // Correct asset found } return(null); // Asset not found }
public ShaderReflectionVariable GetGlobal(string name) { if (_variables.Contains(name)) { return(_variables[name]); } foreach (var cb in _buffers) { if (cb.Constants.Contains(name)) { return(cb.Constants[name]); } } return(null); }
private void InitializeDescriptionForEnumColumn() { NamedCollection <Enumeration> enumerations = this.database.Enumerations; foreach (var table in this.database.Tables) { foreach (var column in table.Columns) { if (enumerations.Contains(column.Name)) { column.Description = BuildEnumColumnDescription(column.Description, enumerations[column.Name]); } } } }
/// <summary> /// Adds a specific file to the <paramref name="files"/> list. /// </summary> /// <param name="files">The collection to add the file to.</param> /// <param name="type">The type-subdirectory the file belongs to.</param> /// <param name="name">The file name to be added to the list.</param> /// <param name="flagAsMod">Set to <c>true</c> when handling mod files to detect added and changed files.</param> private static void AddFileToList(NamedCollection<FileEntry> files, string type, string name, bool flagAsMod) { if (flagAsMod) { // Detect whether this is a new file or a replacement for an existing one if (files.Contains(name)) { var previousEntry = files[name]; // Only mark as modified if the pre-existing file isn't already a mod file itself if (previousEntry.EntryType == FileEntryType.Normal) { files.Remove(previousEntry); files.Add(new FileEntry(type, name, FileEntryType.Modified)); } } else files.Add(new FileEntry(type, name, FileEntryType.Added)); } else { // Prevent duplicate entries if (!files.Contains(name)) files.Add(new FileEntry(type, name)); } }