public void Can_get_lots_of_records_with_new_instantiation_every_time_test()
        {
            var times = new List<double>();

            for (int i = 0; i < 40; ++i)
            {
                var sw = Stopwatch.StartNew();
                var dapperDriver = new DapperDriver();
                var rows = dapperDriver.GetLotsOfRecords<TransactionHistory>();

                Assert.That(rows, Is.Not.Null);
                Assert.That(rows.Count(), Is.GreaterThan(0));

                sw.Stop();

                times.Add(sw.ElapsedMilliseconds);
                Console.WriteLine("took {0} ms to get {1} records",
                    sw.ElapsedMilliseconds,
                    rows.Count());
            }

            Console.WriteLine("average: {0}, min: {1}, max: {2}",
                times.Average(),
                times.Min(),
                times.Max());

            var timesSansMinAndMax = new List<double>();
            timesSansMinAndMax.AddRange(times);
            timesSansMinAndMax.Remove(timesSansMinAndMax.Min());
            timesSansMinAndMax.Remove(timesSansMinAndMax.Max());
            Console.WriteLine("average sans min & max: {0}",
                timesSansMinAndMax.Average());
        }
        public void Can_get_few_records_test()
        {
            var efDriver = new EFDriver();
            var times = new List<double>();

            for (int i = 0; i < 100; ++i)
            {
                var sw = Stopwatch.StartNew();
                var rows = efDriver.GetAFewRecords();

                Assert.That(rows, Is.Not.Null);
                Assert.That(rows.Count(), Is.GreaterThan(0));

                sw.Stop();

                times.Add(sw.ElapsedMilliseconds);
                Console.WriteLine("took {0} ms to get {1} records",
                    sw.ElapsedMilliseconds,
                    rows.Count());
            }

            Console.WriteLine("average: {0}, min: {1}, max: {2}, std dev: {3}, median: {4}",
                times.Average(),
                times.Min(),
                times.Max(),
                times.StandardDeviation(),
                times.Median());

            var timesSansMinAndMax = new List<double>();
            timesSansMinAndMax.AddRange(times);
            timesSansMinAndMax.Remove(timesSansMinAndMax.Min());
            timesSansMinAndMax.Remove(timesSansMinAndMax.Max());
            Console.WriteLine("average sans min & max: {0}",
                timesSansMinAndMax.Average());
        }
        public void RemoveWithNullItems()
        {
            ICollection<int> col = new List<int> { 1, 2, 3 };

            col.Remove((int[])null);
            Assert.IsTrue(col.SequenceEqual(new [] { 1, 2, 3 }));
        }
        public void RemoveWithEmptyItems()
        {
            ICollection<int> col = new List<int> { 1, 2, 3 };

            col.Remove(new int[] { });
            Assert.IsTrue(col.SequenceEqual(new [] { 1, 2, 3 }));
        }
        public void RemoveItems()
        {
            ICollection<int> col = new List<int> { 1, 2, 3, 4, 5 };

            col.Remove(new int[] { 2, 4 });
            Assert.IsTrue(col.SequenceEqual(new [] { 1, 3, 5 }));
        }
