public void ValidateObjectClasses_Sub_Type_Have_Unique_ObjectClasses_Should_Validate() { //arrange var subTypeMapping2 = new Mock <IObjectMapping>(); subTypeMapping2.Setup(x => x.Type) .Returns(typeof(Sub2AttributeClass)); subTypeMapping2.Setup(x => x.ObjectClasses) .Returns(new[] { "sub2" }); var baseTypeMapping = new Mock <IObjectMapping>(); baseTypeMapping.SetupGet(x => x.HasSubTypeMappings) .Returns(true); baseTypeMapping.SetupGet(x => x.ObjectClasses) .Returns(new[] { "base" }); baseTypeMapping.SetupGet(x => x.SubTypeMappings) .Returns(new ReadOnlyCollection <IObjectMapping>(new[] { subTypeMapping2.Object })); baseTypeMapping.Setup(x => x.Type) .Returns(typeof(AttributeClass)); var subTypeMapping = new Mock <IObjectMapping>(); subTypeMapping.Setup(x => x.Type) .Returns(typeof(SubAttributeClass)); subTypeMapping.Setup(x => x.ObjectClasses) .Returns(new[] { "sub" }); //act Executing.This(() => DirectoryMapper.ValidateObjectClasses(baseTypeMapping.Object, subTypeMapping.Object)) .Should() .NotThrow(); }
public void TestSingleFileNotUnique() { string testFolderPath = Path.Combine(currentDirectory, "TestSingleFileNotUnique"); MappedDirectory dir = DirectoryMapper.TryMapDirectories(SDVContentPath, testFolderPath, out IDictionary <string, string> errors); Assert.Null(dir); }
public void ValidateObjectClasses_Sub_Type_Has_Identical_ObjectClasses_To_Other_Sub_Type_Should_Throw_InvalidOperationException() { //arrange var subTypeMapping2 = new Mock <IObjectMapping>(); subTypeMapping2.Setup(x => x.Type) .Returns(typeof(Sub2AttributeClass)); subTypeMapping2.Setup(x => x.ObjectClasses) .Returns(new[] { "Sub", "top" }); var baseTypeMapping = new Mock <IObjectMapping>(); baseTypeMapping.SetupGet(x => x.ObjectClasses) .Returns(new[] { "base" }); baseTypeMapping.SetupGet(x => x.SubTypeMappings) .Returns(new ReadOnlyCollection <IObjectMapping>(new [] { subTypeMapping2.Object })); baseTypeMapping.SetupGet(x => x.HasSubTypeMappings) .Returns(true); baseTypeMapping.Setup(x => x.Type) .Returns(typeof(AttributeClass)); var subTypeMapping = new Mock <IObjectMapping>(); subTypeMapping.Setup(x => x.Type) .Returns(typeof(SubAttributeClass)); subTypeMapping.Setup(x => x.ObjectClasses) .Returns(new[] { "top", "sub" }); //act Executing.This(() => DirectoryMapper.ValidateObjectClasses(baseTypeMapping.Object, subTypeMapping.Object)) .Should() .Throw <InvalidOperationException>() .Exception.Message.Should() .Be.EqualTo( $"All sub types of {typeof(AttributeClass).Name} must have a unique sequence of objectClasses."); }
public void TestDirectContentExtraFile() { MappedDirectory dir = DirectoryMapper.TryMapDirectories(SDVContentPath, Path.Combine(currentDirectory, "TestDirectContentExtraFile"), out IDictionary <string, string> errors); Assert.NotNull(dir); Assert.AreEqual(dir.MappedFiles.Count, 0); }
public void TestSingleFileUniqueIndirect() { string testFolderPath = Path.Combine(currentDirectory, "TestSingleFileUniqueIndirect"); MappedDirectory dir = DirectoryMapper.TryMapDirectories(SDVContentPath, testFolderPath, out IDictionary <string, string> errors); Assert.NotNull(dir); Assert.AreEqual(dir.MappedFiles.Count, 1); Assert.AreEqual(dir.MappedFiles[0].RelativeFilePath, Path.Combine(testFolderPath, "test3.xnb")); Assert.AreEqual(dir.MappedFiles[0].RelativeMappedPath, Path.Combine(SDVContentPath, "Portraits", "test3.xnb")); }
public void TestDirectContent() { MappedDirectory dir = DirectoryMapper.TryMapDirectories(SDVContentPath, Path.Combine(currentDirectory, "TestDirectContent"), out IDictionary <string, string> errors); Assert.NotNull(dir); Assert.AreEqual(dir.MappedFiles.Count, 1); MappedFile file = dir.MappedFiles[0]; Assert.AreEqual(Path.Combine(currentDirectory, "TestDirectContent", "Content", "test.xnb"), file.RelativeFilePath); Assert.AreEqual(Path.Combine(currentDirectory, "Stardew Valley", "Content", "test.xnb"), file.RelativeMappedPath); }
static int Main(string[] args) { ParsedArguments parsedArgs = null; try { parsedArgs = ArgumentParser.Parse(args); } catch (Exception e) { Console.Error.WriteLine("An error occured when trying to parse command line arguments: "); Console.Error.WriteLine(e.ToString()); return(-1); } if (Path.GetFileName(parsedArgs.SDVContentRootDirectory) != "Content") { Console.Error.WriteLine($"\"{parsedArgs.SDVContentRootDirectory}\" doesn't look like a valid SDV Content Directory: "); Console.Error.WriteLine($"It doesn't point to a Content folder."); return(-1); } MappedDirectory mapping = DirectoryMapper.TryMapDirectories(parsedArgs.SDVContentRootDirectory, parsedArgs.ModRootDirectory, out IDictionary <string, string> errors); if (mapping == null) { Console.Error.WriteLine($"An error occured when trying to map the mod to the game's Content folder: "); foreach (KeyValuePair <string, string> errorinfo in errors) { Console.Error.WriteLine($"{errorinfo.Key} is invalid because: ${errorinfo.Value}"); } return(-1); } ContentPack p = new ContentPack(Path.Combine(Directory.GetCurrentDirectory(), "CP")); if (Directory.Exists(p.RootDirectory)) { Directory.Delete(p.RootDirectory, true); } Directory.CreateDirectory(p.RootDirectory); Console.WriteLine(p.RootDirectory); p.GenerateManifest(parsedArgs); ContentGenerator.GenerateContent(p.RootDirectory, mapping); return(0); }
public void SetUp() { _classMap = new Mock <IClassMap>(); _mapper = new DirectoryMapper(); //_mapper.AutoMapWith(type => // { // var mapType = typeof (AutoClassMap<>).MakeGenericType(type); // return // (IClassMap) Activator.CreateInstance(mapType); // }); //_mapper.AttributeMapWith(type => // { // var mapType = typeof (AttributeClassMap<>).MakeGenericType(type); // return // (IClassMap) Activator.CreateInstance(mapType); // }); }
public void ValidateObjectClasses_Sub_Type_Missing_ObjectClasses_Should_Throw_InvalidOperationException() { //arrange var baseTypeMapping = new Mock <IObjectMapping>(); baseTypeMapping.SetupGet(x => x.ObjectClasses) .Returns(new [] { "base" }); baseTypeMapping.Setup(x => x.Type) .Returns(typeof(AttributeClass)); var subTypeMapping = new Mock <IObjectMapping>(); subTypeMapping.Setup(x => x.Type) .Returns(typeof(SubAttributeClass)); //act Executing.This(() => DirectoryMapper.ValidateObjectClasses(baseTypeMapping.Object, subTypeMapping.Object)) .Should() .Throw <InvalidOperationException>() .Exception.Message.Should() .Be.EqualTo( $"In order to use subclass mapping {typeof(SubAttributeClass).Name} must be mapped with objectClasses"); }
/// <summary> /// Constructs an instance of this class and initializes <see cref="Mapper"/>. /// </summary> public LdapConfiguration() { Mapper = new DirectoryMapper(); }
public void SetUp() { _classMap = new Mock <IClassMap>(); _mapper = new DirectoryMapper(); }
public DirectoryRepository() { _Mapper = new DirectoryMapper(); }
public void TestDirectContentMissingFile() { MappedDirectory dir = DirectoryMapper.TryMapDirectories(SDVContentPath, Path.Combine(currentDirectory, "TestDirectContentMissingFile"), out IDictionary <string, string> errors); Assert.Null(dir); }