public void Execute_ShouldPrintExistingConfig_WhenConfigExistsInGitRepo() { var console = Container.Resolve <IConsole>(); var factory = Container.Resolve <IGitDependFileFactory>(); string dir; ReturnCode loadCode = ReturnCode.Success; factory.Arrange(f => f.LoadFromDirectory(Arg.AnyString, out dir, out loadCode)) .Returns(Lib2Config); StringBuilder output = new StringBuilder(); console.Arrange(c => c.WriteLine(Arg.AnyObject)) .DoInstead((object obj) => { output.AppendLine(obj.ToString()); }); var options = new ConfigSubOptions(); var instance = new ConfigCommand(options); var code = instance.Execute(); Assert.AreEqual(ReturnCode.Success, code, "Invalid Return Code"); Assert.AreEqual(Lib2Config.ToString() + Environment.NewLine, output.ToString()); }
public void LoadFromDirectory_ShoulReturnExistingFile_WhenGitDependFileExistsInGitRepo() { var fileSystem = RegisterMockFileSystem(); var instance = new GitDependFileFactory(); string directory = @"C:\projects\GitDepend"; fileSystem.Directory.CreateDirectory(directory); fileSystem.Directory.CreateDirectory(fileSystem.Path.Combine(directory, ".git")); var path = fileSystem.Path.Combine(directory, "GitDepend.json"); fileSystem.File.WriteAllText(path, Lib2Config.ToString()); string dir; ReturnCode code; var config = instance.LoadFromDirectory(directory, out dir, out code); Assert.IsNotNull(config, "Config file should not be null"); Assert.AreEqual(directory, dir, "Invalid directory"); Assert.AreEqual(ReturnCode.Success, code, "Invalid Return Code"); Assert.AreEqual(Lib2Config.ToString(), config.ToString(), "File does not match"); }
public void ToStringTest() { var expected = "{\r\n" + " \"name\": \"Lib2\",\r\n" + " \"build\": {\r\n" + " \"script\": \"make.bat\"\r\n" + " },\r\n" + " \"packages\": {\r\n" + " \"dir\": \"artifacts/NuGet/Debug\"\r\n" + " },\r\n" + " \"dependencies\": [\r\n" + " {\r\n" + " \"url\": \"https://github.com/kjjuno/Lib1.git\",\r\n" + " \"dir\": \"..\\\\Lib1\",\r\n" + " \"branch\": \"develop\"\r\n" + " }\r\n" + " ]\r\n" + "}"; var actual = Lib2Config.ToString(); Assert.AreEqual(expected, actual); }