Beispiel #6
0
        public void NodeIteratorJavaScriptKitDivision()
        {
            var source = @"<div id=contentarea>
<p>Some <span>text</span></p>
<b>Bold text</b>
</div>";
            var doc = Html(source);
            Assert.IsNotNull(doc);

            var rootnode = doc.GetElementById("contentarea");
            Assert.IsNotNull(rootnode);

            var iterator = doc.CreateNodeIterator(rootnode, FilterSettings.Element);
            Assert.IsNotNull(iterator);
            Assert.AreEqual(rootnode, iterator.Root);
            Assert.IsTrue(iterator.IsBeforeReference);

            var results = new List<INode>();

            while (iterator.Next() != null)
                results.Add(iterator.Reference);

            Assert.IsFalse(iterator.IsBeforeReference);
            Assert.AreEqual(3, results.Count);
            Assert.IsInstanceOf<HtmlParagraphElement>(results[0]);
            Assert.IsInstanceOf<HtmlSpanElement>(results[1]);
            Assert.IsInstanceOf<HtmlBoldElement>(results[2]);

            do
                results.Remove(iterator.Reference);
            while (iterator.Previous() != null);

            Assert.IsTrue(iterator.IsBeforeReference);
        }
        public void CheckStringsDeclared()
        {
            var names = new List<string>();
            checker.GetAllResourceReferences(names);
            Assert.Greater(names.Count, 400, "Должно быть много ресурсных строчек");

            // убрать исключения и повторы
            names = names.Distinct().ToList();
            names.Remove("ResourceManager");

            // проверить, есть ли они в файлах ресурсов
            var errorsInFile = new Dictionary<string, List<string>>();
            var resxFileNames = Directory.GetFiles(codeBase + @"\TradeSharp.AdminSite\App_GlobalResources", "*.resx");

            foreach (var resxFileName in resxFileNames)
            {
                var errors = checker.GetNamesLackInResxFile(resxFileName, names);
                if (errors.Count > 0)
                    errorsInFile.Add(Path.GetFileName(resxFileName), errors);
            }

            if (errorsInFile.Count > 0)
            {
                var errorStr = string.Join("\n", errorsInFile.Select(e => e.Key + ": " + string.Join(", ", e.Value)));
                Assert.Fail(errorStr);
            }
        }
        public void SetUp()
        {
            MigrationTestHelper.Clear();
            _versionsFromDatabase = new List<long> { 0 };

            var provider = new Mock<IDataProvider>();
            provider.Setup(x => x.DatabaseKind).Returns(DatabaseKind.Oracle);

            var database = new Mock<IDatabase>();
            database.Setup(x => x.Provider).Returns(provider.Object);

            _dataClient = new Mock<IDataClient>();
            _dataClient.Setup(p => p.TableExists(VersionRepository.VERSION_TABLE_NAME)).Returns(true);
            _dataClient.Setup(x => x.Database).Returns(database.Object);

            _versionRepository = new Mock<IVersionRepository>();
            _versionRepository.Setup(x => x.GetCurrentVersion()).Returns(() => _versionsFromDatabase.Last());
            _versionRepository.Setup(x => x.GetAppliedMigrations()).Returns(() => _versionsFromDatabase);
            _versionRepository.Setup(x => x.InsertVersion(It.IsAny<MigrationInfo>()))
                .Callback<MigrationInfo>(m => _versionsFromDatabase.Add(m.Version));
            _versionRepository.Setup(x => x.RemoveVersion(It.IsAny<MigrationInfo>()))
                .Callback<MigrationInfo>(m => _versionsFromDatabase.Remove(m.Version));

            _runner = new Runner(_dataClient.Object, Assembly.GetExecutingAssembly());
            _runner.VersionRepository = _versionRepository.Object;
        }
