public void AssemblyFromDirectoryAttribute_Succesfull(string line) { AttributesProcessor pr = new AttributesProcessor(_fileWrapper.Object, _pathWrapper.Object, _directory.Object); ScriptAnalyzerResult res = new ScriptAnalyzerResult(); _directory .Setup(x => x.GetFiles("c:\\hello", "*.dll", SearchOption.TopDirectoryOnly)) .Returns(new string[] { "c:\\hello\\test.dll", "c:\\hello\\test2.dll", }); _pathWrapper.Setup(x => x.GetExtension("c:\\hello\\test.dll")).Returns(".dll"); _pathWrapper.Setup(x => x.GetExtension("c:\\hello\\test2.dll")).Returns(".dll"); _fileWrapper.Setup(x => x.Exists("c:\\hello\\test.dll")).Returns(true); _fileWrapper.Setup(x => x.Exists("c:\\hello\\test2.dll")).Returns(true); pr.Process(res, line, 1); Assert.Equal("c:\\hello\\test.dll", res.AssemblyReferences.First().FullPath); Assert.Equal("c:\\hello\\test2.dll", res.AssemblyReferences[1].FullPath); _fileWrapper.VerifyAll(); _pathWrapper.VerifyAll(); _directory.VerifyAll(); }
public void IncludeAttribute_Succesfull(string line) { AttributesProcessor pr = new AttributesProcessor(_fileWrapper.Object, _pathWrapper.Object, _directory.Object); ScriptAnalyzerResult res = new ScriptAnalyzerResult(); pr.Process(res, line, 1); Assert.Contains("\\Test.cs", res.CsFiles[0]); }
/// <summary>Initializes all.</summary> /// <param name="processAttributes">if set to <see langword="true" /> [process attributes].</param> /// <param name="assembliesToScan">The assemblies to scan.</param> /// <exception cref="Exception">propertyComponentPool is null.</exception> internal void InitializeAll(bool processAttributes, IEnumerable <Assembly> assembliesToScan = null) { if (processAttributes) { IDictionary <Type, List <Attribute> > types; if (assembliesToScan == null) { #if FULLDOTNET || METRO || UNITY5 types = AttributesProcessor.Process(AttributesProcessor.SupportedAttributes); #else types = AttributesProcessor.Process(AttributesProcessor.SupportedAttributes, null); #endif } else { types = AttributesProcessor.Process(AttributesProcessor.SupportedAttributes, assembliesToScan); } foreach (KeyValuePair <Type, List <Attribute> > item in types) { #if METRO if (typeof(EntitySystem).GetTypeInfo().IsAssignableFrom(item.Key.GetTypeInfo())) #else if (typeof(EntitySystem).IsAssignableFrom(item.Key)) #endif { Type type = item.Key; ArtemisEntitySystem pee = (ArtemisEntitySystem)item.Value[0]; EntitySystem instance = (EntitySystem)Activator.CreateInstance(type); this.SetSystem(instance, pee.GameLoopType, pee.Layer, pee.ExecutionType); } #if METRO else if (typeof(IEntityTemplate).GetTypeInfo().IsAssignableFrom(item.Key.GetTypeInfo())) #else else if (typeof(IEntityTemplate).IsAssignableFrom(item.Key)) #endif { Type type = item.Key; ArtemisEntityTemplate pee = (ArtemisEntityTemplate)item.Value[0]; IEntityTemplate instance = (IEntityTemplate)Activator.CreateInstance(type); this.entityWorld.SetEntityTemplate(pee.Name, instance); } #if METRO else if (typeof(ComponentPoolable).GetTypeInfo().IsAssignableFrom(item.Key.GetTypeInfo())) #else else if (typeof(ComponentPoolable).IsAssignableFrom(item.Key)) #endif { this.CreatePool(item.Key, item.Value); } } } for (int index = 0, j = this.mergedBag.Count; index < j; ++index) { this.mergedBag.Get(index).LoadContent(); } }
public void NugetPackageAttribute_Succesfull(string line) { AttributesProcessor pr = new AttributesProcessor(_fileWrapper.Object, _pathWrapper.Object, _directory.Object); ScriptAnalyzerResult res = new ScriptAnalyzerResult(); pr.Process(res, line, 1); Assert.Equal("FlubuCore", res.NugetPackageReferences.First().Id); Assert.Equal("2.7.0", res.NugetPackageReferences.First().Version); }
public void IncludeFromDirectoryAttribute_Succesfull(string line, bool expectedIncludeSubDir) { AttributesProcessor pr = new AttributesProcessor(_fileWrapper.Object, _pathWrapper.Object, _directory.Object); ScriptAnalyzerResult res = new ScriptAnalyzerResult(); pr.Process(res, line, 1); Assert.Contains("\\Test", res.CsDirectories[0].Item1.path); Assert.Equal(expectedIncludeSubDir, res.CsDirectories[0].Item1.includeSubDirectories); }
public void AssemblyAttribute_Succesfull(string line) { AttributesProcessor pr = new AttributesProcessor(_fileWrapper.Object, _pathWrapper.Object, _directory.Object); ScriptAnalyzerResult res = new ScriptAnalyzerResult(); _pathWrapper.Setup(x => x.GetExtension("c:\\hello.dll")).Returns(".dll"); _fileWrapper.Setup(x => x.Exists("c:\\hello.dll")).Returns(true); pr.Process(res, line, 1); Assert.Equal("c:\\hello.dll", res.AssemblyReferences.First().FullPath); }
public void ScriptConfigAttributesTests(string line, ScriptConfigAttributes?expected) { AttributesProcessor pr = new AttributesProcessor(_fileWrapper.Object, _pathWrapper.Object, _directory.Object); ScriptAnalyzerResult res = new ScriptAnalyzerResult(); pr.Process(res, line, 1); if (expected.HasValue) { Assert.Contains(expected.Value, res.ScriptAttributes); } else { Assert.True(res.ScriptAttributes.Count == 0); } }
public void ScriptAttributes(string line, ScriptAttributes?expected) { AttributesProcessor pr = new AttributesProcessor(); ScriptAnalyzerResult res = new ScriptAnalyzerResult(); pr.Process(res, line, 1); if (expected.HasValue) { Assert.True(res.ScriptAttributes.Contains(expected.Value)); } else { Assert.True(res.ScriptAttributes.Count == 0); } }