示例#1
0
        public void Drivers()
        {
            var letters = new List<string>();

            for (var letter = 'D'; letter <= 'Z'; letter++)
            {
                letters.Add(letter + ":\\");
                Console.Write(letter + " ");
            }

            Console.WriteLine();

            var drives = DriveInfo.GetDrives().Select(x => x.Name);

            foreach (var drive in drives)
            {
                Console.Write(drive + " ");
            }

            Console.WriteLine();

            foreach (var l in letters.Except(drives))
            {
                Console.Write(l + " ");
            }
        }
        public void CanApplyLocalCopyOfFullMasterDataUpdate()
        {
            //Given 
            var zipStreamProcesser = new FakeZipStreamProcesser(FullMasterUpdatePath);
            var masterDataUpdater = new MasterDataUpdater(Database, zipStreamProcesser);
            
            //When
            var result = masterDataUpdater.ApplyUpdate(false, default(Stream));
            
            //Then
            CheckResult(result);
            
            var actualTableNames = new List<string>();
            var emptyTables = new List<string>();

            foreach (var entity in DatabaseConfig.GetMasteDataTypes())
            {                
                var tableName = Database.GetTableName(entity);              
                actualTableNames.Add(tableName);

                var count = Database.Count(entity);
                if (count == 0) emptyTables.Add(tableName);
            }

            var fail = CheckEmpty("Local Tables that have no rows:\n{0}", emptyTables);

            var difference = actualTableNames.Except(zipStreamProcesser.TableNames);
            fail +=  CheckEmpty("Local Tables that have no Master Data CSV File:\n{0}", difference);

            difference = zipStreamProcesser.TableNames.Except(actualTableNames);
            fail += CheckEmpty("Master Data CSV Files without Local Tables:\n {0}", difference);

            Assert.IsTrue(fail == 0, "\n\nOne or more errors occurred");
        }
示例#3
0
        public static List<QualityProfileItem> GetDefaultQualities(params Quality[] allowed)
        {
            var qualities = new List<Quality>
            {
                Quality.SDTV,
                Quality.WEBDL480p,
                Quality.DVD,
                Quality.HDTV720p,
                Quality.HDTV1080p,
                Quality.RAWHD,
                Quality.WEBDL720p,
                Quality.Bluray720p,
                Quality.WEBDL1080p,
                Quality.Bluray1080p
            };

            if (allowed.Length == 0)
                allowed = qualities.ToArray();

            var items = qualities
                .Except(allowed)
                .Concat(allowed)
                .Select(v => new QualityProfileItem { Quality = v, Allowed = allowed.Contains(v) }).ToList();

            return items;
        }
示例#4
0
        public void AllPropertyNames()
        {
            List<string> propertyNames = new List<string>();
            List<string> excludedNames = new List<string>();
            foreach (var file in Directory.EnumerateFiles(Path.GetFullPath(RelativePathToSchemaDir)))
            {
                if (!file.EndsWith("schema.json"))
                {
                    continue;
                }

                var contents = ReadContents(file);
                var reader = new JsonTextReader(new StringReader(contents));
                while (reader.Read())
                {
                    if (reader.TokenType != JsonToken.PropertyName) continue;
                    propertyNames.Add((string)reader.Value);
                }

                var result = JsonConvert.DeserializeObject<Schema>(contents);
                if (result.Properties != null)
                {
                    foreach (var key in result.Properties.Keys)
                    {
                        excludedNames.Add(key.ToLower());
                    }
                }
            }
            propertyNames = propertyNames.Select((p) => p.ToLower()).Distinct().ToList();
            var knownPropertyNames = typeof (Schema).GetProperties().Select((p) => p.Name.ToLower());
            propertyNames = propertyNames.Except(knownPropertyNames).Except(excludedNames)
                .Except(new[] { "$schema", "__ref__", "additionalproperties", "gltf_webgl", "gltf_detaileddescription", "gltf_enumnames", "gltf_uritype" }).ToList();
            
            CollectionAssert.AreEquivalent(new string[] {}, propertyNames);
        }
 public void given_a_string_constructs_a_correct_PackageNode(string input, string package,
     List<string> dependencies)
 {
     PackageDefinition packageDef = new PackageDefinition(input);
     Assert.AreEqual(packageDef.Package, package);
     Assert.IsFalse(dependencies.Except(packageDef.Dependencies).Any());
     Assert.IsFalse(packageDef.Dependencies.Except(dependencies).Any());
 }
 public void LogicEqualityComparerLinqExcept()
 {
     var people = new List<Person>() { _abe, _joe1, _sue, _joe2 };
     var peopleWhoAreJoe = new List<Person>() { _joe1 };
     var comparer = new LogicEqualityComparer<Person>();
     var peopleWhoAreNotJoe = people.Except(peopleWhoAreJoe, comparer);
     Assert.IsTrue(peopleWhoAreNotJoe.Count() == 2);
     Assert.IsFalse(peopleWhoAreNotJoe.Where(p => p.Name == "Joe").Any());
 }
