public void TestRemove() { List<object> list = new List<object>(new object[] { "a", "b" }); var test = new CollectionAdapter<object, string>(list); Assert.True(test.Remove("a")); Utilities.TestSequenceEqual(list, "b"); }
public void TestRemoveInvalid() { List <string> list = new List <string>(); var test = new CollectionAdapter <string, object>(list); Assert.Throws <InvalidOperationException>(delegate() { test.Remove(new object()); }); }
public void TestAddNull() { List<object> list = new List<object>(); var test = new CollectionAdapter<object, string>(list); test.Add(null); Utilities.TestSequenceEqual(list, (object)null); }
public void TestReadonly() { List <object> list = new List <object>(new object[] { "a", "b" }); var test = new CollectionAdapter <object, string>(list); Assert.False(test.IsReadOnly); }
public void TestRemoveNull() { List <object> list = new List <object>(); var test = new CollectionAdapter <object, string>(list); Assert.False(test.Remove(null)); }
public void CountMatchesSource() { IList <int> baseCollection = System.Linq.Enumerable.Range(0, 10).ToList(); var col = new CollectionAdapter <int>(() => baseCollection); Assert.Equal(baseCollection.Count, col.Count); }
public void AddRemoveElement() { IList <int> baseCollection = new List <int>(new[] { 2, 3, 4 }); bool hitAdd = false; bool hitRemove = false; var forwardedCollection = new CollectionAdapter <int>( () => baseCollection, x => { hitAdd = true; baseCollection.Add(x); }, x => { hitRemove = true; return(baseCollection.Remove(x)); }); Assert.Equal(baseCollection, forwardedCollection); Assert.False(hitAdd); Assert.False(hitRemove); forwardedCollection.Add(5); Assert.Equal(baseCollection, forwardedCollection); Assert.True(hitAdd); Assert.False(hitRemove); hitRemove = false; hitAdd = false; forwardedCollection.Remove(2); Assert.Equal(baseCollection, forwardedCollection); Assert.False(hitAdd); Assert.True(hitRemove); }
public override void OnNext(ChangedCollectionData <T> value) { var change = new CollectionChange <T, TAdaptee>(value.Change, _selector); var state = new CollectionAdapter <T, TAdaptee>(value.ReachedState, _selector); this.Adaptee.OnNext(new ChangedCollectionData <TAdaptee>(change, state)); }
public void TestConstructor() { CollectionAdapter <object, string> test; Assert.Throws <ArgumentNullException>( delegate() { test = new CollectionAdapter <object, string>(null); }); }
public void ContainsEnsureSourcePresence() { IList <int> baseCollection = System.Linq.Enumerable.Range(0, 10).ToList(); var col = new CollectionAdapter <int>(() => baseCollection, baseCollection.Add, baseCollection.Remove); Assert.Contains(3, col); Assert.Throws <ContainsException>(() => Assert.Contains(10, col)); }
public void TestCount() { List<object> list = new List<object>(new object[] { "a", "b" }); var test = new CollectionAdapter<object, string>(list); Assert.True(test.Count == 2); list.Clear(); Assert.True(test.Count == 0); }
public void TestConstructor() { #pragma warning disable 219 //disable warning about 'test' not being used CollectionAdapter<object, string> test; #pragma warning restore 219 Assert.Throws<ArgumentNullException>( delegate() { test = new CollectionAdapter<object, string>(null); }); }
public void TestAddNull() { List <object> list = new List <object>(); var test = new CollectionAdapter <object, string>(list); test.Add(null); Utilities.TestSequenceEqual(list, (object)null); }
public void TestRemove() { List <object> list = new List <object>(new object[] { "a", "b" }); var test = new CollectionAdapter <object, string>(list); Assert.True(test.Remove("a")); Utilities.TestSequenceEqual(list, "b"); }
public void TestConstructor() { #pragma warning disable 219 //disable warning about 'test' not being used CollectionAdapter <object, string> test; #pragma warning restore 219 Assert.Throws <ArgumentNullException>( delegate() { test = new CollectionAdapter <object, string>(null); }); }
public void TestCount() { List <object> list = new List <object>(new object[] { "a", "b" }); var test = new CollectionAdapter <object, string>(list); Assert.True(test.Count == 2); list.Clear(); Assert.True(test.Count == 0); }
public void ClearCleansSource() { IList <int> baseCollection = System.Linq.Enumerable.Range(0, 10).ToList(); var col = new CollectionAdapter <int>(() => baseCollection, baseCollection.Add, baseCollection.Remove); col.Clear(); Assert.Empty(baseCollection); Assert.Empty(col); }
public void IsReadOnlyOnNullCallbacks() { IList <int> baseCollection = System.Linq.Enumerable.Range(0, 10).ToList(); var col = new CollectionAdapter <int>(() => baseCollection); Assert.True(col.IsReadOnly); col = new CollectionAdapter <int>(() => baseCollection, baseCollection.Add, baseCollection.Remove); Assert.False(col.IsReadOnly); }
public static ICollection <T> AsCollection <T>(this IEnumerable <T> collection) { var result = collection as ICollection <T>; if (null != result) { return(result); } result = new CollectionAdapter <T>(collection); return(result); }
public SpatialQuery(params ISpatialQuery <TInput>[] queries) { if (queries == null) { throw new ArgumentNullException("query"); } this.Condition = d => d is TOutput; this.Converter = d => (TOutput)(object)d; this.InnerQueries = new List <ISpatialQuery <TInput> >(queries); this.adapter = new CollectionAdapter() { Parent = this }; }
public SceneQuery(List <ISceneManager <ISpatialQueryable> > sceneManagers, IList <object> topLevelObjects, Predicate <T> condition) { this.sceneManagers = sceneManagers; this.topLevelObjects = topLevelObjects; this.adapter = new CollectionAdapter(condition); }
public void MapCollection() { var person = new Person() { Id = Guid.NewGuid(), Name = "Timuçin", Surname = "KIVANÇ", Project = Projects.A, X = new int[] { 1, 2, 3, 4 }, Y = new List <int>() { 5, 6, 7 }, Z = new ArrayList((ICollection)(new List <Guid>() { Guid.NewGuid(), Guid.NewGuid() })), Ids = new List <Guid>() { Guid.Empty, Guid.NewGuid() }, CityId = Guid.NewGuid(), Picture = new byte[] { 0, 1, 2 }, Countries = new List <string> { "Turkey", "Germany" }, XX = new List <string> { "Nederland", "USA" }, YY = new List <int> { 22, 33 }, ZZ = new List <int> { 44, 55 }, RelatedDepartments = new Departments[] { Departments.IT, Departments.Finance }, Projects = new List <XProject>() { new XProject { Id = 1, Name = "Project X" } } }; var persons = new List <Person>() { person }; var dtos = (Person[])CollectionAdapter <List <Person>, Person, Person[]> .Adapt(persons); Assert.IsNotNull(dtos); Assert.IsTrue(dtos.Length == 1); Assert.IsTrue(dtos.First().Id == person.Id && dtos.First().Name == "Timuçin" && dtos.First().Surname == "KIVANÇ"); Assert.IsNotNull(dtos[0].Projects); Assert.IsTrue(dtos[0].Projects.First().Id == 1 && dtos[0].Projects.First().Name == "Project X"); }
public void TestReadonly() { List<object> list = new List<object>(new object[] { "a", "b" }); var test = new CollectionAdapter<object, string>(list); Assert.False(test.IsReadOnly); }
public void Initialize() { _targetAdapter = new CollectionAdapter(); _sourceAdapter = new ValueAdapter(); _comparer = EqualityComparer <object> .Default; }
public void TestRemoveNull() { List<object> list = new List<object>(); var test = new CollectionAdapter<object, string>(list); Assert.False(test.Remove(null)); }
public void TestConstructor() { CollectionAdapter<object, string> test; Assert.Throws<ArgumentNullException>( delegate() { test = new CollectionAdapter<object, string>(null); }); }
static void Main(string[] args) { ICollectionBase adapter = new CollectionAdapter(); adapter.Add("dddd"); }
public void TestRemoveInvalid() { List<string> list = new List<string>(); var test = new CollectionAdapter<string, object>(list); Assert.Throws<InvalidOperationException>(delegate() { test.Remove(new object()); }); }
/// <summary> /// Initializes a new instance of the <see cref="ItemStorageAdapter"/> class. /// </summary> /// <param name="actualStorage">The actual storage.</param> /// <param name="firstItemSlot">The first item slot.</param> /// <param name="itemSlotCount">The item slot count.</param> public ItemStorageAdapter(ItemStorage actualStorage, byte firstItemSlot, byte itemSlotCount) { this.adapter = new CollectionAdapter(actualStorage.Items, firstItemSlot, itemSlotCount); this.ActualStorage = actualStorage; }
public void CanTestContentsOfCollectionNotImplementingIList() { CollectionAdapter ints = new CollectionAdapter(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); Assert.That(ints, new CollectionContainsConstraint(9)); }