public void GetsInternalAvcCorrectly() { //Arrange var json = new JObject(); json["spec_version"] = 1; json["identifier"] = "DogeCoinFlag"; json["version"] = "1.0.0"; json["download"] = "https://awesomemod.example/AwesomeMod.zip"; var sut = new ModuleService(); // Act var result = sut.GetInternalAvc(CkanModule.FromJson(json.ToString()), TestData.DogeCoinFlagAvcZip()); // Assert Assert.That(result, Is.Not.Null, "ModuleService should get an internal AVC file." ); Assert.That(result.version, Is.EqualTo(new Version("1.1.0")), "ModuleService should get correct version from the internal AVC file." ); Assert.That(result.ksp_version, Is.EqualTo(new KSPVersion("0.24.2")), "ModuleService should get correct ksp_version from the internal AVC file." ); Assert.That(result.ksp_version_min, Is.EqualTo(new KSPVersion("0.24.0")), "ModuleService should get correct ksp_version_min from the internal AVC file." ); Assert.That(result.ksp_version_max, Is.EqualTo(new KSPVersion("0.24.2")), "ModuleService should get correct ksp_version_max from the internal AVC file." ); }
public static int Main(string[] args) { try { ProcessArgs(args); if (Options.File != null) { Log.InfoFormat("Transforming {0}", Options.File); var moduleService = new ModuleService(); var fileService = new FileService(); var http = new CachingHttpService(FindCache(new KSPManager(new ConsoleUser(false)))); var netkan = ReadNetkan(); Log.Info("Finished reading input"); new NetkanValidator().Validate(netkan); Log.Info("Input successfully passed pre-validation"); var transformer = new NetkanTransformer( http, fileService, moduleService, Options.GitHubToken, Options.PreRelease ); var ckan = transformer.Transform(netkan); Log.Info("Finished transformation"); new CkanValidator(netkan, http, moduleService).Validate(ckan); Log.Info("Output successfully passed post-validation"); WriteCkan(ckan); } else { Log.Fatal( "Usage: netkan [--verbose|--debug] [--debugger] [--prerelease] [--outputdir=...] <filename>" ); return ExitBadOpt; } } catch (Exception e) { Log.Fatal(e.Message); if (Options == null || Options.Debug) { Log.Fatal(e.StackTrace); } return ExitError; } return ExitOk; }
public void GetsInternalCkanCorrectly() { // Arrange var sut = new ModuleService(); // Act var result = sut.GetInternalCkan(TestData.DogeCoinFlagZip()); // Assert Assert.That(result, Is.Not.Null, "ModuleService should get an internal CKAN file." ); Assert.That((string)result["identifier"], Is.EqualTo("DogeCoinFlag"), "ModuleService should get correct data for the internal CKAN file." ); }
public void HasInstallableFilesReturnsTrueWhenInstallableFiles() { // Arrange var zip = TestData.DogeCoinFlagZip(); var json = JObject.Parse(TestData.DogeCoinFlag_101()); var sut = new ModuleService(); // Act var result = sut.HasInstallableFiles(CkanModule.FromJson(json.ToString()), zip); // Assert Assert.IsTrue(result, "HasInstallableFiles() should return true when there are installable files." ); }
public void HasInstallableFilesReturnsFalseWhenNoInstallableFiles() { // Arrange var zip = TestData.DogeCoinFlagZip(); var json = JObject.Parse(TestData.DogeCoinFlag_101()); json["install"][0]["file"] = "DOES_NOT_EXIST"; var sut = new ModuleService(); // Act var result = sut.HasInstallableFiles(CkanModule.FromJson(json.ToString()), zip); // Assert Assert.IsFalse(result, "HasInstallableFiles() should return false when there are no installable files." ); }