示例#7
0
        public void Subset()
        {
            var a = new List<int> { 1, 2, 3 };
            var b = new List<int> { 1, 2, 5, 3, 4, 3, 6 };

            var result = !a.Except(b).Any();

            Assert.IsTrue(result);
        }
 public void LogicEqualityComparerDeepLinqExcept()
 {
     var group1 = new KeyValuePair<string, List<Person>>("People", new List<Person>() { _abe });
     var group2 = new KeyValuePair<string, List<Person>>("People", new List<Person>() { _sue });
     var groups = new List<KeyValuePair<string, List<Person>>>() { group1, group2 };
     var groupsWithJoe = new List<KeyValuePair<string, List<Person>>>() { group1 };
     var groupsWithoutJoe = groups.Except(groupsWithJoe, _typedComparer);
     Assert.IsTrue(groupsWithoutJoe.Count() == 1);
     Assert.IsTrue(groupsWithoutJoe.First().Value.First().Name == "Sue");
 }
        public void ShouldNotFinishUntilAllMatchesPlayed()
        {
            var leagueSeason = A.LeagueSeason.Build();

            var fixtures = new List<Fixture>();
            leagueSeason.ScheduleFixtures(f => fixtures.Add(f));

            var allFixturesExceptLast = fixtures.Except(fixtures.Last().AsEnumerable()).ToList();
            allFixturesExceptLast.ForEach(f => leagueSeason.ApplyResult(A.MatchResult.ForFixture(f).Build()));

            Assert.That(leagueSeason.IsFinished, Is.False);
        }
示例#10
0
        public void Difference()
        {
            var a = new List<int> { 1, 2, 3 };
            var b = new List<int> { 1, 2, 3, 4, 5, 6 };

            var results = b.Except(a).ToList();

            Assert.AreEqual(3, results.Count());
            Assert.AreEqual(4, results[0]);
            Assert.AreEqual(5, results[1]);
            Assert.AreEqual(6, results[2]);
        }
示例#11
0
        public void Categories_That_Do_Not_Have_Certain_Products()
        {
            List<int> prod = new List<int>() { 1, 2 };

            var expected = "[{\"CategoryID\":2},{\"CategoryID\":3},{\"CategoryID\":4},{\"CategoryID\":5},{\"CategoryID\":6},{\"CategoryID\":7},{\"CategoryID\":8}]";

            ICorrectness result = this.tester.TestQuery(
                context =>
                    from
                        cat in context.Categories
                    where
                        prod.Except(cat.Products.Select(x => x.ProductID))
                            .Count() > 0
                    select
                        cat.CategoryID,
                expected);

            Assert.IsTrue(result.Check());
        }
        public void RandomShufflerShouldNotChangeReffernceTypeListContentOtherThanOrder()
        {
            const int listSize = 4;
            var list = new List<string>()
            {
                "This",
                "is",
                "a",
                "Test"
            };
            var listClone = new List<string>(list);
            ListRandomShuffler.InPlaceShuffle(list);

            var dupCount = list.Intersect(listClone).ToList().Count;
            Assert.AreEqual(dupCount, listSize);

            bool hasDifference = list.Except(listClone).ToList().Any();
            Assert.IsFalse(hasDifference);
        }
示例#13
0
        public void CanCompareOldIdsWithNewIdsAndReturnNewIdsOnly()
        {
            // Arrange
            const int expectedNewId = 12345;

            var oldIds = new List<int> { 123, 1234, 123456, 1233 };
            var newIds = new List<int> { 123, 1234, expectedNewId };

            // Act
            var mergedIds = new List<int>();
            mergedIds.AddRange(oldIds);
            mergedIds.AddRange(newIds);

            IList<int> except = mergedIds.Except(oldIds).ToList();

            // Assert
            Assert.That(except, Is.Not.Null);
            Assert.That(except.Count(), Is.EqualTo(1));
            Assert.That(except.SingleOrDefault(), Is.EqualTo(expectedNewId));
        }