Beispiel #9
0
        public void Copy()
        {
            var data = new int[][]
            {
                new int[] { 1, 2, 3 },
                new int[] { 4, 5, 6 },
                new int[] { 7, 8, 9 }
            };

            var original = new List<List<int>>();
            foreach (var row in data)
            {
                original.Add(row.ToList());
            }

            var copy = original.Copy();

            // the copy contains the same items as the original
            // so if you modify the items they are modified in both
            Assert.AreEqual(original[1][1], copy[1][1]);
            original[1][1] = 0;
            Assert.AreEqual(original[1][1], copy[1][1]);

            // if you remove an item in the original list the item
            // is not removed in the copy
            original.Remove(original[2]);
            Assert.AreEqual(2, original.Count());
            Assert.AreEqual(3, copy.Count());

            // if you switch out an item in one copy it does not
            // modify the other copy
            Assert.AreEqual(original[0][0], copy[0][0]);
            original[0] = data[2].ToList();
            Assert.IsFalse(original[0][0] == copy[0][0]);
        }
        public void Can_Delete_from_basic_persistence_provider()
        {
            using (var db = ConnectionString.OpenDbConnection())
            using (var dbCmd = db.CreateCommand())
            {
                dbCmd.CreateTable<ModelWithFieldsOfDifferentTypes>(true);

                var basicProvider = new OrmLitePersistenceProvider(db);

                var rowIds = new List<int> { 1, 2, 3, 4, 5 };

                var rows = rowIds.ConvertAll(x => ModelWithFieldsOfDifferentTypes.Create(x));

                rows.ForEach(x => dbCmd.Insert(x));

                var deleteRowIds = new List<int> { 2, 4 };

                foreach (var row in rows)
                {
                    if (deleteRowIds.Contains(row.Id))
                    {
                        basicProvider.Delete(row);
                    }
                }

                var providerRows = basicProvider.GetByIds<ModelWithFieldsOfDifferentTypes>(rowIds).ToList();
                var providerRowIds = providerRows.ConvertAll(x => x.Id);

                var remainingIds = new List<int>(rowIds);
                deleteRowIds.ForEach(x => remainingIds.Remove(x));

                Assert.That(providerRowIds, Is.EquivalentTo(remainingIds));
            }
        }
        public async Task It_notifies_about_removing_an_entry()
        {
            var fakeSchedule = new FakeSchedule();
            var entries = new List<Entry>();
            var fakeBackplane = new FakeBackplane("A", entries);
            var otherBackplane = new FakeBackplane("B", entries);

            var client = new DataBackplaneClient(fakeBackplane, fakeSchedule);
            await client.Start();
            var readValues = new List<string>();
            var subscription = await client.GetAllAndSubscribeToChanges("T1", entry =>
            {
                readValues.Add(entry.Data);
                return Task.FromResult(0);
            }, entry =>
            {
                readValues.Remove(entry.Data);
                return Task.FromResult(0);
            });

            await otherBackplane.Publish("T1", "B");
            await fakeSchedule.TriggerQuery();
            CollectionAssert.Contains(readValues, "B");

            await otherBackplane.Revoke("T1");
            await fakeSchedule.TriggerQuery();
            CollectionAssert.DoesNotContain(readValues, "B");
            subscription.Unsubscribe();
        }
        public void GalleriesEditComplexTest()
        {
            Flickr.CacheDisabled = true;
            Flickr.FlushCache();

            string primaryPhotoId = "486875512";
            string comment = "You don't get much better than this for the best Entrance to Hell.\n\n" + DateTime.Now.ToString();
            string galleryId = "78188-72157622589312064";

            Flickr f = TestData.GetAuthInstance();

            // Get photos
            var photos = f.GalleriesGetPhotos(galleryId);

            List<string> photoIds = new List<string>();
            foreach (var p in photos) photoIds.Add(p.PhotoId);

            // Remove the last one.
            GalleryPhoto photo = photos[photos.Count - 1];
            photoIds.Remove(photo.PhotoId);

            // Update the gallery
            f.GalleriesEditPhotos(galleryId, primaryPhotoId, photoIds);

            // Check removed photo no longer returned.
            var photos2 = f.GalleriesGetPhotos(galleryId);

            Assert.AreEqual(photos.Count - 1, photos2.Count, "Should be one less photo.");

            bool found = false;
            foreach (var p in photos2)
            {
                if (p.PhotoId == photo.PhotoId)
                {
                    found = true;
                    break;
                }
            }
            Assert.IsFalse(false, "Should not have found the photo in the gallery.");

            // Add photo back in
            f.GalleriesAddPhoto(galleryId, photo.PhotoId, photo.Comment);

            var photos3 = f.GalleriesGetPhotos(galleryId);
            Assert.AreEqual(photos.Count, photos3.Count, "Count should match now photo added back in.");

            found = false;
            foreach (var p in photos3)
            {
                if (p.PhotoId == photo.PhotoId)
                {
                    Assert.AreEqual(photo.Comment, p.Comment, "Comment should have been updated.");
                    found = true;
                    break;
                }
            }

            Assert.IsTrue(found, "Should have found the photo in the gallery.");
        }
        public void Remove_with_predicate_empty_list()
        {
            List<int> list = new List<int>();

            list.Remove(i => false);

            Assert.AreEqual(0, list.Count);
        }
        public void ConstructorGivenAnEnumerableCopiesIt()
        {
            var list = new List<int> { 1, 2, 3 };
            var observableList = new ObservableList<int>(list.AsEnumerable()) { 4 };
            list.Remove(1);

            Assert.AreEqual(4, observableList.Count);
            Assert.AreEqual(2, list.Count);
        }
