public static CompilerResults CompileFile(string input, string output, params string[] references) { CreateOutput(output); List<string> referencedAssemblies = new List<string>(references.Length + 3); referencedAssemblies.AddRange(references); referencedAssemblies.Add("System.dll"); referencedAssemblies.Add(typeof(IModule).Assembly.CodeBase.Replace(@"file:///", "")); referencedAssemblies.Add(typeof(ModuleAttribute).Assembly.CodeBase.Replace(@"file:///", "")); CSharpCodeProvider codeProvider = new CSharpCodeProvider(); CompilerParameters cp = new CompilerParameters(referencedAssemblies.ToArray(), output); using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(input)) { if (stream == null) { throw new ArgumentException("input"); } StreamReader reader = new StreamReader(stream); string source = reader.ReadToEnd(); CompilerResults results = codeProvider.CompileAssemblyFromSource(cp, source); ThrowIfCompilerError(results); return results; } }
public void TestLoadAndRunDynamic() { var cities = new Cities(); cities.ReadCities(CitiesTestFile); IRoutes routes = RoutesFactory.Create(cities); routes.ReadRoutes(LinksTestFile); Assert.AreEqual(11, cities.Count); // test available cities List<Link> links = routes.FindShortestRouteBetween("Zürich", "Basel", TransportModes.Rail); var expectedLinks = new List<Link>(); expectedLinks.Add(new Link(new City("Zürich", "Switzerland", 7000, 1, 2), new City("Aarau", "Switzerland", 7000, 1, 2), 0)); expectedLinks.Add(new Link(new City("Aarau", "Switzerland", 7000, 1, 2), new City("Liestal", "Switzerland", 7000, 1, 2), 0)); expectedLinks.Add(new Link(new City("Liestal", "Switzerland", 7000, 1, 2), new City("Basel", "Switzerland", 7000, 1, 2), 0)); Assert.IsNotNull(links); Assert.AreEqual(expectedLinks.Count, links.Count); for (int i = 0; i < links.Count; i++) { Assert.AreEqual(expectedLinks[i].FromCity.Name, links[i].FromCity.Name); Assert.AreEqual(expectedLinks[i].ToCity.Name, links[i].ToCity.Name); } links = routes.FindShortestRouteBetween("doesNotExist", "either", TransportModes.Rail); Assert.IsNull(links); }
public void ArrayLiterals() { var array = new[] { 42 }; Assert.AreEqual(typeof(int[]), array.GetType(), "You don't have to specify a type if the elements can be inferred"); Assert.AreEqual(new int[] { 42 }, array, "These arrays are literally equal... But you won't see this string in the error message."); //Are arrays 0-based or 1-based? Assert.AreEqual(42, array[((int)FILL_ME_IN)], "Well, it's either 0 or 1.. you have a 110010-110010 chance of getting it right."); //This is important because... Assert.IsTrue(array.IsFixedSize, "...because Fixed Size arrays are not dynamic"); //Begin RJG // Moved this Throws() call to a separate FixedSizeArraysCannotGrow() method below //...it means we can't do this: array[1] = 13; //Assert.Throws(typeof(FILL_ME_IN), delegate() { array[1] = 13; }); //End RJG //This is because the array is fixed at length 1. You could write a function //which created a new array bigger than the last, copied the elements over, and //returned the new array. Or you could do this: var dynamicArray = new List<int>(); dynamicArray.Add(42); CollectionAssert.AreEqual(array, dynamicArray.ToArray(), "Dynamic arrays can grow"); dynamicArray.Add(13); CollectionAssert.AreEqual((new int[] { 42, (int)FILL_ME_IN }), dynamicArray.ToArray(), "Identify all of the elements in the array"); }
public void InsertAll_InsertItems_WithTypeHierarchyBase() { using (var db = Context.Sql()) { if (db.Database.Exists()) { db.Database.Delete(); } db.Database.Create(); List<Person> people = new List<Person>(); people.Add(Person.Build("FN1", "LN1")); people.Add(Person.Build("FN2", "LN2")); people.Add(Person.Build("FN3", "LN3")); EFBatchOperation.For(db, db.People).InsertAll(people); } using (var db = Context.Sql()) { var contacts = db.People.OrderBy(c => c.FirstName).ToList(); Assert.AreEqual(3, contacts.Count); Assert.AreEqual("FN1", contacts.First().FirstName); } }
public void LifeCycleCycleTestBlinker() { List<Cell> blinkerTextCellsVertical = new List<Cell>(); blinkerTextCellsVertical.Add(new Cell(2, 1)); blinkerTextCellsVertical.Add(new Cell(2, 2)); blinkerTextCellsVertical.Add(new Cell(2, 3)); LifeCycle lifeCycle = new LifeCycle(blinkerTextCellsVertical); lifeCycle.Cycle(); Assert.IsTrue(lifeCycle.checkCellCollectionForCell(lifeCycle.Cells, new Cell(1, 2))); Assert.IsTrue(lifeCycle.checkCellCollectionForCell(lifeCycle.Cells, new Cell(2, 2))); Assert.IsTrue(lifeCycle.checkCellCollectionForCell(lifeCycle.Cells, new Cell(3, 2))); Assert.IsFalse(lifeCycle.checkCellCollectionForCell(lifeCycle.Cells, new Cell(2, 3))); Assert.IsTrue(lifeCycle.Cells.Count == 3); lifeCycle.Cycle(); Assert.IsTrue(lifeCycle.checkCellCollectionForCell(lifeCycle.Cells, new Cell(2, 1))); Assert.IsTrue(lifeCycle.checkCellCollectionForCell(lifeCycle.Cells, new Cell(2, 2))); Assert.IsTrue(lifeCycle.checkCellCollectionForCell(lifeCycle.Cells, new Cell(2, 3))); Assert.IsFalse(lifeCycle.checkCellCollectionForCell(lifeCycle.Cells, new Cell(1, 2))); Assert.IsTrue(lifeCycle.Cells.Count == 3); }
public void DuplicateActivations() { const int nRunnerGrains = 100; const int nTargetGRain = 10; const int startingKey = 1000; const int nCallsToEach = 100; var runnerGrains = new ICatalogTestGrain[nRunnerGrains]; var promises = new List<Task>(); for (int i = 0; i < nRunnerGrains; i++) { runnerGrains[i] = GrainClient.GrainFactory.GetGrain<ICatalogTestGrain>(i.ToString(CultureInfo.InvariantCulture)); promises.Add(runnerGrains[i].Initialize()); } Task.WhenAll(promises).Wait(); promises.Clear(); for (int i = 0; i < nRunnerGrains; i++) { promises.Add(runnerGrains[i].BlastCallNewGrains(nTargetGRain, startingKey, nCallsToEach)); } Task.WhenAll(promises).Wait(); }
public void CollisionComparison() { CollisionDictionary d = new CollisionDictionary(); List<PhysicalObject2D> allSprites = new List<PhysicalObject2D>(); for (int i=0; i<1000000; i++) { Sprite s = new Sprite(this, "blocky"); s.Size = new Vector2(10); s.Position = i * s.Size; d.Add(s.Bounds); allSprites.Add(s); } Sprite firstSprite = new Sprite(this, "blocky"); firstSprite.Size = new Vector2(50); firstSprite.Position = new Vector2(300); allSprites.Add(firstSprite); Stopwatch sw = Stopwatch.StartNew(); DoConventionalCollisionCheck(firstSprite, allSprites); Console.WriteLine(sw.ElapsedMilliseconds); sw = Stopwatch.StartNew(); d.CalculateCollisions(firstSprite.Bounds); Console.WriteLine(sw.ElapsedMilliseconds); }
internal static void MakeDeepCopies(List<ModelHelperInfo> modelHelperInfos, int cCopies, string directory) { int cModels = modelHelperInfos.Count; for (int iCopy = 0; iCopy < cCopies - 1; iCopy++) { for (int iModel = 0; iModel < cModels; iModel++) { ModelHelperInfo modelHelperInfo = modelHelperInfos[iModel]; ModelHelperInfo modelHelperInfoCopy = ModelHelperInfo.Create(directory); foreach (DeploymentModelStepsStep step in modelHelperInfo.modelHelper.AllSteps) { List<string> commandParamStrings = new List<string>(); for (int iCommandParam = 0; iCommandParam < step.CommandParam.Length; iCommandParam++) { commandParamStrings.Add(step.CommandParam[iCommandParam].Name); commandParamStrings.Add(step.CommandParam[iCommandParam].ParameterName); } modelHelperInfoCopy.modelHelper.AddStep(step.Type, step.Command, step.Message, commandParamStrings.ToArray()); } IEnumerable<DeploymentModelParametersParameter> dmParams = modelHelperInfo.modelHelper.AllParameters; foreach (DeploymentModelParametersParameter dmParam in dmParams) { modelHelperInfoCopy.modelHelper.AddParameter(dmParam.Name, dmParam.Value, dmParam.Required, dmParam.ValuePrefixRef, dmParam.ValueSuffix); } modelHelperInfos.Add(modelHelperInfoCopy); } } }
public static List<Endereco> GetEnderecos() { List<Endereco> enderecos = new List<Endereco>(); Pessoa pessoa = new Pessoa(); pessoa.Nome = "Bruno3"; pessoa.DataNascimento = new DateTime(1995, 06, 01, 0, 0, 0); pessoa.Cpf = "0911095678"; pessoa.Profissao = "Tester"; Endereco endereco1 = new Endereco(); endereco1.Rua = "João"; endereco1.Numero = 98; endereco1.Cep = "0911095679"; endereco1.Cidade = "Lages"; endereco1.Pessoa = pessoa; Endereco endereco2 = new Endereco(); endereco2.Rua = "João"; endereco2.Numero = 98; endereco2.Cep = "0911095679"; endereco2.Cidade = "Lages"; endereco2.Pessoa = pessoa; enderecos.Add(endereco1); enderecos.Add(endereco2); return enderecos; }
public void FindPeaksTest() { Bitmap hand = Properties.Resources.rhand; GaussianBlur median = new GaussianBlur(1.1); median.ApplyInPlace(hand); // Extract contour BorderFollowing bf = new BorderFollowing(1); List<IntPoint> contour = bf.FindContour(hand); hand = hand.Clone(new Rectangle(0, 0, hand.Width, hand.Height), PixelFormat.Format24bppRgb); // Find peaks KCurvature kcurv = new KCurvature(30, new DoubleRange(0, 45)); // kcurv.Suppression = 30; var peaks = kcurv.FindPeaks(contour); List<IntPoint> supports = new List<IntPoint>(); for (int i = 0; i < peaks.Count; i++) { int j = contour.IndexOf(peaks[i]); supports.Add(contour[(j + kcurv.K) % contour.Count]); supports.Add(contour[Accord.Math.Tools.Mod(j - kcurv.K, contour.Count)]); } // show(hand, contour, peaks, supports); Assert.AreEqual(2, peaks.Count); Assert.AreEqual(46, peaks[0].X); Assert.AreEqual(0, peaks[0].Y); Assert.AreEqual(2, peaks[1].X); Assert.AreEqual(11, peaks[1].Y); }
public void Test1Test() { var Values = new List<int>(); var Thread1 = new GreenThread(); var Thread2 = new GreenThread(); Thread1.InitAndStartStopped(() => { Values.Add(1); GreenThread.Yield(); Values.Add(3); }); Thread2.InitAndStartStopped(() => { Values.Add(2); GreenThread.Yield(); Values.Add(4); }); Thread.Sleep(20); // Inits stopped. Assert.AreEqual("[]", Values.ToJson()); Thread1.SwitchTo(); Assert.AreEqual("[1]", Values.ToJson()); Thread2.SwitchTo(); Assert.AreEqual("[1,2]", Values.ToJson()); Thread.Sleep(20); Thread1.SwitchTo(); Assert.AreEqual("[1,2,3]", Values.ToJson()); Thread2.SwitchTo(); Assert.AreEqual("[1,2,3,4]", Values.ToJson()); }
public void TestExcelExport() { string excelFileName = Directory.GetCurrentDirectory() + @"\ExportTest.xlsx"; City bern = new City("Bern", "Switzerland", 5000, 46.95, 7.44); City zuerich = new City("Zürich", "Switzerland", 100000, 32.876174, 13.187507); City aarau = new City("Aarau", "Switzerland", 10000, 35.876174, 12.187507); Link link1 = new Link(bern, aarau, 15, TransportModes.Ship); Link link2 = new Link(aarau, zuerich, 20, TransportModes.Ship); List<Link> links = new List<Link>(); links.Add(link1); links.Add(link2); // TODO: Fix starting Excel on sever (not robust) ExcelExchange excel = new ExcelExchange(); Console.WriteLine("Export Path is: {0}", excelFileName); excel.WriteToFile(excelFileName, bern, zuerich, links); // first verify that file exists Assert.IsTrue(File.Exists(excelFileName)); // now verify the content of the file // TODO: Fix reading file on sever VerifyExcelContent(excelFileName); }
public void TestMethod1() { List<KeyValuePair<string, string>> mongoEnv = new List<KeyValuePair<string, string>>(); mongoEnv.Add(new KeyValuePair<string, string>("MongoServer", "localhost")); mongoEnv.Add(new KeyValuePair<string, string>("MongoPort", "27017")); mongoEnv.Add(new KeyValuePair<string, string>("MongoRepositorySvcConfig", "ServiceConfig")); ServiceComponentProvider scp = new ServiceComponentProvider(mongoEnv); ServiceComponent sc = new ServiceComponent() { Assembly = "theAssembly", Class = "theClass", CommandMessageQueue = "theQueue", Config = "theConfig", CreateDate = DateTime.UtcNow, Creator = string.Format(@"{0}\{1}", Environment.UserDomainName, Environment.UserName), IsActive = false, IsPaused = false, Machine = Environment.MachineName, ParamsAssembly = "paramsAssembly", ParamsClass = "paramsClass" }; Guid origId = sc.Id; scp.Insert(sc); ServiceComponent sc2 = scp.Queryable().Single(x => x.Id == origId); Assert.AreEqual<Guid>(origId, sc2.Id); scp.Delete(sc2); }
public void Population_GetBestChromosome() { List<City> cities = new List<City>(); cities.Add(new City(1, 1, "A")); cities.Add(new City(2, 2, "B")); cities.Add(new City(3, 3, "C")); cities.Add(new City(4, 4, "D")); cities.Add(new City(5, 5, "E")); List<City> cities2 = new List<City>(); cities2.Add(new City(1, 1, "A")); cities2.Add(new City(5, 5, "B")); cities2.Add(new City(3, 3, "C")); cities2.Add(new City(4, 4, "D")); cities2.Add(new City(2, 2, "E")); Population p = new Population(); Chromosome c = new Chromosome(cities); Chromosome c2 = new Chromosome(cities2); p.Add(c); p.Add(c2); Chromosome best = p.GetBestChromosome(); Assert.AreEqual(c, best); }
public async Task DeadlockDetection_2() { long bBase = 100; for (int i = 0; i < numIterations; i++) { long grainId = i; IDeadlockNonReentrantGrain firstGrain = GrainClient.GrainFactory.GetGrain<IDeadlockNonReentrantGrain>(grainId); List<Tuple<long, bool>> callChain = new List<Tuple<long, bool>>(); callChain.Add(new Tuple<long, bool>(grainId, true)); callChain.Add(new Tuple<long, bool>(bBase + grainId, true)); callChain.Add(new Tuple<long, bool>(grainId, true)); try { await firstGrain.CallNext_1(callChain, 1); } catch (Exception exc) { Exception baseExc = exc.GetBaseException(); logger.Info(baseExc.Message); Assert.AreEqual(typeof(DeadlockException), baseExc.GetType()); DeadlockException deadlockExc = (DeadlockException)baseExc; Assert.AreEqual(callChain.Count, deadlockExc.CallChain.Count()); } } }
public void GetAggregatedValueTest() { var cell1 = new Mock<Cell>(); var cell2 = new Mock<Cell>(); var cell3 = new Mock<Cell>(); var cell4 = new Mock<Cell>(); cell1.Setup(foo => foo.Content).Returns((double)0.6); cell2.Setup(foo => foo.Content).Returns((double)3); cell3.Setup(foo => foo.Content).Returns((double)0.3); cell4.Setup(foo => foo.Content).Returns((double)0.1); List<Cell> cells = new List<Cell>(); cells.Add(cell1.Object); cells.Add(cell2.Object); cells.Add(cell3.Object); MinAggregation target = new MinAggregation(); double expected = 0.3; double actual; actual = (double)target.GetAggregatedValue(cells); Assert.AreEqual(expected, actual); cells.Add(cell4.Object); expected = 0.1; actual = (double)target.GetAggregatedValue(cells); Assert.AreEqual(expected, actual); }
public void CheckIteratorTest() { Executeable<int> identity = (Func<int, int>)((int x) => x); Executeable<int> linearfunction = (Func<int, int>)((int x) => 3 * x - 2); Executeable<int> quadraticfunction = (Func<int, int>)((int x) => 2 * x * x - 5); Executeable<int> cubicfunction = (Func<int, int>)((int x) => x * x * x + x * x + x + 1); List<Executeable<int>> functions = new List<Executeable<int>>(); functions.Add(identity); functions.Add(linearfunction); functions.Add(quadraticfunction); functions.Add(cubicfunction); Composition<int> comp = new Composition<int>(functions.ToArray()); int[] tab0 = new int[] { 0, -2, -5, 1 }; int[] tab1 = new int[] { 1, 1, -3, 4 }; int[] tab2 = new int[] { 2, 4, 3, 15 }; int i = 0; foreach (var f in comp) { Assert.AreEqual((int)f.Execute(0), tab0[i]); Assert.AreEqual((int)f.Execute(1), tab1[i]); Assert.AreEqual((int)f.Execute(2), tab2[i]); i++; } }
public void GoodFileCommaDelimitedNamesInFirstLineNLnl() { // Arrange List<ProductData> dataRows_Test = new List<ProductData>(); dataRows_Test.Add(new ProductData { retailPrice = 4.59M, name = "Wooden toy", startDate = DateTime.Parse("1/2/2008"), nbrAvailable = 67 }); dataRows_Test.Add(new ProductData { onsale = true, weight = 4.03, shopsAvailable = "Ashfield", description = "" }); dataRows_Test.Add(new ProductData { name = "Metal box", launchTime = DateTime.Parse("5/11/2009 4:50"), description = "Great\nproduct" }); CsvFileDescription fileDescription_namesNl2 = new CsvFileDescription { SeparatorChar = ',', FirstLineHasColumnNames = true, EnforceCsvColumnAttribute = false, TextEncoding = Encoding.Unicode, FileCultureName = "nl-Nl" // default is the current culture }; string expected = @"name,startDate,launchTime,weight,shopsAvailable,code,price,onsale,description,nbrAvailable,unusedField Wooden toy,1-2-2008,01 jan 00:00:00,""000,000"",,0,""€ 4,59"",False,,67, ,1-1-0001,01 jan 00:00:00,""004,030"",Ashfield,0,""€ 0,00"",True,"""",0, Metal box,1-1-0001,05 nov 04:50:00,""000,000"",,0,""€ 0,00"",False,""Great product"",0, "; // Act and Assert AssertWrite(dataRows_Test, fileDescription_namesNl2, expected); }
public void TestWritableTransportServer() { BlockingCollection<WritableString> queue = new BlockingCollection<WritableString>(); List<string> events = new List<string>(); IPEndPoint endpoint = new IPEndPoint(IPAddress.Any, 0); var remoteHandler = Observer.Create<TransportEvent<WritableString>>(tEvent => queue.Add(tEvent.Data)); using (var server = new WritableTransportServer<WritableString>(endpoint, remoteHandler, _tcpPortProvider, _injector)) { server.Run(); IPEndPoint remoteEndpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), server.LocalEndpoint.Port); using (var client = new WritableTransportClient<WritableString>(remoteEndpoint, _injector)) { client.Send(new WritableString("Hello")); client.Send(new WritableString(", ")); client.Send(new WritableString("World!")); events.Add(queue.Take().Data); events.Add(queue.Take().Data); events.Add(queue.Take().Data); } } Assert.AreEqual(3, events.Count); Assert.AreEqual(events[0], "Hello"); Assert.AreEqual(events[1], ", "); Assert.AreEqual(events[2], "World!"); }
public void TestRequest() { new TestConfigure().TestInitialize(); Products produto1 = new Products() { Weight = 1, CostOfGoods = 2, Width = 0.1, Height = 0.1, Length = 0.1, Quantity = 1, SkuId = "123", description = "produto 1", CanGroup = false }; Products produto2 = new Products() { Weight = 1, CostOfGoods = 2, Width = 0.1, Height = 0.1, Length = 0.1, Quantity = 1, SkuId = "123", description = "produto 1", CanGroup = false }; List<Products> produtos = new List<Products>(); produtos.Add(produto1); produtos.Add(produto2); var modelRequest = new Request<Quote>() { Content = new Quote() { OriginZipCode = "01001-000", DestinationZipCode = "20000-000", Products = produtos, AddtionalInformation = new AddtionalInformation() { FreeShipping = false, ExtraCostsAbsolute = 0, ExtraCostsPercentage = 0, LeadTimeBussinessDays = 0, DeliveryMethodIds = new int[] {1,2} } } }; try { var modelResponse = new API.QuoteByProduct().RequestNewQuoteByProduct(modelRequest,"fc8e9d156fcfb48fbfe4c66febac48acce84e5af"); Assert.IsFalse(modelResponse.Status == "ERROR", "Houve algum problema na requisição, por favor, verifique o Log gerado para esta resposta da requisição."); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public void Test_Parsing_Names_Contains_No_First_Names() { // Arrange List<string> names = new List<string>(); names.Add("Bob, Alice"); names.Add("Redfield, Chris"); names.Add("Valentine, "); names.Add("Redfield, Claire"); names.Add("Smith, Agent"); // Act Person[] people = _nameParser.ParseNames(names.ToArray()); // Assert Assert.IsNotNull(people); Assert.AreEqual(5, people.Length); Assert.AreEqual("Bob", people[0].LastName); Assert.AreEqual("Alice", people[0].FirstName); Assert.AreEqual("Redfield", people[1].LastName); Assert.AreEqual("Chris", people[1].FirstName); Assert.AreEqual("Valentine", people[2].LastName); Assert.AreEqual(string.Empty, people[2].FirstName); Assert.AreEqual("Redfield", people[3].LastName); Assert.AreEqual("Claire", people[3].FirstName); Assert.AreEqual("Smith", people[4].LastName); Assert.AreEqual("Agent", people[4].FirstName); }
public static string Find() { if (!_found) { _found = true; try { var regKey = Registry.CurrentUser.OpenSubKey(@"Software\Valve\Steam"); if (regKey == null) return null; var searchCandidates = new List<string>(); var installPath = Path.GetDirectoryName(regKey.GetValue("SourceModInstallPath").ToString()); searchCandidates.Add(installPath); var steamPath = regKey.GetValue("SteamPath").ToString(); var config = File.ReadAllText(Path.Combine(steamPath, @"config", @"config.vdf")); var match = Regex.Match(config, "\"BaseInstallFolder_\\d\"\\s+\"(.+?)\""); while (match.Success) { if (match.Groups.Count > 1) { var candidate = Path.Combine(match.Groups[1].Value.Replace(@"\\", @"\"), "SteamApps"); searchCandidates.Add(candidate); } match = match.NextMatch(); } _value = (from searchCandidate in searchCandidates where searchCandidate != null && Directory.Exists(searchCandidate) select Path.Combine(searchCandidate, @"common", @"assettocorsa")).FirstOrDefault(Directory.Exists); } catch (Exception) { // ignored } } return _value; }
public void testDefaultClauseSimplifier() { FOLDomain domain = new FOLDomain(); domain.addConstant("ZERO"); domain.addConstant("ONE"); domain.addPredicate("P"); domain.addFunction("Plus"); domain.addFunction("Power"); FOLParser parser = new FOLParser(domain); List<TermEquality> rewrites = new List<TermEquality>(); rewrites.Add((TermEquality)parser.parse("Plus(x, ZERO) = x")); rewrites.Add((TermEquality)parser.parse("Plus(ZERO, x) = x")); rewrites.Add((TermEquality)parser.parse("Power(x, ONE) = x")); rewrites.Add((TermEquality)parser.parse("Power(x, ZERO) = ONE")); DefaultClauseSimplifier simplifier = new DefaultClauseSimplifier( rewrites); Sentence s1 = parser .parse("((P(Plus(y,ZERO),Plus(ZERO,y)) OR P(Power(y, ONE),Power(y,ZERO))) OR P(Power(y,ZERO),Plus(y,ZERO)))"); CNFConverter cnfConverter = new CNFConverter(parser); CNF cnf = cnfConverter.convertToCNF(s1); Assert.AreEqual(1, cnf.getNumberOfClauses()); Clause simplified = simplifier.simplify(cnf.getConjunctionOfClauses() [0]); Assert.AreEqual("[P(y,y), P(y,ONE), P(ONE,y)]", simplified .ToString()); }
//[TestMethod] public void TestRedirectFileGeneration() { var originalFile = @"E:\Index\mscorlib\A.html"; var lines = File.ReadAllLines(originalFile); var list = new List<KeyValuePair<string, string>>(); var map = new Dictionary<string, string>(); foreach (var line in lines) { if (line.Length > 25 && line[0] == 'm') { if (line[22] == '"') { var id = line.Substring(3, 16); var file = line.Substring(23, line.Length - 25); list.Add(new KeyValuePair<string, string>(id, file)); map[id] = file; } else if (line[22] == 'm') { var id = line.Substring(3, 16); var other = line.Substring(25, 16); list.Add(new KeyValuePair<string, string>(id, map[other])); } } } Microsoft.SourceBrowser.HtmlGenerator.ProjectGenerator.GenerateRedirectFile( @"E:\Solution", @"E:\Solution\Project", list.ToDictionary(kvp => kvp.Key, kvp => (IEnumerable<string>)new List<string> { kvp.Value })); }
public void TestGroupingsAnnualAndMonthlyGroupingsGiveTwoGroupRoots() { List<Grouping> grouping = new List<Grouping>(); grouping.Add(new Grouping { IndicatorId = 1, SexId = 1, BaselineYear = 2001, BaselineQuarter = -1, DataPointYear = 2001, DataPointQuarter = -1 }); grouping.Add(new Grouping { IndicatorId = 1, SexId = 1, BaselineYear = 2001, BaselineQuarter = -1, BaselineMonth = 1, DataPointYear = 2001, DataPointQuarter = -1, DataPointMonth = 1 }); GroupRootBuilder builder = new GroupRootBuilder(); IList<GroupRoot> roots = builder.BuildGroupRoots(grouping); Assert.AreEqual(2, roots.Count); }
public void WriteToFileTest() { //--Arrange var changedItems = new List<ILoggable>(); var customer = new Customer(1) { EmailAddress = "*****@*****.**", FirstName = "Frodo", LastName = "Baggins", AddressList = null }; changedItems.Add(customer as ILoggable); var product = new Product(2) { ProductName = "Rake", ProductDescription = "Garden Rake with Steel handle", CurrentPrice = 6M }; changedItems.Add(product as ILoggable); //--Act LoggingService.WriteToFile(changedItems); //--Assert //Nothing to assert }
public void DifferentMarginTest() { var request = new Request(); request.ProductHierarchy = new List<Relation>(this.hierarchy); request.GeographyHierarchy = new List<Relation>(this.hierarchy); request.SalesComponentHierarchy = new List<Relation>(this.hierarchy); request.PeriodHierarchy = new List<Relation>(); request.Sales = new List<ConcreteFact>(); request.Sales.AddRange(makeDuetos(4, 7, 4, 7, 4, 7, 1, 10, 100)); //including facts for each period request.Margins = Enumerable.Range(1, 10).SelectMany(r => { var facts = new List<NullableFact>(); facts.Add(new NullableFact() { TimeId = (short)r, ProductId = 2, Value = 0.15f }); facts.Add(new NullableFact() { TimeId = (short)r, ProductId = 3, Value = 0.25f }); return facts; }).ToList(); request.Spend = new List<NullableFact>() { new NullableFact() { ProductId = 1, GeographyId = 1, Value = 100 } }; // no adjustments request.Adjustments = null; var calculator = new CalculatorService(); var result = calculator.CalculateRoi(request); Assert.AreEqual(1, result.Count); Assert.AreEqual(128f, result.Single().Value, 0.0001); }
public void InsertAll_InsertItems_WithTypeHierarchy() { using (var db = Context.Sql()) { if (db.Database.Exists()) { db.Database.Delete(); } db.Database.Create(); List<Contact> people = new List<Contact>(); people.Add(Contact.Build("FN1", "LN1", "Director")); people.Add(Contact.Build("FN2", "LN2", "Associate")); people.Add(Contact.Build("FN3", "LN3", "Vice President")); EFBatchOperation.For(db, db.People).InsertAll(people); } using (var db = Context.Sql()) { var contacts = db.People.OfType<Contact>().OrderBy(c => c.FirstName).ToList(); Assert.AreEqual(3, contacts.Count); Assert.AreEqual("FN1", contacts.First().FirstName); Assert.AreEqual("Director", contacts.First().Title); } }
public async Task ObterRotaComPedagioTest() { var mockRequestJSON = new Mock<IRequestJSON>(); mockRequestJSON.Setup(t => t.GetJSON(It.IsAny<string>(), It.IsAny<string>())).ReturnsAsync("{ routes: [{ summary: { duration: 1000, distance: 2000, tollFees:[ { prices: { car: 10 } }, { prices: { car: 20 } } ] } }]}"); IRoteirizacaoApi roteirizacaoApiV0 = new RoteirizacaoApiV0(mapLinkSignature, mockRequestJSON.Object, apiConfig); var listaCoordendas = new List<CoordenadasModel>(); listaCoordendas.Add(new CoordenadasModel { Latitude = 100, Longitude = 200 }); listaCoordendas.Add(new CoordenadasModel { Latitude = 200, Longitude = 300 }); listaCoordendas.Add(new CoordenadasModel { Latitude = 300, Longitude = 400 }); var rota = await roteirizacaoApiV0.ObterRota(listaCoordendas, 12, "car"); Assert.AreEqual(rota.TempoTotal, 1000.0); Assert.AreEqual(rota.Distancia, 2000.0); Assert.AreEqual(rota.CustoTotal, 30.0); }
public void TestReviewerIndexRedirectsInNoAccess3() { #region Arrange Controller.ControllerContext.HttpContext = new MockHttpContext(1, new[] { "" }, "*****@*****.**"); var editors = new List<Editor>(); editors.Add(CreateValidEntities.Editor(1)); editors.Add(CreateValidEntities.Editor(2)); editors.Add(CreateValidEntities.Editor(3)); editors[1].ReviewerEmail = "*****@*****.**"; var calls = new List<CallForProposal>(); calls.Add(CreateValidEntities.CallForProposal(1)); calls[0].Editors = editors; var fakeCalls = new FakeCallForProposals(); fakeCalls.Records(2, CallForProposalRepository, calls); #endregion Arrange #region Act Controller.ReviewerIndex(1, StaticValues.RB_Decission_Denied, "*****@*****.**") .AssertActionRedirect() .ToAction<ProposalController>(a => a.Home()); #endregion Act #region Assert Assert.AreEqual("You do not have access to that.", Controller.Message); #endregion Assert }