示例#14
0
文件: Test.cs 项目: zurabbat/Bilingi
        public void StringebisShedareba()
        {
            var l1 = new List<string>(){"a", "b", "c", "d", "f"};
            var l2 = new List<string>(){"d", "c","b"};
            List<string> lNew = l1.Except(l2, StringComparer.OrdinalIgnoreCase).ToList();

            Console.WriteLine(lNew.Count);
            //Intersect saertoebi, Except - gansxvaveba
            foreach (var variable in lNew)
            {
                Console.WriteLine(variable);
            }

            Console.WriteLine(" **************************** ");
            lNew.Remove("f");
            foreach (var variable in lNew)
            {
                Console.WriteLine(variable);
            }
        }
        public void The_dependencies_should_include_referenced_complex_types_and_groups()
        {
            RelationshipsSchemaVisitor visitor = new RelationshipsSchemaVisitor(_schemaSet);
            visitor.Visit(_schema);

            List<Edge<string>> expectedList = new List<Edge<string>>
                                                  {
                                                      new Edge<string>("equity", "EquityAsset"),
                                                      new Edge<string>("EquityAsset", "ExchangeTraded"),
                                                      new Edge<string>("ExchangeTraded", "UnderlyingAsset"),
                                                      new Edge<string>("UnderlyingAsset", "IdentifiedAsset"),
                                                      new Edge<string>("IdentifiedAsset", "Asset"),
                                                      new Edge<string>("ExchangeTraded", "ExchangeIdentifier.model"),
                                                      new Edge<string>("equity", "underlyingAsset"),
                                                      new Edge<string>("underlyingAsset", "Asset"),
                                                  };

            var missingEdges = expectedList.Except(visitor.NodeEdges);
            Assert.That(visitor.NodeEdges, Is.EquivalentTo(expectedList));
        }
示例#16
0
        public void RemoveStringArray()
        {
            var l1 = new List<string>() { "a", "b", "c", "d", "f" };
            var l2 = new List<string>() { "d", "c", "b" };
            List<string> lNew = l1.Except(l2, StringComparer.OrdinalIgnoreCase).ToList();

            Console.WriteLine(" L1 List ");
            foreach (var variable in l1)
            {
                Console.WriteLine(variable);
            }

            Console.WriteLine(" L2 List ");
            foreach (var variable in l2)
            {
                Console.WriteLine(variable);
            }

            Console.WriteLine(lNew.Count);

            //Intersect saertoebi, Except - gansxvaveba
        }
示例#17
0
        public void PostUrls_Test()
        {
            List<Uri> expected = new List<Uri>
            {
                new Uri("http://i.imgur.com/gzM4d.jpg"),
                new Uri("http://i.imgur.com/RJPpg.jpg"),
                new Uri("http://i.imgur.com/lGlYd.jpg"),
                new Uri("http://imgur.com/eLsOC"),
                new Uri("http://i.imgur.com/ij8aD.jpg?1"),
                new Uri("http://i.imgur.com/chpyk.jpg"),
                new Uri("http://imgur.com/a34aG"),
                new Uri("http://i.imgur.com/bAHVs.jpg"),
                new Uri("http://imgur.com/t1gcK"),
                new Uri("http://imgur.com/ahOMq"),
                new Uri("http://imgur.com/zUtRh"),
                new Uri("http://i.imgur.com/EVsxY.jpg"),
                new Uri("http://i.imgur.com/fDD72.jpg"),
                new Uri("http://i.imgur.com/CTPoN.jpg"),
                new Uri("http://i.imgur.com/CcRhZ.jpg"),
                new Uri("http://i.imgur.com/exLxs.jpg"),
                new Uri("http://www.imgur.com/Uhwxp.jpeg"),
                new Uri("http://imgur.com/R5uRE"),
                new Uri("http://i.imgur.com/Xo9Nv.jpg"),
                new Uri("http://i.imgur.com/BrOi4.jpg"),
                new Uri("http://www.flickr.com/photos/t_funk/7303497392/"),
                new Uri("http://imgur.com/6f1Hs"),
                new Uri("http://imgur.com/nNSpv"),
                new Uri("http://i.imgur.com/sn4DM.jpg"),
                new Uri("http://i.imgur.com/ckfR4.jpg")
            };

            string sampleRedditPageJson = Resources.redditsamplepage;

            var page = new RedditPage(sampleRedditPageJson);
            var actual = page.PostUrls;

            var differenceQuery = expected.Except(actual);
            Assert.AreEqual(differenceQuery.Count(), 0);
        }
