public void ShouldSupportGeneratingCollections() { const int anyCount = 3; var list = Any.List <RecursiveInterface>(); var array = Any.Array <RecursiveInterface>(); var set = Any.Set <RecursiveInterface>(); var dictionary = Any.Dictionary <RecursiveInterface, ISimple>(); var sortedList = Any.SortedList <string, ISimple>(); var sortedDictionary = Any.SortedDictionary <string, ISimple>(); var sortedEnumerable = Any.EnumerableSortedDescending <string>(); var enumerable = Any.Enumerable <RecursiveInterface>(); var concurrentDictionary = Any.ConcurrentDictionary <string, ISimple>(); var concurrentBag = Any.ConcurrentBag <string>(); var concurrentQueue = Any.ConcurrentQueue <string>(); var concurrentStack = Any.ConcurrentStack <string>(); XAssert.All(assert => { assert.Equal(anyCount, list.Count); assert.Equal(anyCount, enumerable.Count()); assert.Equal(anyCount, array.Length); assert.Equal(anyCount, set.Count); assert.Equal(anyCount, dictionary.Count); assert.Equal(anyCount, sortedList.Count); assert.Equal(anyCount, sortedDictionary.Count); assert.Equal(anyCount, sortedEnumerable.Count()); assert.Equal(anyCount, concurrentDictionary.Count); assert.Equal(anyCount, concurrentBag.Count); assert.Equal(anyCount, concurrentStack.Count); assert.Equal(anyCount, concurrentQueue.Count); }); }
public void ShouldSupportGeneratingCollectionsUsingGenericInstanceMethod() { const int anyCount = 3; var list = Any.Instance <List <RecursiveInterface> >(); var array = Any.Instance <RecursiveInterface[]>(); var set = Any.Instance <HashSet <RecursiveInterface> >(); var dictionary = Any.Instance <Dictionary <RecursiveInterface, ISimple> >(); var sortedList = Any.Instance <SortedList <string, ISimple> >(); var sortedDictionary = Any.Instance <SortedDictionary <string, ISimple> >(); var enumerable = Any.Instance <IEnumerable <RecursiveInterface> >(); var concurrentDictionary = Any.Instance <ConcurrentDictionary <string, ISimple> >(); var concurrentStack = Any.Instance <ConcurrentStack <string> >(); var concurrentBag = Any.Instance <ConcurrentBag <string> >(); var concurrentQueue = Any.Instance <ConcurrentQueue <string> >(); XAssert.All(assert => { assert.Equal(anyCount, list.Count); assert.Equal(anyCount, enumerable.Count()); assert.Equal(anyCount, array.Length); assert.Equal(anyCount, set.Count); assert.Equal(anyCount, dictionary.Count); assert.Equal(anyCount, sortedList.Count); assert.Equal(anyCount, sortedDictionary.Count); assert.Equal(anyCount, concurrentDictionary.Count); assert.Equal(anyCount, concurrentStack.Count); assert.Equal(anyCount, concurrentBag.Count); assert.Equal(anyCount, concurrentQueue.Count); }); }
public void ShouldGeneratePickNextValueEachTimeFromPassedOnesWhenAskedToCreateAnyValueFromGiven() { //WHEN var int1 = Any.From(Enumerable.Range(1, 3).ToArray()); var int2 = Any.From(Enumerable.Range(1, 3).ToArray()); var int3 = Any.From(Enumerable.Range(1, 3).ToArray()); var int4 = Any.From(Enumerable.Range(1, 3).ToArray()); var int5 = Any.From(Enumerable.Range(5, 2).ToArray()); var int6 = Any.From(Enumerable.Range(10, 4).ToArray()); //THEN XAssert.All(assert => { assert.True(Enumerable.Range(1, 3).Contains(int1)); assert.True(Enumerable.Range(1, 3).Contains(int2)); assert.True(Enumerable.Range(1, 3).Contains(int3)); assert.True(Enumerable.Range(1, 3).Contains(int4)); assert.NotEqual(int1, int2); assert.NotEqual(int2, int3); assert.NotEqual(int3, int4); assert.True(Enumerable.Range(5, 2).Contains(int5)); assert.True(Enumerable.Range(10, 4).Contains(int6)); }); }
public void ShouldCorrectlyCompareCollectionsInAssertAll() { // GIVEN var x1 = new List <string> { "aaa", "bbb" }; var x2 = new List <string> { "aaa", "bbb" }; var exception = Assert.Throws <AssertionException>( () => XAssert.All(recorder => recorder.Equal(x1, x2)) ); StringAssert.Contains( "Expected actual to be {\"aaa\", \"bbb\"}, but found {\"aaa\", \"bbb\"}", exception.ToString()); XAssert.All(assert => assert.CollectionsEqual(x1, x2)); Assert.Throws <AssertionException>( () => XAssert.All(recorder => recorder.CollectionsEqual( x1, new List <string>() { "bbb", "aaa" })) ); }
public void ValidateCompleteness() { // TODO: Dig into whether ipcSend should be allowed in config HashSet <string> ignoredMethods = new HashSet <string>() { "ScheduleProcessPip", "WriteDataCore", "GetBuildXLBinDirectoryToBeDeprecated", "GetNewIpcMoniker", "GetBuildEngineDirectoryToBeDeprecated", }; // Extract string parameter for each InlineDataAttribute for each method. string[] inlineDataContent = this.GetType().GetMethods() .SelectMany(mi => mi.GetCustomAttributes <InlineDataAttribute>().Select(attr => (string)attr?.GetData(null)?.FirstOrDefault()[0])) .Select(s => s.Substring(0, s.IndexOf("("))) .ToArray(); XAssert.All(GetAmbientMethods(AmbientContext.ContextName, typeof(AmbientContext)) .Concat(GetAmbientMethods(AmbientTransformerOriginal.Name, typeof(AmbientTransformerOriginal))) .Concat(GetAmbientMethods(AmbientContract.ContractName, typeof(AmbientContract))) .Concat(GetAmbientMethods(AmbientFile.FileName, typeof(AmbientFile))) .ToArray(), funcName => XAssert.Contains(inlineDataContent, funcName)); IEnumerable <string> GetAmbientMethods(string name, System.Type type) { return(type.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.DeclaredOnly) .Where(mi => mi.ReturnType == typeof(EvaluationResult) && !ignoredMethods.Contains(mi.Name)) .Select(mi => $"{name}.{char.ToLowerInvariant(mi.Name[0])}{mi.Name.Substring(1)}")); } }
public void QualifiersAndGlobalPropertiesAreMergedPerQualifier() { var entryPointPath = m_builder.WriteProjectsWithReferences(("A", "<Project/>")); // let's 'build' for debug and release var requestedQualifiers = new GlobalProperties[] { new GlobalProperties(new Dictionary <string, string> { ["configuration"] = "debug" }), new GlobalProperties(new Dictionary <string, string> { ["configuration"] = "release" }), }; var globalProperties = new GlobalProperties(new Dictionary <string, string> { ["platform"] = "x86" }); var arguments = CreateBuilderArguments(entryPointPath, requestedQualifiers, globalProperties); var projectGraphWithPredictionsResult = BuildGraphAndDeserialize(arguments); Assert.True(projectGraphWithPredictionsResult.Succeeded); var nodes = projectGraphWithPredictionsResult.Result.ProjectNodes; // There should be two nodes, one per qualifier Assert.Equal(2, nodes.Count()); var debugNode = nodes.First(node => node.GlobalProperties["configuration"] == "debug"); var releaseNode = nodes.First(node => node.GlobalProperties["configuration"] == "release"); // Both nodes should have the same platform, since that's part of the global properties XAssert.All(nodes, node => Assert.Equal("x86", node.GlobalProperties["platform"])); }
public async Task TestSpec2SpecMapGeneratedByTypeChecker(SimpleGraph file2file) { var helper = new WorkspaceEvaluationHelper(TestOutputDirectory, null, forTesting: true); var repo = GenerateFullWorkspaceRepo(helper, file2file); var workspace = await helper.ParseAsync(repo); var semanticModel = helper.Typecheck(workspace); Func <int, AbsolutePath> specIdxToSpecPath = (specIdx) => SpecIdxToSpecPath(repo, specIdx); var relevantSpecPaths = file2file.Nodes.Select(specIdxToSpecPath).ToList(); Func <RoaringBitSet, IEnumerable <AbsolutePath> > materializeRelevant = (bitSet) => { bitSet.MaterializeSetIfNeeded(string.Empty, (s, i) => workspace.GetAllSourceFiles()[i].GetAbsolutePath(helper.PathTable)); return(bitSet.MaterializedSetOfPaths.Intersect(relevantSpecPaths)); }; // test the spec2spec map generated by TypeChecker XAssert.All( file2file.Nodes, specIdx => { var specSourceFile = workspace.GetSourceFile(SpecIdxToSpecPath(repo, specIdx)); var computedDependencies = materializeRelevant(semanticModel.GetFileDependenciesOf(specSourceFile)); var computedDependents = materializeRelevant(semanticModel.GetFileDependentFilesOf(specSourceFile)); var expectedDependents = file2file.OutgoingEdges(specIdx).Select(e => specIdxToSpecPath(e.Dest)); var expectedDependencies = file2file.IncomingEdges(specIdx).Select(e => specIdxToSpecPath(e.Src)); XAssert.SetEqual(expectedDependencies, computedDependents); XAssert.SetEqual(expectedDependents, computedDependencies); }); }
protected override void AssertPipGraphContent(PipGraph pipGraph, SimpleGraph file2file, StringTable stringTable) { AssertPipGraphCounts(pipGraph, new Dictionary <PipType, int> { [PipType.Process] = file2file.NodeCount, [PipType.SealDirectory] = file2file.NodeCount, }); var processPips = pipGraph.RetrievePipsOfType(PipType.Process).ToList(); // assert edges exist XAssert.All( file2file.Edges, edge => { var errPrefix = $"Edge ({edge.Src})->({edge.Dest}) not found: "; var srcPip = FindPipByTag(processPips, GetProcTag(edge.Src), stringTable); var destPip = FindPipByTag(processPips, GetProcTag(edge.Dest), stringTable); var producedSealDirectoryPips = pipGraph.RetrievePipImmediateDependents(destPip).Where(pip => pip.PipType == PipType.SealDirectory).ToList(); XAssert.AreEqual(1, producedSealDirectoryPips.Count, $"{errPrefix} expected to find exactly one SealDirectory dependency of Process Pip {destPip}"); var producedSealDirectoryPip = producedSealDirectoryPips.First(); var deps = pipGraph.RetrievePipImmediateDependents(producedSealDirectoryPip); if (!deps.Contains(srcPip)) { XAssert.Fail($"{errPrefix} expected edges between {srcPip} <-- {producedSealDirectoryPip} <-- {destPip}; dependencies of Pip {producedSealDirectoryPip} are: {XAssert.SetToString(deps)}"); } }); }
public void ShouldCorrectlyDetermineIfObjectIsOfTypeType() //this is not a typo! { XAssert.All(assert => { assert.False(TypeOfType.Is <object>()); assert.False(TypeOfType.Is <int>()); assert.True(TypeOfType.Is <Type>()); }); }
public void ShouldSoftlyMatchWithTddToolkitApi() { XAssert.All(assert => { //TODO change all assert.Equal(2, 2); assert.Equal(4, 4); assert.Equal(6, 6); }); }
public void ShouldSupportCreationOfKeyValuePairs() { var kvp = Any.Instance <KeyValuePair <string, RecursiveInterface> >(); XAssert.All(assert => { assert.NotNull(kvp.Key); assert.NotNull(kvp.Value); }); }
public void ShouldBeAbleToGenerateBothPrimitiveTypeInstanceAndInterfaceUsingNewInstanceMethod() { var primitive = Any.Instance <int>(); var interfaceImplementation = Any.Instance <ISimple>(); XAssert.All(assert => { assert.NotNull(interfaceImplementation); assert.NotEqual(default(int), primitive); }); }
public void ShouldBeAbleToGenerateInstancesOfAbstractClasses() { //GIVEN var createdProxy = Any.Instance <AbstractObjectWithInterfaceInConstructor>(); //THEN XAssert.All(assert => { assert.NotNull(createdProxy._constructorArgument); assert.NotNull(createdProxy._constructorNestedArgument); assert.NotEqual(default(int), createdProxy.AbstractInt); assert.NotEqual(default(int), createdProxy.SettableInt); }); }
internal static void AssertPipGraphCounts(PipGraph pipGraph, Dictionary <PipType, int> pipTypeCounts) { var pips = pipGraph.RetrieveScheduledPips().Where(p => NotMetaPip(p) && p.PipType != PipType.HashSourceFile).ToArray(); XAssert.All( pipTypeCounts, pipTypeAndCount => { AssertPipTypeCount(pips, pipTypeAndCount.Key, pipTypeAndCount.Value); }); var expectedTotalNonMetaPips = pipTypeCounts.Sum(t => t.Value); XAssert.AreEqual(expectedTotalNonMetaPips, pips.Count(), "Expected total number non-meta pips didn't match"); }
public void TestMapOrdering() { var result = EvaluateSpec(@" namespace M { const a = 'a/path'; const b = 'b/path'; const c = 'c/path'; const d = 'd/path'; const pa = [a, 1]; const pa1 = [a, 999]; const pb = [b, 2]; const pc = [c, 3]; const pd = [d, 4]; const ps1 = [pa, pb, pc]; const psDup: any = [...ps1, pa]; const psAdd: any = [...ps1, pa1]; const x = Map.empty().addRange(...psDup); const y = Map.empty().addRange(...psAdd); const z = x.remove(b); const w = x.add(pd[0], pd[1]).removeRange(a, c); const yKeys = y.keys(); const yValues = y.values(); export const checkX = checkKVP(x.toArray(), [pa, pb, pc]); export const checkY = checkKVP(y.toArray(), [pb, pc, pa1]); export const checkZ = checkKVP(z.toArray(), [pa, pc]); export const checkW = checkKVP(w.toArray(), [pb, pd]); export const checkYKeys = check(yKeys, [b, c, a]); export const checkYValues = check(yValues, [2, 3, 999]); function checkKVP(array1 : any[], array2 : any[]) { if (array1.length !== array2.length) return false; return array1.map((e, i) => e[0] === array2[i][0] && e[1] === array2[i][1]).all(b => b); } function check(array1 : any[], array2 : any[]) { if (array1.length !== array2.length) return false; return array1.map((e, i) => e === array2[i]).all(b => b); } }", new[] { "M.checkX", "M.checkY", "M.checkZ", "M.checkW", "M.checkYKeys", "M.checkYValues" }); result.ExpectNoError(); result.ExpectValues(6); XAssert.All(result.Values, e => Assert.Equal(true, e)); }
private void ExpectGraph(GraphReloadResult reloadResult, Pip[] oldPips, string expectedPipIndexesAsString, string expectedEdgesAsString) { int[] expectedPipIndexes = expectedPipIndexesAsString.Split(',').Select(i => int.Parse(i)).ToArray(); var graph = SimpleGraph.Parse(oldPips.Length, expectedEdgesAsString); var newPipGraph = reloadResult.PipGraph; var newPipTable = newPipGraph.PipTable; var newGraph = newPipGraph.DirectedGraph; // check that the new pip table contains expected number of relevant pips var allPipTypes = new HashSet <PipType>(oldPips.Select(pip => pip.PipType).Distinct()); IEnumerable <Pip> newRelevantPips = HydratePipsByType(newPipTable, relevantTypes: allPipTypes); Assert.Equal(expectedPipIndexes.Length, newRelevantPips.Count()); // check that for all expected pips there is a node in the new graph XAssert.All( expectedPipIndexes, idx => { Assert.True(newGraph.ContainsNode(oldPips[idx].PipId.ToNodeId()), $"No graph node found for Pip{idx}"); }); // check edges var newRelevantPipIdValues = new HashSet <uint>(newRelevantPips.Select(pip => pip.PipId.Value)); XAssert.All( expectedPipIndexes, idx => { var nodeId = oldPips[idx].PipId.ToNodeId(); var expectedOutgoingEdges = graph .Edges .Where(e => e.Src == idx) .Select(e => oldPips[e.Dest].PipId.ToNodeId().Value) .OrderBy(v => v) .ToArray(); var actualOutgoingEdges = newGraph .GetOutgoingEdges(nodeId) .Select(e => e.OtherNode.Value) .Where(v => newRelevantPipIdValues.Contains(v)) .OrderBy(v => v) .ToArray(); XAssert.AreArraysEqual(expectedOutgoingEdges, actualOutgoingEdges, expectedResult: true); }); // check stats Assert.Equal(expectedPipIndexes.Length, reloadResult.Stats.NumPipsReloaded); }
public void ValidProjectFileSucceedsAndAssemblyLocationsAreSetProperly() { // Write an empty project string entryPoint = @"<?xml version=""1.0"" encoding=""utf-8""?> <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003""/>"; var projectGraphWithPredictionsResult = BuildGraphAndDeserialize(entryPoint); // We expect the result to succeed Assert.True(projectGraphWithPredictionsResult.Succeeded); // The locations for MSBuild.exe and its assemblies should be properly set Assert.Contains(TestDeploymentDir, projectGraphWithPredictionsResult.PathToMsBuild); XAssert.All(projectGraphWithPredictionsResult.MsBuildAssemblyPaths.Values, assemblyPath => assemblyPath.Contains(TestDeploymentDir)); }
protected static void AssertEdges(PipGraph pipGraph, SimpleGraph file2file, List <Pip> pips, StringTable stringTable) { XAssert.All( file2file.Edges, edge => { var srcPip = FindPipByTag(pips, GetProcTag(edge.Src), stringTable); var destPip = FindPipByTag(pips, GetProcTag(edge.Dest), stringTable); var deps = pipGraph.RetrievePipImmediateDependencies(srcPip).ToList(); if (!deps.Contains(destPip)) { XAssert.Fail($"Edge ({edge.Src})->({edge.Dest}) not found: expected an edge between {srcPip} <-- {destPip}; dependencies of Pip {srcPip} are: {XAssert.SetToString(deps)}"); } }); }
public void ShouldGenerateMembersReturningTypeOfType() { //GIVEN var obj1 = Any.Instance <ISimple>(); var obj2 = Any.Instance <ISimple>(); //THEN XAssert.All(assert => { assert.NotNull(obj1.GetTypeProperty); assert.NotNull(obj2.GetTypeProperty); assert.NotEqual(obj1.GetTypeProperty, obj2.GetTypeProperty); assert.Equal(obj1.GetTypeProperty, obj1.GetTypeProperty); assert.Equal(obj2.GetTypeProperty, obj2.GetTypeProperty); }); }
public void ShouldSupportRecursiveInterfacesWithDictionaries() { var factories = Any.Enumerable <RecursiveInterface>().ToList(); var x = factories[0]; var y = x.NestedAsDictionary; var y1 = y.Keys.First(); var y2 = y.Values.First(); XAssert.All(assert => { assert.Equal(3, y.Count); assert.NotNull(y1); assert.NotNull(y2); }); }
public void ShouldBeAbleToGenerateDistinctDigitsEachTime() { //WHEN var char1 = Any.DigitChar(); var char2 = Any.DigitChar(); var char3 = Any.DigitChar(); //THEN XAssert.All(assert => { assert.NotEqual(char1, char2); assert.NotEqual(char2, char3); assert.True(Char.IsDigit(char1)); assert.True(Char.IsDigit(char2)); assert.True(Char.IsDigit(char3)); }); }
public void CorrectAssembliesAreSuccessfullyLoaded() { using (var reporter = new GraphBuilderReporter(Guid.NewGuid().ToString())) { var succeed = AssemblyLoader.TryLoadMsBuildAssemblies( // The test deployment dir should have all assemblies needed by the loader new [] { TestDeploymentDir }, reporter, out _, out var locatedAssemblyPaths, out var locatedMsBuildExePath); // We expect success Assert.True(succeed); // All located assemblies (and MSBuild.exe) should be the ones in the deployment directory XAssert.All(locatedAssemblyPaths.Values, locatedAssemblyPath => locatedAssemblyPath.StartsWith(TestDeploymentDir)); Assert.True(locatedMsBuildExePath.StartsWith(TestDeploymentDir)); } }
protected static void AssertMonikerConsistencyForIpcPip(IEnumerable <IpcPip> ipcPips, PipGraph pipGraph) { XAssert.All( ipcPips, ipcPip => { var servicePip = (Process)pipGraph.RetrievePipImmediateDependencies(ipcPip).FirstOrDefault(p => (p as Process)?.IsService == true); XAssert.IsNotNull(servicePip, $" could not find service pip dependency of ipc pip {ipcPip.PipId}"); var finalizationPip = pipGraph.PipTable.HydratePip(servicePip.ServiceInfo.ShutdownPipId, global::BuildXL.Pips.PipQueryContext.Test) as Process; XAssert.IsNotNull(finalizationPip, $" could not find finalization pip for ipc pip {ipcPip.PipId}"); var shutdownPip = pipGraph.PipTable.HydratePip(servicePip.ServiceInfo.FinalizationPipIds.First(), global::BuildXL.Pips.PipQueryContext.Test) as Process; XAssert.IsNotNull(shutdownPip, $" could not find shutdown pip for ipc pip {ipcPip.PipId}"); StringId servicePipMoniker = ExtractMonikerValueFromPipData(servicePip.Arguments); XAssert.AreEqual(servicePipMoniker, ExtractMonikerValueFromPipData(ipcPip.MessageBody), "service pip and ipc pip monikers don't match"); XAssert.AreEqual(servicePipMoniker, ExtractMonikerValueFromPipData(finalizationPip.Arguments), "service pip and finalization pip monikers don't match"); XAssert.AreEqual(servicePipMoniker, ExtractMonikerValueFromPipData(shutdownPip.Arguments), "service pip and shutdown pip monikers don't match"); }); }
public void ShouldAllowDepascalizationOfNUnitReportXml() { //GIVEN const string input = ExampleNUnitReport.Text; const string expectedReport = ExampleNUnitReport.DepascalizedText; var splitExpected = expectedReport.Split(new[] { '>' }, StringSplitOptions.None); var depascalization = new Depascalization.Transformation(); //WHEN var depascalizedVersion = depascalization.OfNUnitReport(input); //THEN var splitResult = depascalizedVersion.Split(new[] { '>' }, StringSplitOptions.None); XAssert.All(assert => { for (var i = 0; i < splitExpected.Length; i++) { assert.Equal(splitExpected[i].Trim(), splitResult[i].Trim(), i.ToString(CultureInfo.InvariantCulture)); } }); }
public void ShouldGenerateDifferentTypeEachTime() { //GIVEN var type1 = Any.Instance <Type>(); var type2 = Any.Instance <Type>(); var type3 = Any.Instance <Type>(); //THEN XAssert.All(assert => { assert.NotNull(type1); assert.NotNull(type2); assert.NotNull(type3); }); XAssert.All(assert => { assert.NotEqual(type1, type2); assert.NotEqual(type2, type3); assert.NotEqual(type3, type1); }); }
public void BasicFunctionalityTest() { var logDir = Path.Combine(TemporaryDirectory, nameof(TextLoggerTests), nameof(BasicFunctionalityTest)); var logFileName = "test.log"; var port = "60000"; var infoMessage = "Info"; var debugMessage = "Debug"; var errorMessage = "Error"; var warningMessage = "Warning"; var message = "none"; Directory.CreateDirectory(logDir); // create a logger and log a couple of messages string logFileFullPath = Path.Combine(logDir, logFileName + $"-{port}.log"); using (var logger = PluginLogUtils.GetLogger <TextLoggerTests>(logDir, logFileName, port)) { logger.Info(message); logger.Warning(message); logger.Error(message); logger.Debug(message); } // check that the log file was produced XAssert.FileExists(logFileFullPath); // check that the verbose message was not logged unless 'logVerbose' is true var logLines = File.ReadAllLines(logFileFullPath); // check that every line contains the prefix; XAssert.All(logLines, line => line.Contains(nameof(TextLoggerTests))); // check individual log messages XAssert.Contains(logLines[0], infoMessage); XAssert.Contains(logLines[1], warningMessage); XAssert.Contains(logLines[2], errorMessage); XAssert.Contains(logLines[3], debugMessage); }
public void ShouldAggregateMultipleAssertionsWhenAssertionAll() { var exception = Assert.Throws <AssertionException>(() => XAssert.All(assert => { assert.Equal(1, 3); assert.Equal(2, 44); assert.Equal("aa", "123"); assert.True(true); assert.Contains("bb", "aa"); }) ); StringAssert.Contains("Assertion no. 1 failed: Expected actual to be 1, but found 3", exception.ToString()); StringAssert.Contains("Assertion no. 2 failed: Expected actual to be 2, but found 44", exception.ToString()); StringAssert.Contains("Assertion no. 3 failed: Expected actual to be \"aa\", but found \"123\"", exception.ToString()); StringAssert.DoesNotContain("Assertion no. 4 failed", exception.ToString()); StringAssert.Contains("Assertion no. 5 failed: Expected expected \"bb\" to contain \"aa\"", exception.ToString()); }
private GraphReloadResult ReloadGraph(Pip[] procs, params int[] affectedIndexes) { XAssert.All(affectedIndexes, i => Assert.True(i >= 0 && i < procs.Length)); // add meta pips only for non-affected processes, because they should be present in the reloaded graph var nonAffectedIndexes = Enumerable.Range(0, procs.Length).Except(affectedIndexes); var nonAffectedProcs = nonAffectedIndexes.Select(i => procs[i]).ToArray(); // partially reload graph into the newly created PipGraph.Builder var builder = new PatchablePipGraph( oldPipGraph: PipGraphBuilder.DirectedGraph, oldPipTable: PipTable, graphBuilder: CreatePipGraphBuilder(), maxDegreeOfParallelism: Environment.ProcessorCount); var affectedSpecs = affectedIndexes.Select(i => procs[i].Provenance.Token.Path); var reloadingStats = builder.PartiallyReloadGraph(new HashSet <AbsolutePath>(affectedSpecs)); // build and return the new PipGraph together with the statistics of graph reloading return(new GraphReloadResult() { PipGraph = builder.Build(), Stats = reloadingStats }); }
public void BasicFunctionalityTest(bool logVerbose) { var logDir = Path.Combine(TemporaryDirectory, nameof(FileLoggerTests), nameof(BasicFunctionalityTest)); var logFileName = "test.log"; var monikerId = "moniker"; var prefix = "QWERTY"; var infoMessage = "imessage"; var warningMessage = "wmessage"; var errorMessage = "emessage"; var verboseMessage = "vmessage"; Directory.CreateDirectory(logDir); // create a logger and log a couple of messages string logFileFullPath = null; using (var logger = new FileLogger(logDir, logFileName, monikerId, logVerbose, prefix)) { XAssert.AreEqual(logVerbose, logger.IsLoggingVerbose); XAssert.AreEqual(prefix, logger.Prefix); logger.Info(infoMessage); logger.Warning(warningMessage); logger.Error(errorMessage); logger.Verbose(verboseMessage); logFileFullPath = logger.LogFilePath; } // check that the log file was produced XAssert.FileExists(logFileFullPath); // check that the verbose message was not logged unless 'logVerbose' is true var logLines = File.ReadAllLines(logFileFullPath); XAssert.AreEqual(logVerbose ? 4 : 3, logLines.Length); // check that every line contains the prefix; XAssert.All(logLines, line => line.Contains(prefix)); // check individual log messages XAssert.Contains(logLines[0], infoMessage); XAssert.Contains(logLines[1], warningMessage); XAssert.Contains(logLines[2], errorMessage); if (logVerbose) { XAssert.Contains(logLines[3], verboseMessage); } // create the same logger and assert that it's not going to overwrite the the old log file string logFile2FullPath = null; using (var logger2 = new FileLogger(logDir, logFileName, monikerId, logVerbose, prefix)) { XAssert.AreNotEqual(logFileFullPath, logger2.LogFilePath); logger2.Log(LogLevel.Info, "hi"); logFile2FullPath = logger2.LogFilePath; } XAssert.FileExists(logFileFullPath); XAssert.FileExists(logFile2FullPath); }
public void ShouldGenerateComplexGraphsWithNonNullPublicProperties() { var entity = Any.Instance <AreaEntity>(); XAssert.All(assert => { assert.NotNull(entity.Feature); }); }