Beispiel #15
0
 public void DropAItem()
 {
     var weakBlade = new LongSword();
     var it = new List<IItems>();
     
     it.Remove(weakBlade);
     
     Assert.That(!it.Any(x => string.Equals("Longsword", x.Name)));
 }
 public void ExcluirPessoaFisicaTest()
 {
     var lista = new List<Fisica>();
        _pessoaFisica = new Fisica { Nome = "Glebson Lima", CPF = "871.852.323/02", Email = "*****@*****.**", Idade = 30, Sexo = char.Parse("m") };
        _pessoaFisica.AdicionarTelefone(new Guid(), "Celular", 021, 52859563);
        lista.Remove(_pessoaFisica);
        var esperado = lista;
        Telefone atual = _pessoaFisica.Telefones.FirstOrDefault(tel => tel.Numero == 52859563);
        Assert.AreNotEqual(atual, esperado);
 }
Beispiel #17
0
		private static void AssertArraysAreEqualUnsorted(object[] expected, object[] actual)
		{
			Assert.AreEqual(expected.Length, actual.Length);
			List<object> actualAsList = new List<object>(actual);
			foreach (object expectedElement in expected)
			{
				Assert.Contains(expectedElement, actualAsList);
				actualAsList.Remove(expectedElement);
				// need to remove the element after it has been found to guarantee that duplicate elements are handled correctly
			}
		}
		public void Sign() {
			Association assoc1 = HmacShaAssociation.Create(Protocol.Default, Protocol.Default.Args.SignatureAlgorithm.HMAC_SHA1,
				"h1", sha1Secret, TimeSpan.FromMinutes(2));
			Association assoc2 = HmacShaAssociation.Create(Protocol.Default, Protocol.Default.Args.SignatureAlgorithm.HMAC_SHA1,
				"h2", sha1Secret2, TimeSpan.FromMinutes(2));

			var dict = new Dictionary<string, string>();
			dict.Add("a", "b");
			dict.Add("c", "d");
			var keys = new List<string>();
			keys.Add("a");
			keys.Add("c");

			// sign once and verify that it's sane
			byte[] signature1 = assoc1.Sign(dict, keys);
			Assert.IsNotNull(signature1);
			Assert.AreNotEqual(0, signature1.Length);

			// sign again and make sure it's different
			byte[] signature2 = assoc2.Sign(dict, keys);
			Assert.IsNotNull(signature2);
			Assert.AreNotEqual(0, signature2.Length);
			Assert.IsFalse(Util.ArrayEquals(signature1, signature2));

			// sign again with the same secret and make sure it's the same.
			Assert.IsTrue(Util.ArrayEquals(signature1, assoc1.Sign(dict, keys)));

			// now add data and make sure signature changes
			dict.Add("g", "h");
			keys.Add("g");
			Assert.IsFalse(Util.ArrayEquals(signature1, assoc1.Sign(dict, keys)));

			// now change existing data.
			dict.Remove("g");
			keys.Remove("g");
			dict["c"] = "e";
			Assert.IsFalse(Util.ArrayEquals(signature1, assoc1.Sign(dict, keys)));
			dict.Remove("c");
			keys.Remove("c");
			Assert.IsFalse(Util.ArrayEquals(signature1, assoc1.Sign(dict, keys)));
		}