示例#18
0
        public void ExceptWithComparerQueryReuse()
        {
            List<int> first = new List<int> { 1, 2, 3 };
            List<int> second = new List<int> { 3, 5, 6 };
            IEnumerable<int> enumerable = first.Except(second, EqualityComparer<int>.Default);

            enumerable.AssertEqual(1, 2);

            first.Add(4);
            second.Add(2);
            enumerable.AssertEqual(1, 4);
        }
示例#19
0
        public async void ProducerAndListenerRecoveryTest()
        {
            kafka4net.Tracing.EtwTrace.Marker("ProducerAndListenerRecoveryTest");
            const int count = 200;
            var topic = "part33." + _rnd.Next();
            VagrantBrokerUtil.CreateTopic(topic,6,3);

            var producer = new Producer(_seed2Addresses, new ProducerConfiguration(topic));

            _log.Debug("Connecting");
            await producer.ConnectAsync();

            _log.Debug("Filling out {0}", topic);
            var sentList = new List<int>(200);
            Observable.Interval(TimeSpan.FromMilliseconds(100))
                .Select(l => (int) l)
                .Select(i => new Message {Value = BitConverter.GetBytes(i)})
                .Take(count)
                .Subscribe(msg=> { producer.Send(msg); sentList.Add(BitConverter.ToInt32(msg.Value, 0)); });

            var consumer = new Consumer(new ConsumerConfiguration(_seed2Addresses, topic, new StartPositionTopicStart(), maxBytesPerFetch: 4 * 8));
            var current =0;
            var received = new ReplaySubject<ReceivedMessage>();
            Task brokerStopped = null;
            var consumerSubscription = consumer.OnMessageArrived.
                Subscribe(async msg => {
                    current++;
                    if (current == 18)
                    {
                        brokerStopped = Task.Factory.StartNew(() => VagrantBrokerUtil.StopBrokerLeaderForPartition(consumer.Cluster, consumer.Topic, msg.Partition), CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default);
                        _log.Info("Stopped Broker Leader {0}",brokerStopped);
                    }
                    received.OnNext(msg);
                    _log.Info("Got: {0}", BitConverter.ToInt32(msg.Value, 0));
                });
            await consumer.IsConnected;

            _log.Info("Waiting for receiver complete");
            var receivedList = await received.Select(msg => BitConverter.ToInt32(msg.Value, 0)).Take(count).TakeUntil(DateTime.Now.AddSeconds(60)).ToList().ToTask();

            await brokerStopped.TimeoutAfter(TimeSpan.FromSeconds(10));

            // get the offsets for comparison later
            var heads = await consumer.Cluster.FetchPartitionOffsetsAsync(topic, ConsumerLocation.TopicStart);
            var tails = await consumer.Cluster.FetchPartitionOffsetsAsync(topic, ConsumerLocation.TopicEnd);

            _log.Info("Done waiting for receiver. Closing producer.");
            await producer.CloseAsync(TimeSpan.FromSeconds(5));
            _log.Info("Producer closed, disposing consumer subscription.");
            consumerSubscription.Dispose();
            _log.Info("Consumer subscription disposed. Closing consumer.");
            consumer.Dispose();
            _log.Info("Consumer closed.");

            if (sentList.Count != receivedList.Count)
            {
                // log some debug info.
                _log.Error("Did not receive all messages. Messages received: {0}",string.Join(",",receivedList.OrderBy(i=>i)));
                _log.Error("Did not receive all messages. Messages sent but NOT received: {0}", string.Join(",", sentList.Except(receivedList).OrderBy(i => i)));

                _log.Error("Sum of offsets fetched: {0}", tails.MessagesSince(heads));
                _log.Error("Offsets fetched: [{0}]", string.Join(",", tails.Partitions.Select(p => string.Format("{0}:{1}",p,tails.NextOffset(p)))));
            }

            Assert.AreEqual(sentList.Count, receivedList.Count);
            kafka4net.Tracing.EtwTrace.Marker("/ProducerAndListenerRecoveryTest");
        }
