Пример #1
0
        public void CanReplace_ValuesInCollection()
        {
            DetailCollection collection = new DetailCollection(null, null, "hello", "world");

            collection.Replace(new[] { "hi", "world" });

            Assert.That(collection.Contains("hi"));
            Assert.That(collection.Contains("world"));
            Assert.That(!collection.Contains("hello"));
        }
Пример #2
0
        public void Contains_IsTrue_ForContainedString()
        {
            DetailCollection collection = new DetailCollection();

            collection.Add("hello");

            Assert.That(collection.Contains("hello"));
        }
Пример #3
0
        public void CanClone_Collection()
        {
            DetailCollection collection = new DetailCollection();

            collection.Add("hello");

            DetailCollection cloned = collection.Clone();

            Assert.That(cloned.Contains("hello"));
        }
Пример #4
0
        public void Collection_CanCombine_MultipleTypes()
        {
            object[]         objects    = new object[] { "hello", 1, 3.1415, true, DateTime.Now, new Content.AnItem(), new object[0] };
            DetailCollection collection = new DetailCollection();

            collection.AddRange(objects);

            foreach (object o in objects)
            {
                Assert.That(collection.Contains(o));
            }
        }
Пример #5
0
        private void ClearMissingDetails(ContentItem source, ContentItem destination)
        {
            // remove details not present in source
            List <string> detailKeys = new List <string>(destination.Details.Keys);

            foreach (string key in detailKeys)
            {
                if (!source.Details.ContainsKey(key))
                {
                    destination.Details.Remove(key);
                }
            }

            List <string> collectionKeys = new List <string>(destination.DetailCollections.Keys);

            foreach (string key in collectionKeys)
            {
                if (source.DetailCollections.ContainsKey(key))
                {
                    // remove detail collection values not present in source
                    DetailCollection destinationCollection = destination.DetailCollections[key];
                    DetailCollection sourceCollection      = source.DetailCollections[key];
                    List <object>    values = new List <object>(destinationCollection.Enumerate <object>());
                    foreach (object value in values)
                    {
                        if (!sourceCollection.Contains(value))
                        {
                            destinationCollection.Remove(value);
                        }
                    }
                }
                else
                {
                    // remove detail collections not present in source
                    destination.DetailCollections.Remove(key);
                }
            }
        }
Пример #6
0
		public void Collection_CanCombine_MultipleTypes()
		{
			object[] objects = new object[] {"hello", 1, 3.1415, true, N2.Utility.CurrentTime(), new Content.AnItem(), new object[0]};
			DetailCollection collection = new DetailCollection();
			collection.AddRange(objects);

            foreach(object o in objects)
				Assert.That(collection.Contains(o));
		}
Пример #7
0
		public void CanReplace_ValuesInCollection()
		{
			DetailCollection collection = new DetailCollection(null, null, "hello", "world");

			collection.Replace(new[] {"hi", "world"});

			Assert.That(collection.Contains("hi"));
			Assert.That(collection.Contains("world"));
			Assert.That(!collection.Contains("hello"));
		}
Пример #8
0
		public void Contains_IsTrue_ForContainedString()
		{
			DetailCollection collection = new DetailCollection();
			collection.Add("hello");

			Assert.That(collection.Contains("hello"));
		}