public void GarageInsertAfterLoadTest() { string pathToFile = "./base.json"; var result = new int[] { 1, 2 }; var garage = new Garage(); var car = new Car() { Name = "One car", Number = "et2314fd", WheelCount = 4, MaxSpeed = 123, InstalledGas = false }; garage.Store(car); garage.Save(pathToFile); var newGarage = new Garage(pathToFile); var car2 = new Car() { Name = "Two car", Number = "wr6346fg", WheelCount = 3, MaxSpeed = 98, InstalledGas = false }; newGarage.Store(car2); var ids = newGarage.GetIds(); CollectionAssert.AreEqual(result, ids); }
public void GetWalletOf_LoggedInFriend_Should_Return_Users_Wallet() { //create user and attach a friend to it var user = new User(1); var friend = new User(2); user.AddFriend(friend); //login the friend _userSession.LoggedUser = friend; //create wallets and attach it to the user var userWallet1 = new Wallet(); var userWallet2 = new Wallet(); var wallets = new List <Wallet>() { userWallet1, userWallet2 }; _walletDalMock.Setup(dao => dao.FindWalletsByUser(user)).Returns(wallets); //walletService should return same list CollectionAssert.AreEqual(_walletService.GetWalletsByUser(user), wallets); }
public void ChangeCollectionCompleteWithErrorTest() { //arrange var source = new PandaTask(); var tasks = new List <IPandaTask> { PandaTasksUtilities.CompletedTask, source }; var allTask = new WhenAllPandaTask(tasks, CancellationStrategy.Aggregate); tasks.Add(PandaTasksUtilities.CanceledTask); //act var testError = new Exception(); source.Reject(testError); //assert Assert.AreEqual(PandaTaskStatus.Rejected, allTask.Status); Assert.IsInstanceOf <AggregateException>(allTask.Error); CollectionAssert.AreEqual(new[] { testError }, (( AggregateException )allTask.Error).InnerExceptions); }
public void Products() { var expected = Enumerable.Range(0, 10) .Select(i => { var idSql = RandomData.GenerateOrderedSqlGuid2(); var name = RandomData.GenerateAlphanumerics(20); System.Threading.Thread.Sleep(1); return(new Product { Id = idSql.Guid, Created = idSql.DateTime, Name = name, }); }) .ToArray(); using (var db = new RandomTestDb()) { db.Products.AddRange(expected); db.SaveChanges(); } Product[] actual; using (var db = new RandomTestDb()) { var lower = DateTime.UtcNow.AddSeconds(-30); actual = db.Products .Where(p => p.Created.CompareTo(lower) > 0) .OrderBy(p => p.Id) .ToArray(); } CollectionAssert.AreEqual(expected.Select(x => x.Name).ToArray(), actual.Select(x => x.Name).ToArray()); }
public void TestLongNonRepeatingRow() { var data = new byte[250]; for (var i = 0; i < data.Length; ++i) { data[i] = (byte)(i + 1); } var compressedData = CompressRow(0, data); var expectedData = new byte[254]; expectedData[0] = 252; Array.Copy(data, 0, expectedData, 1, 64); expectedData[65] = 252; Array.Copy(data, 64, expectedData, 66, 64); expectedData[130] = 252; Array.Copy(data, 128, expectedData, 131, 64); expectedData[195] = 228; Array.Copy(data, 192, expectedData, 196, 58); CollectionAssert.AreEqual(expectedData, compressedData); CollectionAssert.AreEqual(data, UncompressRow(9, data.Length, compressedData)); }
public void Can_Build_Correct_Model_For_10_Items_With_2_Item_Per_Page() { // Assemble var pager = new Pager(null, 2, 3, 10); var expectedPagination = new List <PaginationLink>() { new PaginationLink { Active = true, DisplayText = "«", PageIndex = 2, Url = "/test/2" }, new PaginationLink { Active = true, DisplayText = "1", PageIndex = 1, Url = "/test/1" }, new PaginationLink { Active = true, DisplayText = "2", PageIndex = 2, Url = "/test/2" }, new PaginationLink { Active = true, DisplayText = "3", PageIndex = 3, IsCurrent = true, Url = null }, new PaginationLink { Active = true, DisplayText = "4", PageIndex = 4, Url = "/test/4" }, new PaginationLink { Active = true, DisplayText = "5", PageIndex = 5, Url = "/test/5" }, new PaginationLink { Active = true, DisplayText = "»", PageIndex = 4, Url = "/test/4" } }; // Act var result = pager.BuildPaginationModel(BuildUrl); // Assert Assert.AreEqual(expectedPagination.Count, result.PaginationLinks.Count()); CollectionAssert.AreEqual(expectedPagination, result.PaginationLinks, new PaginationComparer()); }
public void Serialize_Full_MqttUnsubAckPacket_V500() { var unsubAckPacket = new MqttUnsubAckPacket { PacketIdentifier = 123, ReasonCodes = new List <MqttUnsubscribeReasonCode> { MqttUnsubscribeReasonCode.ImplementationSpecificError }, ReasonString = "ReasonString", UserProperties = new List <MqttUserProperty> { new MqttUserProperty("Foo", "Bar") } }; var deserialized = MqttPacketSerializationHelper.EncodeAndDecodePacket(unsubAckPacket, MqttProtocolVersion.V500); Assert.AreEqual(unsubAckPacket.PacketIdentifier, deserialized.PacketIdentifier); Assert.AreEqual(unsubAckPacket.ReasonString, deserialized.ReasonString); Assert.AreEqual(unsubAckPacket.ReasonCodes.Count, deserialized.ReasonCodes.Count); Assert.AreEqual(unsubAckPacket.ReasonCodes[0], deserialized.ReasonCodes[0]); CollectionAssert.AreEqual(unsubAckPacket.UserProperties, deserialized.UserProperties); }
public void EditDataGrid() { using (var app = Application.AttachOrLaunch(Info.ExeFileName, WindowName)) { var window = app.MainWindow; window.FindButton("Reset").Invoke(); window.FindButton("AddTen").Invoke(); var listBox = window.FindGroupBox("ListBox").FindListBox(); var dataGrid = window.FindGroupBox("DataGrid").FindDataGrid(); CollectionAssert.AreEqual(new[] { "1", "2", "3", "4", string.Empty }, listBox.Items.Select(x => x.FindTextBlock().Text)); CollectionAssert.AreEqual(new[] { "1", "2", "3", "4", string.Empty }, dataGrid.ColumnValues(0)); CollectionAssert.AreEqual(new[] { "Reset" }, window.FindChangesGroupBox("ViewChanges").Texts); CollectionAssert.AreEqual(Enumerable.Repeat("Add", 10), window.FindChangesGroupBox("SourceChanges").Texts); dataGrid[0, 0].Value = "5"; listBox.Focus(); CollectionAssert.AreEqual(new[] { "5", "2", "3", "4", string.Empty }, listBox.Items.Select(x => x.FindTextBlock().Text)); CollectionAssert.AreEqual(new[] { "5", "2", "3", "4", string.Empty }, dataGrid.ColumnValues(0)); CollectionAssert.AreEqual(new[] { "Reset" }, window.FindChangesGroupBox("ViewChanges").Texts); CollectionAssert.AreEqual(Enumerable.Repeat("Add", 10), window.FindChangesGroupBox("SourceChanges").Texts); } }
public void Test_AddBook_AddsBookToAuthor() { //Arrange Author testAuthor = new Author("George Orwell"); testAuthor.Save(); Book testBook = new Book("1984"); testBook.Save(); Book testBook2 = new Book("Animal Farm"); testBook2.Save(); //Act testAuthor.AddBook(testBook); testAuthor.AddBook(testBook2); List <Book> result = testAuthor.GetBooks(); List <Book> testList = new List <Book> { testBook, testBook2 }; //Assert CollectionAssert.AreEqual(testList, result); }
public static void Validation() { using var app = Application.Launch(ExeFileName, WindowName); var window = app.MainWindow; // this is used as reference var groupBox = window.FindGroupBox("Validation events"); var expected = new List<string> { "HasError: False", "Empty" }; var actual = groupBox.FindTextBlocks("Event").Select(x => x.Text).ToArray(); CollectionAssert.AreEqual(expected, actual, $"Actual: {string.Join(", ", actual.Select(x => "\"" + x + "\""))}"); var textBox = window.FindTextBox("ValidationTextBox"); textBox.Text = "a"; expected.AddRange( new[] { "ValidationError: Value 'a' could not be converted.", "HasError: True", "Action: Added Error: Value 'a' could not be converted. Source: ValidationTextBox OriginalSource: ValidationTextBox", }); actual = groupBox.FindTextBlocks("Event").Select(x => x.Text).ToArray(); CollectionAssert.AreEqual(expected, actual, $"Actual: {string.Join(", ", actual.Select(x => "\"" + x + "\""))}"); textBox.Text = "1"; expected.AddRange( new[] { "HasError: False", "Empty", "Action: Removed Error: Value 'a' could not be converted. Source: ValidationTextBox OriginalSource: ValidationTextBox", }); actual = groupBox.FindTextBlocks("Event").Select(x => x.Text).ToArray(); CollectionAssert.AreEqual(expected, actual, $"Actual: {string.Join(", ", actual.Select(x => "\"" + x + "\""))}"); }
public void Test_AddItem_AddsItemToCategory() { //Arrange Category testCategory = new Category("Household chores"); testCategory.Save(); Item testItem = new Item("Mow the lawn"); testItem.Save(); Item testItem2 = new Item("Water the garden"); testItem2.Save(); //Act testCategory.AddItem(testItem); testCategory.AddItem(testItem2); List <Item> result = testCategory.GetItems(); List <Item> testList = new List <Item> { testItem, testItem2 }; //Assert CollectionAssert.AreEqual(testList, result); }
public void TestDateTime() { TestPreValidation(); var actualResults = TestContext.GetModelParseResults(TestSpec); var expectedResults = TestSpec.CastResults <ModelResult>(); Assert.AreEqual(expectedResults.Count(), actualResults.Count, GetMessage(TestSpec)); foreach (var tuple in Enumerable.Zip(expectedResults, actualResults, Tuple.Create)) { var expected = tuple.Item1; var actual = tuple.Item2; Assert.AreEqual(expected.Text, actual.Text, GetMessage(TestSpec)); Assert.AreEqual(expected.TypeName, actual.TypeName, GetMessage(TestSpec)); Assert.AreEqual(expected.Start, actual.Start, GetMessage(TestSpec)); Assert.AreEqual(expected.End, actual.End, GetMessage(TestSpec)); var values = actual.Resolution as IDictionary <string, object>; // Actual ValueSet types should not be modified as that's considered a breaking API change var actualValues = ((List <Dictionary <string, string> >)values[ResolutionKey.ValueSet]).ToList(); var expectedValues = JsonConvert.DeserializeObject <IList <Dictionary <string, string> > >(expected .Resolution[ResolutionKey.ValueSet].ToString()); Assert.AreEqual(expectedValues.Count, actualValues.Count, GetMessage(TestSpec)); foreach (var value in expectedValues.Zip(actualValues, Tuple.Create)) { Assert.AreEqual(value.Item1.Count, value.Item2.Count, GetMessage(TestSpec)); CollectionAssert.AreEqual(value.Item1, value.Item2, GetMessage(TestSpec)); } } }
public void SubArraysTest() { var array = new byte[] { 66, 49, 129, 36, 9, 90, 250, 190, 61, 36, 113, 21, 249, 74, 237, 174 }; var expectedPart1 = new byte[] { 66, 49, 129, 36, 9, 90, 250, 190 }; var expectedPart2 = new byte[] { 61, 36, 113, 21, 249, 74, 237, 174 }; var sub1 = ArrayHelper.SubArray(array, 0, 8); CollectionAssert.AreEqual(expectedPart1, sub1); var sub2 = ArrayHelper.SubArray(array, 8); CollectionAssert.AreEqual(expectedPart2, sub2); }
public void CustomerFacade_GetAllFlights_FlightsReceived() { AddToLogFile("run CustomerFacade GetAllFlights"); InitDBUnitTest.InitDB(); IList<Flight> flights1 = null; IList<Flight> flights2 = null; AdministratorFacade_CreateNewCustomer(); Flight flight = AirlineCompanyFacadeFacade_CreateNewFlight1(); ILoggedInCustomerFacade customerFacade = GetCustomerFacade(out LoginToken<Customer> tCustomer); flights1 = customerFacade.GetAllFlights(tCustomer); flights2 = new List<Flight>(); flights2.Add(flight); List<Flight> f1 = (List<Flight>)flights1; List<Flight> f2 = (List<Flight>)flights2; CollectionAssert.AreEqual(f1, f2); Assert.AreEqual(flights1[0].ID, flights2[0].ID); Assert.AreEqual(flights1[0].AIRLINECOMPANY_ID, flights2[0].AIRLINECOMPANY_ID); Assert.AreEqual(flights1[0].ORIGIN_COUNTRY_CODE, flights2[0].ORIGIN_COUNTRY_CODE); Assert.AreEqual(flights1[0].DESTINATION_COUNTRY_CODE, flights2[0].DESTINATION_COUNTRY_CODE); Assert.AreEqual(flights1[0].DEPARTURE_TIME, flights2[0].DEPARTURE_TIME); Assert.AreEqual(flights1[0].LANDING_TIME, flights2[0].LANDING_TIME); Assert.AreEqual(flights1[0].REMANING_TICKETS, flights2[0].REMANING_TICKETS); Assert.AreEqual(flights1[0].TOTAL_TICKETS, flights2[0].TOTAL_TICKETS); }
public void DeserializeRequestDataT020() { var jsont = EmbeddedResourceManager.GetString("Assets.v1_spec_02.0_req.json"); var jrcr = new JsonRpcContractResolver(); var jrs = new JsonRpcSerializer(jrcr, compatibilityLevel: JsonRpcCompatibilityLevel.Level1); jrcr.AddRequestContract("postMessage", new JsonRpcRequestContract(new[] { typeof(string) })); var jrd = jrs.DeserializeRequestData(jsont); Assert.IsFalse(jrd.IsBatch); var jrmi = jrd.Item; Assert.IsTrue(jrmi.IsValid); var jrm = jrmi.Message; Assert.AreEqual(99L, jrm.Id); Assert.AreEqual("postMessage", jrm.Method); Assert.AreEqual(JsonRpcParametersType.ByPosition, jrm.ParametersType); CollectionAssert.AreEqual(new object[] { "Hello all!" }, jrm.ParametersByPosition?.ToArray()); }
public async Task Test_Get_Match() { using (var context = new MatchDBContext(options)) { //just to have empty database and insert same element options to compare with the result context.Database.EnsureDeleted(); IMatchRepository _matchRepository = new MatchRepository(context); var matchService = new MatchService(_matchRepository); if (!context.Matches.Any()) { await context.Matches.AddRangeAsync(Get_mockDefaultListMaches()); await context.SaveChangesAsync(); } //can not return same default order Assert.AreNotEqual(Get_mockDefaultListMaches(), await matchService.GetOrderedScore()); //can be same list order from mock data CollectionAssert.AreEqual(Get_mockOrderedListMaches(), await matchService.GetOrderedScore(), new MatchComparer()); } }
public void FindPersonsByEmailDomain_ShouldReturnMatchingPersons() { // Arrange this.persons.AddPerson("*****@*****.**", "Pesho", 28, "Plovdiv"); this.persons.AddPerson("*****@*****.**", "Kiril", 22, "Sofia"); this.persons.AddPerson("*****@*****.**", "Maria", 21, "Plovdiv"); this.persons.AddPerson("*****@*****.**", "Anna", 19, "Bourgas"); // Act var personsGmail = this.persons.FindPersons("gmail.com"); var personsYahoo = this.persons.FindPersons("yahoo.co.uk"); var personsHoo = this.persons.FindPersons("hoo.co.uk"); // Assert CollectionAssert.AreEqual( new string[] { "*****@*****.**", "*****@*****.**", "*****@*****.**" }, personsGmail.Select(p => p.Email).ToList()); CollectionAssert.AreEqual( new string[] { "*****@*****.**" }, personsYahoo.Select(p => p.Email).ToList()); CollectionAssert.AreEqual( new string[] { }, personsHoo.Select(p => p.Email).ToList()); }
public void GetActivityFieldsOffDataSplitActivityExpectedAllFindMissingFieldsToBeReturned() { DsfDataSplitActivity dataSplitActivity = new DsfDataSplitActivity(); dataSplitActivity.OnErrorVariable = "[[onErr]]"; dataSplitActivity.ResultsCollection = new List <DataSplitDTO> { new DataSplitDTO("[[OutputVariable1]]", "Index", "[[At1]]", 1) { EscapeChar = "[[Escaped1]]" }, new DataSplitDTO("[[OutputVariable2]]", "Index", "[[At2]]", 2) { EscapeChar = "[[Escaped2]]" } }; dataSplitActivity.SourceString = "[[SourceString]]"; Dev2FindMissingStrategyFactory fac = new Dev2FindMissingStrategyFactory(); IFindMissingStrategy strategy = fac.CreateFindMissingStrategy(enFindMissingType.MixedActivity); List <string> actual = strategy.GetActivityFields(dataSplitActivity); List <string> expected = new List <string> { "[[Escaped1]]", "[[OutputVariable1]]", "[[At1]]", "[[Escaped2]]", "[[OutputVariable2]]", "[[At2]]", "[[SourceString]]", "[[onErr]]" }; CollectionAssert.AreEqual(expected, actual); }
public void TestReadFile() { //Arrange var ExpectedResults = new List <string>(); ExpectedResults.Add("Janet Parsons"); ExpectedResults.Add("Vaughn Lewis"); ExpectedResults.Add("Adonis Julius Archer"); ExpectedResults.Add("Shelby Nathan Yoder"); ExpectedResults.Add("Marin Alvarez"); ExpectedResults.Add("London Lindsey"); ExpectedResults.Add("Beau Tristan Bentley"); ExpectedResults.Add("Leo Gardner"); ExpectedResults.Add("Hunter Uriah Mathew Clarke"); ExpectedResults.Add("Mikayla Lopez"); ExpectedResults.Add("Frankie Conner Ritter"); //Act var ReadFiles = servicesProvider.GetService <IFileServices>(); var Results = ReadFiles.ReadFile(@"Files\unsorted-names-list.txt"); //Assert CollectionAssert.AreEqual(ExpectedResults, Results, "Read File Failed"); }
public async Task GetSecurityBlogAsync_LoggerServiceThrow_SendEmail() { string originContent = "1111 2222 3333 4444 0000 5555 为了节能环保000,为了环境安全,请使用可降解垃圾袋。"; await _blogService.GetSecurityBlogAsync(originContent); CollectionAssert.AreEqual(SendEmailArgsList, new List<string> { "Harley", "System", "LoggerService抛出异常", "Custom Exception" }, "GetSecurityBlogAsync记录错误日志时出现错误,未能正确发送邮件给开发者"); }
public void TestNoiseTimeLimit() { var testFilesDir = new TestFilesDir(TestContext, ZIP_FILE); string docPath = testFilesDir.GetTestPath("BSA_Protea_label_free_20100323_meth3_multi.sky"); SrmDocument doc = ResultsUtil.DeserializeDocument(docPath); using (var docContainer = new ResultsTestDocumentContainer(doc, docPath)) { // Import the first RAW file (or mzML for international) string rawPath = testFilesDir.GetTestPath("ah_20101011y_BSA_MS-MS_only_5-2" + ExtensionTestContext.ExtThermoRaw); var measuredResults = new MeasuredResults(new[] { new ChromatogramSet("Single", new[] { rawPath }) }); SrmDocument docResults = docContainer.ChangeMeasuredResults(measuredResults, 3, 3, 21); var tolerance = (float)docResults.Settings.TransitionSettings.Instrument.MzMatchTolerance; ChromCacheMinimizer.Settings settings = new ChromCacheMinimizer.Settings() .ChangeDiscardUnmatchedChromatograms(false) .ChangeNoiseTimeRange(1.0); string minimized1Path = testFilesDir.GetTestPath("NoiseTimeLimited1.sky"); string minimized2Path = testFilesDir.GetTestPath("NoiseTimeLimited2.sky"); using (var docContainerMinimized1Min = MinimizeCacheFile(docResults, settings.ChangeNoiseTimeRange(1.0), minimized1Path)) using (var docContainerMinimized2Min = MinimizeCacheFile(docResults, settings.ChangeNoiseTimeRange(2.0), minimized2Path)) { SrmDocument docMinimized1Min = docContainerMinimized1Min.Document; SrmDocument docMinimized2Min = docContainerMinimized2Min.Document; ChromatogramSet chromSet1Min = docMinimized1Min.Settings.MeasuredResults.Chromatograms[0]; ChromatogramSet chromSet2Min = docMinimized2Min.Settings.MeasuredResults.Chromatograms[0]; ChromatogramSet chromSetOriginal = docResults.Settings.MeasuredResults.Chromatograms[0]; foreach (var pair in docResults.PeptidePrecursorPairs) { ChromatogramGroupInfo[] chromGroupsOriginal; ChromatogramGroupInfo[] chromGroups1; ChromatogramGroupInfo[] chromGroups2; docMinimized1Min.Settings.MeasuredResults.TryLoadChromatogram(chromSet1Min, pair.NodePep, pair.NodeGroup, tolerance, true, out chromGroups1); docMinimized2Min.Settings.MeasuredResults.TryLoadChromatogram(chromSet2Min, pair.NodePep, pair.NodeGroup, tolerance, true, out chromGroups2); docResults.Settings.MeasuredResults.TryLoadChromatogram(chromSetOriginal, pair.NodePep, pair.NodeGroup, tolerance, true, out chromGroupsOriginal); Assert.AreEqual(chromGroups1.Length, chromGroups2.Length); Assert.AreEqual(chromGroups1.Length, chromGroupsOriginal.Length); for (int iChromGroup = 0; iChromGroup < chromGroups1.Length; iChromGroup++) { ChromatogramGroupInfo chromGroup1 = chromGroups1[iChromGroup]; ChromatogramGroupInfo chromGroup2 = chromGroups2[iChromGroup]; ChromatogramGroupInfo chromGroupOriginal = chromGroupsOriginal[iChromGroup]; var times = new[] { GetTimes(chromGroupOriginal)[0], GetTimes(chromGroup2)[0], GetTimes(chromGroup1)[0], GetTimes(chromGroup1).Last(), GetTimes(chromGroup2).Last(), GetTimes(chromGroupOriginal).Last() }; // The two minute window around the peak might overlap with either the start or end of the original chromatogram, // but will never overlap with both. Assert.IsTrue(GetTimes(chromGroup2)[0] > GetTimes(chromGroupOriginal)[0] || GetTimes(chromGroup2).Last() < GetTimes(chromGroupOriginal).Last()); // If the two minute window does not overlap with the start/end of the original chromatogram, then the difference // in time between the one minute window and the two minute window will be approximately 1 minute. if (GetTimes(chromGroup2)[0] > GetTimes(chromGroupOriginal)[0]) { Assert.AreEqual(GetTimes(chromGroup2)[0], GetTimes(chromGroup1)[0] - 1, .1); } if (GetTimes(chromGroup2).Last() < GetTimes(chromGroupOriginal).Last()) { Assert.AreEqual(GetTimes(chromGroup2).Last(), GetTimes(chromGroup1).Last() + 1, .1); } float[] timesSorted = times.ToArray(); Array.Sort(timesSorted); CollectionAssert.AreEqual(times, timesSorted); } } } } }
public void SwapTestForward() { int[] data = { 1, 2, 3, 4, 5 }; data.Swap(2, 4); CollectionAssert.AreEqual(new[] { 1, 2, 5, 4, 3 }, data); }
public void SwapTestSameIndex() { int[] data = { 1, 2, 3, 4, 5 }; data.Swap(2, 2); CollectionAssert.AreEqual(new[] { 1, 2, 3, 4, 5 }, data); }
public void Correct_sum_100() { var res = new ProRataDistributor().DistributeAllButLast(100, new[] { 1, 1 }, 2); CollectionAssert.AreEqual(new[] { 50M, 50M }, res); Assert.AreEqual(100, res.Sum()); }
public void SwapTestBackward() { int[] data = {1, 2, 3}; data.Swap(2, 0); CollectionAssert.AreEqual(new[] { 3, 2, 1 }, data); }
public void Error_should_sum_100() { var res = new ProRataDistributor().DistributeAllButLast(100, new[] { 1, 1, 1 }, 2); CollectionAssert.AreEqual(new[] { 33.33M, 33.33M, 33.34M }, res); Assert.AreEqual(100, res.Sum()); }
protected void AssertMatchesSolrInformationFromUrl() { // get id from url string url = Driver.Url; const string urlPattern = @".+\/(\d+)"; const string keyValuePattern = @"^value_.+_txts_\w{2}$"; const string associationsPattern = @"^(?:parents|related)_ss$"; Regex urlRegex = new Regex(urlPattern); Regex keyValyeRegex = new Regex(keyValuePattern); Regex associationsRegex = new Regex(associationsPattern); Match urlMatch = urlRegex.Match(url); if (urlMatch.Success && urlMatch.Groups.Count == 2) { Int64 id = Convert.ToInt64(urlMatch.Groups[1].Value); CatfishDbContext db = new CatfishDbContext(); CFEntity model = db.Entities.Find(id); Dictionary <string, object> result = model.ToSolrDictionary(); SolrQuery q = new SolrQuery($@"id:{model.MappedGuid}"); SolrQueryResults <Dictionary <string, object> > solrResults = SolrService.SolrOperations.Query(q); if (solrResults.Count == 1) { Dictionary <string, object> fromSolr = solrResults[0]; foreach (KeyValuePair <string, object> entry in result) { // first we need to make sure the entry value is not empty, // otherwise is not indexed in solr //if (entry.Value.ToString().Length > 0 && entry.Value != fromSolr[entry.Key]) //{ // return false; //} //if (entry.Value.ToString().Length > 0) //{ // // check if key has value pattern // Match keyValueMatch = keyValyeRegex.Match(entry.Key); // if (keyValueMatch.Success) // { // // compare as list of values // CollectionAssert.AreEqual((List<string>)entry.Value, // (System.Collections.ArrayList)fromSolr[entry.Key]); // } else // { // Assert.AreEqual(entry.Value, fromSolr[entry.Key]); // } //} Match keyValueMatch = keyValyeRegex.Match(entry.Key); Match associationsMatch = associationsRegex.Match(entry.Key); if (keyValueMatch.Success || associationsMatch.Success) { // treat as multi values List <string> test = (List <string>)entry.Value; if (test.Count > 0 && test[0] != "") { CollectionAssert.AreEqual(test, (System.Collections.ArrayList)fromSolr[entry.Key]); } //XXX Should it fail if the previous test is not passed? } else { // treat as regular values if (!string.IsNullOrEmpty(entry.Value.ToString())) { Assert.AreEqual(entry.Value, fromSolr[entry.Key]); } } } //return true; } } //return false; }
public void Test_FullJordanGauss() { //шаг 1 double[,] except = { { 0, 1, -2, 3 }, { 1, -2, 5.0 / 2, -13.0 / 2 }, { 0, 5, 17.0 / 2, -7.0 / 2 } }; Jordan_Gauss.Jordan_Gauss actual = Jordan_Gauss.StepMethod ( data: new Jordan_Gauss.Jordan_Gauss ( table: new double[, ] { { 4, -7, 8, -23 }, { 2, -4, 5, -13 }, { -3, 11, 1, 16 } }, resultTable: null ), indexRow: 1, indexColumn: 0 ); Console.WriteLine(value: Jordan_Gauss.PrintJordan_Gauss(data: actual)); CollectionAssert.AreEqual(expected: except, actual: actual.ResultTable); //шаг 2 except = new[, ] { { 0, 1, -2, 3 }, { 1, 0, -1.5D, -0.5D }, { 0, 0, 18.5D, -18.5D } }; actual = Jordan_Gauss.StepMethod ( data: new Jordan_Gauss.Jordan_Gauss (table: actual.Table, resultTable: actual.ResultTable), indexRow: 0, indexColumn: 1 ); Console.WriteLine(value: Jordan_Gauss.PrintJordan_Gauss(data: actual)); CollectionAssert.AreEqual(expected: except, actual: actual.ResultTable); //шаг 3 except = new double[, ] { { 0, 1, 0, 1 }, { 1, 0, 0, -2 }, { 0, 0, 1, -1 } }; actual = Jordan_Gauss.StepMethod ( data: new Jordan_Gauss.Jordan_Gauss (table: actual.Table, resultTable: actual.ResultTable), indexRow: 2, indexColumn: 2 ); Console.WriteLine(value: Jordan_Gauss.PrintJordan_Gauss(data: actual)); CollectionAssert.AreEqual(expected: except, actual: actual.ResultTable); //Метод с подным расчетом except = new double[, ] { { 1, 0, 0, -2 }, { 0, 1, 0, 1 }, { 0, 0, 1, -1 } }; actual = Jordan_Gauss.RunMethod ( data: new Jordan_Gauss.Jordan_Gauss ( table: new double[, ] { { 4, -7, 8, -23 }, { 2, -4, 5, -13 }, { -3, 11, 1, 16 } }, resultTable: null ) ); Console.WriteLine(value: Jordan_Gauss.PrintJordan_Gauss(data: actual)); CollectionAssert.AreEqual(expected: except, actual: actual.ResultTable); }
public void Decode_LowerCase(byte[] expectedOutput, string input) { var result = Base16.Decode(input.ToLowerInvariant()); CollectionAssert.AreEqual(expectedOutput, result); }
public void Decode(byte[] expectedOutput, string input) { var result = Base16.Decode(input); CollectionAssert.AreEqual(expectedOutput, result); }