示例#20
0
        public async void LeaderDownProducerAndConsumerRecovery()
        {
            kafka4net.Tracing.EtwTrace.Marker("LeaderDownProducerAndConsumerRecovery");
            string topic = "part32." + _rnd.Next();
            VagrantBrokerUtil.CreateTopic(topic, 3, 2);

            var sent = new List<string>();
            var confirmedSent1 = new List<string>();

            var producer = new Producer(_seed2Addresses, new ProducerConfiguration(topic));
            producer.OnSuccess += msgs =>
            {
                msgs.ForEach(msg => confirmedSent1.Add(Encoding.UTF8.GetString(msg.Value)));
                _log.Debug("Sent {0} messages", msgs.Length);
            };
            await producer.ConnectAsync();

            var consumer = new Consumer(new ConsumerConfiguration(_seed2Addresses, topic, new StartPositionTopicEnd()));

            const int postCount = 100;
            const int postCount2 = 50;

            //
            // Read messages
            //
            var received = new List<ReceivedMessage>();
            var receivedEvents = new ReplaySubject<ReceivedMessage>();
            var consumerSubscription = consumer.OnMessageArrived.
                Synchronize().
                Subscribe(msg =>
                {
                    received.Add(msg);
                    receivedEvents.OnNext(msg);
                    _log.Debug("Received {0}/{1}", Encoding.UTF8.GetString(msg.Value), received.Count);
                });
            await consumer.IsConnected;

            //
            // Send #1
            //
            _log.Info("Start sender");
            Observable.Interval(TimeSpan.FromMilliseconds(200)).
                Take(postCount).
                Subscribe(
                    i => {
                        var msg = "msg " + i;
                        producer.Send(new Message { Value = Encoding.UTF8.GetBytes(msg) });
                        sent.Add("msg " + i);
                    },
                    () => _log.Info("Producer complete")
                );

            // wait for first 50 messages to arrive
            _log.Info("Waiting for first {0} messages to arrive", postCount2);
            await receivedEvents.Take(postCount2).Count().ToTask();
            Assert.AreEqual(postCount2, received.Count);

            _log.Info("Stopping broker");
            var stoppedBroker = VagrantBrokerUtil.StopBrokerLeaderForPartition(producer.Cluster, topic, 0);
            _log.Debug("Stopped broker {0}", stoppedBroker);

            // post another 50 messages
            _log.Info("Sending another {0} messages", postCount2);
            var sender2 = Observable.Interval(TimeSpan.FromMilliseconds(200)).
                Take(postCount2).
                Publish().RefCount();

            //
            // Send #2
            //
            sender2.Subscribe(
                    i => {
                        var msg = "msg #2 " + i;
                        producer.Send(new Message { Value = Encoding.UTF8.GetBytes(msg) });
                        sent.Add(msg);
                        _log.Debug("Sent msg #2 {0}", i);
                    },
                    () => _log.Info("Producer #2 complete")
                );

            _log.Info("Waiting for #2 sender to complete");
            await sender2.ToTask();
            _log.Info("Waiting for producer.Close");
            await producer.CloseAsync(TimeSpan.FromSeconds(60));

            _log.Info("Waiting 4sec for remaining messages");
            await Task.Delay(TimeSpan.FromSeconds(4)); // if unexpected messages arrive, let them in to detect failure

            _log.Info("Waiting for consumer.CloseAsync");
            consumer.Dispose();
            consumerSubscription.Dispose();

            if (postCount + postCount2 != received.Count)
            {
                var receivedStr = received.Select(m => Encoding.UTF8.GetString(m.Value)).ToArray();

                var diff = sent.Except(received.Select(m => Encoding.UTF8.GetString(m.Value))).OrderBy(s => s);
                _log.Info("Not received {0}: \n {1}", diff.Count(), string.Join("\n ", diff));

                var diff2 = sent.Except(confirmedSent1).OrderBy(s => s);
                _log.Info("Not confirmed {0}: \n {1}", diff2.Count(), string.Join("\n ", diff2));

                var diff3 = received.Select(m => Encoding.UTF8.GetString(m.Value)).Except(sent).OrderBy(s => s);
                _log.Info("Received extra: {0}: \n {1}", diff3.Count(), string.Join("\n ", diff3));

                var diff4 = confirmedSent1.Except(sent).OrderBy(s => s);
                _log.Info("Confirmed extra {0}: \n {1}", diff4.Count(), string.Join("\n ", diff4));

                var dups = receivedStr.GroupBy(s => s).Where(g => g.Count() > 1).Select(g => string.Format("{0}: {1}", g.Count(), g.Key));
                _log.Info("Receved dups: \n {0}", string.Join("\n ", dups));

                _log.Debug("Received: \n{0}", string.Join("\n ", received.Select(m => Encoding.UTF8.GetString(m.Value))));
            }
            Assert.AreEqual(postCount + postCount2, received.Count, "Received.Count");

            _log.Info("Done");
            kafka4net.Tracing.EtwTrace.Marker("/LeaderDownProducerAndConsumerRecovery");
        }
 private bool ContainsAllItems(IList<string> firstList, List<string> secondList)
 {
     return !secondList.Except(firstList).Any();
 }
        private static void AssertThatResultContainsAllKeys(RiakResult<RiakMapReduceResult> mapReduceResult)
        {
            var phaseResults = mapReduceResult.Value.PhaseResults.ToList();
            phaseResults.Count.ShouldEqual(1);

            var searchResults = phaseResults[0];
            searchResults.Values.ShouldNotBeNull();
            searchResults.Values.Count.ShouldEqual(2);

            var allKeys = new List<string> { HackerKey, PublicKey };
            var solrResults = searchResults.Values.Select(searchResult => searchResult.FromRiakString());

            var usedKeys = solrResults.SelectMany(result => allKeys.Where(result.Contains));
            var unusedKeys = allKeys.Except(usedKeys).ToList();

            Assert.AreEqual(0, unusedKeys.Count, "Results did not contain the following keys: {0}",
                string.Join(", ", allKeys));
        }