Beispiel #19
0
		public void MakefileSynchronization ()
		{
			if (Platform.IsWindows)
				Assert.Ignore ();

			string solFile = Util.GetSampleProject ("console-project-with-makefile", "ConsoleProject.sln");
			Solution sol = (Solution) Services.ProjectService.ReadWorkspaceItem (Util.GetMonitor (), solFile);
			
			DotNetProject p = (DotNetProject) sol.Items [0];
			
			Assert.AreEqual (2, p.Files.Count);
			string f = Path.Combine (p.BaseDirectory, "Program.cs");
			Assert.IsTrue (p.Files.GetFile (f) != null, "Contains Program.cs");
			f = Path.Combine (p.BaseDirectory, "Properties");
			f = Path.Combine (f, "AssemblyInfo.cs");
			Assert.IsTrue (p.Files.GetFile (f) != null, "Contains Properties/AssemblyInfo.cs");
			
			List<string> refs = new List<string> ();
			refs.Add ("System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
			refs.Add ("System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
			refs.Add ("System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
			Assert.AreEqual (3, p.References.Count);
			
			ProjectReference xmlRef = null;
			foreach (ProjectReference pref in p.References) {
				Assert.IsTrue (refs.Contains (pref.Reference), "Contains reference " + pref.Reference);
				refs.Remove (pref.Reference);
				if (pref.Reference.StartsWith ("System.Xml"))
					xmlRef = pref;
			}
			
			// Test saving
			
			p.References.Remove (xmlRef);
			p.References.Add (new ProjectReference (ReferenceType.Package, "System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"));
			
			p.Files.Remove (f);
			p.Files.Add (new ProjectFile (Path.Combine (p.BaseDirectory, "Class1.cs"), BuildAction.Compile));
			
			sol.Save (Util.GetMonitor ());
			
			string makefile = File.ReadAllText (Path.Combine (p.BaseDirectory, "Makefile"));
			string[] values = GetVariable (makefile, "FILES").Split (' ');
			Assert.AreEqual (2, values.Length);
			Assert.AreEqual ("Class1.cs", values [0]);
			Assert.AreEqual ("Program.cs", values [1]);

			values = GetVariable (makefile, "REFERENCES").Split (' ');
			Assert.AreEqual (3, values.Length);
			Assert.AreEqual ("System", values [0]);
			Assert.AreEqual ("System.Data", values [1]);
			Assert.AreEqual ("System.Web", values [2]);
		}
        public void Remove_with_predicate_none()
        {
            List<int> list = new List<int>();
            list.Add(1);
            list.Add(2);
            list.Add(3);
            list.Add(4);

            list.Remove(i => false);

            Assert.AreEqual(4, list.Count);
        }
        public void Remove_with_predicate_all()
        {
            List<int> list = new List<int>();
            list.Add(1);
            list.Add(2);
            list.Add(3);
            list.Add(4);

            list.Remove(i => true);

            Assert.AreEqual(0, list.Count);
        }
Beispiel #22
0
 public void TestIListGetRandom()
 {
     var list = new List<int> ();
     for (int i = 0; i < 1000; i++) {
         list.Add (i);
     }
     for (int j = 0; j < 1000; j++) {
         int i = list.Aleatorio ();
         Console.Write (i + " ");
         Assert.True (list.Remove (i));
     }
     Assert.AreEqual (0, list.Count);
 }
 public void testIterator()
 {
     FastIDSet set = buildTestFastSet();
     var expected = new List<long>(3);
     expected.Add(1L);
     expected.Add(2L);
     expected.Add(3L);
     var it = set.GetEnumerator();
     while (it.MoveNext()) {
       expected.Remove(it.Current);
     }
     Assert.True(expected.Count == 0);
 }
Beispiel #24
0
        public void ShouldGetParamNamesFromMethod()
        {
            MethodInfo method = this.GetType().GetMethod("MethodWithTwoArguments");
            ParameterInfo[] parameters = method.GetParameters();
            List<string> expected = new List<string>(new string[] {"str", "anint"});
            Assert.AreEqual(2, parameters.Length);

            foreach (ParameterInfo info in parameters)
            {
                expected.Remove(info.Name);
            }
            Assert.AreEqual(0, expected.Count);
        }
        public void RenameOnSubFolder() {
            var storage = new Mock<IMetaDataStorage>();
            var fsFactory = new Mock<IFileSystemInfoFactory>();
            var underTest = new LocalEventGenerator(storage.Object, fsFactory.Object);
            Dictionary<string, Tuple<AbstractFolderEvent, AbstractFolderEvent>> eventMap = new Dictionary<string, Tuple<AbstractFolderEvent, AbstractFolderEvent>>();

            Guid rootGuid = Guid.NewGuid();
            var rootName = "root";
            var rootPath = Path.Combine(Path.GetTempPath(), rootName);
            var rootObjectId = "rootId";
            ObjectTree<IFileSystemInfo> rootTree = this.CreateTreeFromPathAndGuid(rootName, rootPath, rootGuid);

            Guid subFolderGuid = Guid.NewGuid();
            var subName = "A";
            var subPath = Path.Combine(rootPath, subName);
            var subFolderId = "subId";
            ObjectTree<IFileSystemInfo> subFolder = this.CreateTreeFromPathAndGuid(subName, subPath, subFolderGuid);
            rootTree.Children.Add(subFolder);

            Guid subSubFolderGuid = Guid.NewGuid();
            var subSubName = "B";
            var subSubPath = Path.Combine(subPath, subSubName);
            var subSubFolderId = "subId";
            ObjectTree<IFileSystemInfo> subSubFolder = this.CreateTreeFromPathAndGuid(subSubName, subSubPath, subSubFolderGuid);
            subFolder.Children.Add(subSubFolder);

            List<IMappedObject> storedObjectsForLocal = new List<IMappedObject>();
            var rootMappedObject = this.CreateStoredObjectMock(rootGuid, rootObjectId, rootName, null);
            storedObjectsForLocal.Add(rootMappedObject);
            var subMappedObject = this.CreateStoredObjectMock(subFolderGuid, subFolderId, subName, rootObjectId);
            storedObjectsForLocal.Add(subMappedObject);
            var subSubMappedObject = this.CreateStoredObjectMock(subSubFolderGuid, subSubFolderId, "oldsubsubName", subSubFolderId);
            storedObjectsForLocal.Add(subSubMappedObject);

            storage.Setup(s => s.GetLocalPath(rootMappedObject)).Returns(rootPath);
            storage.Setup(s => s.GetLocalPath(subMappedObject)).Returns(subPath);
            storage.Setup(s => s.GetLocalPath(subSubMappedObject)).Returns(subSubPath);

            ISet<IMappedObject> handledLocalStoredObjects = new HashSet<IMappedObject>();
            List<AbstractFolderEvent> creationEvents = underTest.CreateEvents(storedObjectsForLocal, rootTree, eventMap, handledLocalStoredObjects);
            foreach (var handledObjects in handledLocalStoredObjects) {
                storedObjectsForLocal.Remove(handledObjects);
            }

            storedObjectsForLocal.Remove(rootMappedObject);
            Assert.That(creationEvents, Is.Empty);
            Assert.That(storedObjectsForLocal, Is.Empty);
            Assert.That(eventMap.Count, Is.EqualTo(1));
            Assert.That(eventMap[subSubFolderId], Is.Not.Null);
            Assert.That(eventMap[subSubFolderId].Item1.Local, Is.EqualTo(MetaDataChangeType.CHANGED));
        }
        public void TestCreateEmbeddedDatabase()
        {
            string newfileName = "TestCreateEmbeddedDatabase" + SRandom.Next().ToString() + ".db";

            HttpWebClient httpWebClient = new HttpWebClient();
            LoginAsRoot(httpWebClient);

            CreateFile(WebServer, httpWebClient, "/", newfileName, "database");

            HttpResponseHandler webResponse = httpWebClient.Post(
                "http://localhost:" + WebServer.Port + "/" + newfileName + "?Method=PostQuery",
                new KeyValuePair<string, string>("query", "create table testtable (testcol int)"));

            Assert.AreEqual(HttpStatusCode.OK, webResponse.StatusCode, "Bad status code");
            int[] resultInts = webResponse.AsJsonReader().Deserialize<int[]>();
            Assert.IsNotNull(resultInts, "Result deserialized as null");
            Assert.AreEqual(0, resultInts[0], "Incorrect result");

            webResponse = httpWebClient.Post(
                "http://localhost:" + WebServer.Port + "/" + newfileName + "?Method=PostQuery",
                new KeyValuePair<string, string>("query", "insert into testtable (testcol) values (123);insert into testtable (testcol) values (456)"));

            Assert.AreEqual(HttpStatusCode.OK, webResponse.StatusCode, "Bad status code");
            resultInts = webResponse.AsJsonReader().Deserialize<int[]>();
            Assert.AreEqual(2, resultInts[0], "Incorrect result");

            webResponse = httpWebClient.Post(
                "http://localhost:" + WebServer.Port + "/" + newfileName + "?Method=PostQuery",
                new KeyValuePair<string, string>("query", "select * from testtable; select * from testtable"));

            Assert.AreEqual(HttpStatusCode.OK, webResponse.StatusCode, "Bad status code");
            Dictionary<string, object>[][] resultObjss = webResponse.AsJsonReader().Deserialize<Dictionary<string, object>[][]>();

            Assert.AreEqual(2, resultObjss.Length, "Wrong number of queries returned");

            foreach (Dictionary<string, object>[] resultObjs in resultObjss)
            {
                List<int> expected = new List<int>(new int[] {123,456});

                foreach(Dictionary<string, object> resultObj in resultObjs)
                {
                    int value = Convert.ToInt32(resultObj["testcol"]);

                    Assert.IsTrue(expected.Contains(value), "Unexpected value: " + value);
                    expected.Remove(value);
                }

                Assert.IsTrue(0 == expected.Count, "Expected values not returned: " + StringGenerator.GenerateCommaSeperatedList(expected));
            }
        }
        private static RepositoryType[] RemoveExceptions(RepositoryType[] repositoryType)
        {
            if (_exceptions == null || _exceptions.Length == 0)
                return repositoryType;

            var list = new List<RepositoryType>();
            list.AddRange(repositoryType);
            foreach (var exception in _exceptions.Where(list.Contains))
            {
                list.Remove(exception);
            }

            return list.ToArray();
        }
Beispiel #28
0
        public void TestExecute()
        {
            var list = new List<int> ();
            Action<int> exeAction = list.Add;
            Action<int> undoAction = (v) => list.Remove(v);

            var command = new Command<int>(2,exeAction, undoAction);
            command.Execute ();
            Assert.AreEqual (list.Count,1);
            Assert.AreEqual (list [0], 2);

            command.Undo ();
            Assert.AreEqual (list.Count,0);
        }
Beispiel #29
0
        public void Test()
        {
            // Arrange
              var list = new List<Player>();

              // Quarterbacks
              for (var i = 0; i < 20; i++)
              {
            var player = GeneratePlayer(30, 40, "Quarterback");
            list.Add(player);
              }

              // Runnigbacks
              for (var i = 0; i < 20; i++)
              {
            var player = GeneratePlayer(10, 20, "Runningback");
            list.Add(player);
              }

              // Kickers
              for (var i = 0; i < 20; i++)
              {
            var player = GeneratePlayer(1, 2, "Kicker");
            list.Add(player);
              }

              // Act
              var results = new List<Player>();
              for (var i = 0; i < 40; i++)
              {
            var player = _sut.Choose(list);
            player.Position = i + 1;

            results.Add(player);
            list.Remove(player);
              }

              // Assert
              var quarterBacks = results.Where(x => x.PlayerType == "Quarterback").ToList();
              var runnigBacks = results.Where(x => x.PlayerType == "Runningback").ToList();
              var kickers = results.Where(x => x.PlayerType == "Kicker").ToList();
              quarterBacks.Count().ShouldBeGreaterThanOrEqualTo(runnigBacks.Count());
              runnigBacks.Count().ShouldBeGreaterThanOrEqualTo(kickers.Count());

              var topTenQuarterbacks = quarterBacks.Count(x => x.Position <= 10);
              var topTenRunningbacks = runnigBacks.Count(x => x.Position <= 10);
              var topTenKickers = kickers.Count(x => x.Position <= 10);
              topTenQuarterbacks.ShouldBeGreaterThan(topTenRunningbacks);
              topTenRunningbacks.ShouldBeGreaterThanOrEqualTo(topTenKickers);
        }
Beispiel #30
0
 public static TestMode Create(string commandLineArguments)
 {
     var testMode = new TestMode();
     bool containsExternalMode = commandLineArguments.Contains("/exclude");
     if (containsExternalMode)
     {
         var modes = new List<string> {Constants.WPFFrameworkId, Constants.WinFormFrameworkId, Constants.SWT};
         string[] strings = commandLineArguments.Split(new[] {"/exclude:"}, StringSplitOptions.None);
         strings = strings[1].Split(',', '\"', ' ');
         foreach (string exclude in strings)
             modes.Remove(exclude);
         testMode.applicationClass = (ApplicationClass) Enum.Parse(typeof (ApplicationClass), modes[0]);
     }
     return testMode;
 }