示例#23
0
        public void Can_guarantee_random_nonces_in_succession_multithreaded()
        {
            const int threads = 16;
            const int totalNonces = 30000;
            const int noncesPerThread = totalNonces / threads;
            var nonces = new List<string>();
            var noncesLock = new object();
            var dupes = new List<string>();
            var dupesLock = new object();
            var sem = new Semaphore(0, threads);
            var ts = new ThreadStart(() =>
                                         {
                                             sem.WaitOne();
                                             try
                                             {
                                                 var localNonces = new List<string>();
                                                 for (var i = 0; i < noncesPerThread; i++)
                                                 {
                                                     var nonce = OAuthTools.GetNonce();
                                                     localNonces.Add(nonce);
                                                 }
                                                 lock (nonces)
                                                 {
                                                     var localDupes = from s in nonces 
                                                                      where localNonces.Contains(s) 
                                                                      select s;
                                                     if (localDupes.Any())
                                                     {
                                                         lock(dupesLock)
                                                         {
                                                             dupes.AddRange(localDupes);
                                                         }
                                                     }
                                                     nonces.AddRange(localNonces.Except(localDupes));
                                                 }
                                             }
                                             finally
                                             {
                                                 sem.Release();
                                             }
                                         });
            var workerThreads = new Thread[threads];
            for (var i = 0; i < threads; i++)
            {
                workerThreads[i] = new Thread(ts) { IsBackground = false, Name = "thread" + i };
                workerThreads[i].Start();
            }

            sem.Release(threads);
            foreach (var t in workerThreads)
            {
                t.Join();
            }
            Assert.IsEmpty(dupes, "Found {0} duplicated nonces generated during test", dupes.Count);
            lock (noncesLock)
            {
                Assert.AreEqual(totalNonces, nonces.Count);
            }
        }
示例#24
0
        public void ExceptQueryReuse()
        {
            List<int> first = new List<int> { 1, 2, 3 };
            List<int> second = new List<int> { 3, 5, 6 };
            IEnumerable<int> enumerable = first.Except(second);

            enumerable.AssertEqual(1, 2);

            first.Add(4);
            second.Add(2);
            enumerable.AssertEqual(1, 4);
        }
示例#25
0
			public void Complex_Collection_Assign_InternalReferences()
			{
			    var xml = Xml("<Foo $x/>");
			    var foo = Create<IFoo>(xml);

			    var a = Create<IFoo>(); a.Value = "a";
			    var b = Create<IFoo>();	b.Value = "b";
			    var c = Create<IFoo>();	c.Value = "c";

				var list = new List<IFoo> { a, b, c };

				foreach (var x in list)
				{
					x.Set = new HashSet<IFoo>(list.Except(Enumerable.Repeat(x, 1)));
				}

				foo.List = list;

				//a  .Set  = new HashSet<IFoo> {    b, c };
				//b  .Set  = new HashSet<IFoo> { a,    c }; // no effect, due to order of operations
				//c  .Set  = new HashSet<IFoo> { a, b    }; // no effect, due to order of operations
				//foo.List = new List   <IFoo> { a, b, c };

			    Assert.That(xml, XmlEquivalent.To(Xml(
			        "<Foo $x>",
			            "<List>",
			                "<Foo>",
			                    "<Value>a</Value>",
			                    "<Set>",
			                        "<Foo x:id='1'> <Value>b</Value> </Foo>",
									"<Foo x:id='2'> <Value>c</Value> </Foo>",
			                    "</Set>",
			                "</Foo>",
			                "<Foo x:ref='1'/>",
			                "<Foo x:ref='2'/>",
			            "</List>",
			        "</Foo>"
			    )));

				Assert.That(foo.List,                Is.Not.Null & Has.Count.EqualTo(3));
				Assert.That(foo.List[0].Set,         Is.Not.Null & Has.Count.EqualTo(2));
				Assert.That(foo.List[0].Set.Contains(foo.List[1]), Is.True);
				Assert.That(foo.List[0].Set.Contains(foo.List[2]), Is.True);
				Assert.That(foo.List[0].Set.Contains(foo),         Is.False);
			}
示例#26
0
        private void DirectoryWalkerHarness(Action<FileSystemInfo> action, List<String> expected, List<String> actual)
        {
            var exceptions = FileUtils.DirectoryWalker(_testFilesPath, action, FileSystemTypes.All, DirectoryWalkerErrorHandling.Accumulate);

              if (exceptions.Any())
              {
            var messages = String.Join(Environment.NewLine, exceptions.Select(ex => ex.Message));
            throw new Exception(messages);
              }
              else
              {
            Assert.IsTrue(!expected.Except(actual).Any());
              }
        }
示例#27
0
        public void PinImageUrlsTest()
        {
            List<Uri> expected = new List<Uri>
            {
                new Uri("http://media-cache-lt0.pinterest.com/upload/251286854177953342_8JhnoMC6_f.jpg"),
                new Uri("http://media-cache0.pinterest.com/upload/265571709246843002_B4WPNnUC_f.jpg"),
                new Uri("http://media-cache-ec5.pinterest.com/upload/218495019392755281_32uBAZ70_f.jpg"),
                new Uri("http://media-cache-ec2.pinterest.com/upload/210543351300567476_mgqLsVTI_f.jpg"),
                new Uri("http://media-cache-ec3.pinterest.com/upload/254523816410114620_ksYiV5q0_f.jpg"),
                new Uri("http://media-cache-ec5.pinterest.com/upload/229120699761953489_FbaprerB_f.jpg"),
                new Uri("http://media-cache-ec6.pinterest.com/upload/231161393343358413_QZ2Sd0vA_f.jpg"),
                new Uri("http://media-cache-ec3.pinterest.com/upload/250020216784426937_AHYzpAWt_f.jpg"),
                new Uri("http://media-cache-ec3.pinterest.com/upload/222646775298781559_Lj456pGy_f.jpg"),
                new Uri("http://media-cache-ec3.pinterest.com/upload/227080006181493479_BvTt4xY9_f.jpg"),
                new Uri("http://media-cache-ec2.pinterest.com/upload/198088083580855560_mYcwCcti_f.jpg"),
                new Uri("http://media-cache0.pinterest.com/upload/276338127106868484_CxSIzcKh_f.jpg"),
                new Uri("http://media-cache-ec3.pinterest.com/upload/186125397070353211_ou6kfH6W_f.jpg"),
                new Uri("http://media-cache-ec2.pinterest.com/upload/79164905919618394_lieNXoZS_f.jpg"),
                new Uri("http://media-cache-ec2.pinterest.com/upload/23573598020718911_2he0xPCI_f.jpg"),
                new Uri("http://media-cache0.pinterest.com/upload/236298311669434276_LxZoH8bD_f.jpg"),
                new Uri("http://media-cache-ec2.pinterest.com/upload/263460646921476246_MBd4rahH_f.jpg"),
                new Uri("http://media-cache-lt0.pinterest.com/upload/119556565077929075_1OOYyH3e_f.jpg"),
                new Uri("http://media-cache-ec6.pinterest.com/upload/27584616438676939_OBqBPrjx_f.jpg"),
                new Uri("http://media-cache-ec2.pinterest.com/upload/67483694386041825_Qcixqf9z_f.jpg"),
                new Uri("http://media-cache-ec2.pinterest.com/upload/18225573461957465_eum0ttIs_f.jpg"),
                new Uri("http://media-cache-ec2.pinterest.com/upload/90564642476202918_HeuOwioG_f.jpg"),
                new Uri("http://media-cache-ec5.pinterest.com/upload/83527768058469460_4obfCiKm_f.jpg"),
                new Uri("http://media-cache-ec3.pinterest.com/upload/22447698113564407_ScFF9YEE_f.jpg"),
                new Uri("http://media-cache-ec4.pinterest.com/upload/17803360996481638_IcwF0u5h_f.jpg"),
                new Uri("http://media-cache-ec6.pinterest.com/upload/227713324878970695_IreO4d9s_f.jpg"),
                new Uri("http://media-cache-ec4.pinterest.com/upload/215609900879855586_kXFMRgi3_f.jpg"),
                new Uri("http://media-cache-lt0.pinterest.com/upload/166492517445650419_FMxyPo1W_f.jpg"),
                new Uri("http://media-cache-ec5.pinterest.com/upload/139611657168665335_rTyYxWMp_f.jpg"),
                new Uri("http://media-cache-ec5.pinterest.com/upload/264093965619553206_GWGpBKiC_f.jpg"),
                new Uri("http://media-cache-ec2.pinterest.com/upload/118923246379853870_ZVs2xSpE_f.jpg"),
                new Uri("http://media-cache-ec6.pinterest.com/upload/201395414556781404_xav17l3h_f.jpg"),
                new Uri("http://media-cache-ec3.pinterest.com/upload/218424650647505418_re3IYohF_f.jpg"),
                new Uri("http://media-cache0.pinterest.com/upload/170362798374312177_v5FWhDCA_f.jpg"),
                new Uri("http://media-cache-lt0.pinterest.com/upload/173036810653158012_amGHoap0_f.jpg"),
                new Uri("http://media-cache-lt0.pinterest.com/upload/58828338853737264_F94k6WQM_f.jpg"),
                new Uri("http://media-cache-ec5.pinterest.com/upload/24699497927339150_0A8jcu36_f.jpg"),
                new Uri("http://media-cache-lt0.pinterest.com/upload/226587424971588897_KTJKzFkh_f.jpg"),
                new Uri("http://media-cache-ec6.pinterest.com/upload/147000375307337546_OELiwxBm_f.jpg"),
                new Uri("http://media-cache-ec6.pinterest.com/upload/30469734948424142_bXFn4oXj_f.jpg"),
                new Uri("http://media-cache-ec2.pinterest.com/upload/21110691973619968_AgIt8M8R_f.jpg"),
                new Uri("http://media-cache-ec4.pinterest.com/upload/218987600601003362_d6xPGpPf_f.jpg"),
                new Uri("http://media-cache-lt0.pinterest.com/upload/178455203954606843_lBhck3aC_f.jpg"),
                new Uri("http://media-cache-ec4.pinterest.com/upload/45387908715370890_8hpqWGrq_f.jpg"),
                new Uri("http://media-cache-ec5.pinterest.com/upload/78179743501731929_PsVgFuES_f.jpg"),
                new Uri("http://media-cache-ec4.pinterest.com/upload/11399805277101990_ujIeqJAw_f.jpg"),
                new Uri("http://media-cache-ec3.pinterest.com/upload/142356038192689977_h0IgKdSQ_f.jpg"),
                new Uri("http://media-cache0.pinterest.com/upload/284993482639035173_vwFVj6Ta_f.jpg"),
                new Uri("http://media-cache-ec3.pinterest.com/upload/257338566178852655_vGB06rz3_f.jpg"),
                new Uri("http://media-cache-lt0.pinterest.com/upload/168040629815881391_Bb1QhkkC_f.jpg")
            };

            string samplePinterestHtml = Resources.pinterestsamplepage;

            var page = new PinterestBoard(samplePinterestHtml);
            var actual = page.PinImageUrls;

            var differenceQuery = expected.Except(actual);
            Assert.AreEqual(differenceQuery.Count(), 0);
        }
示例#28
0
		public void Except_LinqExt ()
		{
			// Except: all of groupOne except where in existance in groupTwo
			var groupOne = new List<int> (){ 1,2,3,4,5};
			var groupTwo = new List<int> (){4,5,6,7};
			var groupExcept = groupOne.Except (groupTwo).OrderBy (x => x);

			Assert.AreEqual (3, groupExcept.Count ());
			Assert.AreEqual (1, groupExcept.First ());
			Assert.AreEqual (3, groupExcept.Last ());
		}
 public IEnumerable<Region> GetRegions()
 {
     var regions = new List<Region> (AddedRegions);
     return regions.Except (RemovedRegions);
 }
示例#30
0
        private int CompareDirectoryWithProjects(List<string> filesToCompile, params string[] projectFiles)
        {
            var filesInProject = new List<string>();
            this.GetCompileItemsFromProjects(filesInProject, projectFiles);

            var missingFiles = filesToCompile.Except(filesInProject).ToList();
            if (missingFiles.Count > 0)
            {
                Console.WriteLine("The following files must be added to {0}", string.Join(";", projectFiles));
                foreach (var f in missingFiles)
                {
                    Console.WriteLine("  {0}", f);
                }
            }

            return missingFiles.Count;
        }