Example #1
0
        public void GetsModCorrectly()
        {
            // Arrange
            var sut = new KerbalstuffApi(new CachingHttpService(_cache));

            // Act
            var result = sut.GetMod(493); // PlaneMode

            // Assert
            var latestVersion = result.Latest();

            Assert.That(result.id, Is.EqualTo(493));
            Assert.That(result.author, Is.Not.Null);
            Assert.That(result.background, Is.Not.Null);
            Assert.That(result.license, Is.Not.Null);
            Assert.That(result.name, Is.Not.Null);
            Assert.That(result.short_description, Is.Not.Null);
            Assert.That(result.source_code, Is.Not.Null);
            Assert.That(result.website, Is.Not.Null);
            Assert.That(result.versions.Length, Is.GreaterThan(0));
            Assert.That(latestVersion.changelog, Is.Not.Null);
            Assert.That(latestVersion.download_path, Is.Not.Null);
            Assert.That(latestVersion.friendly_version, Is.Not.Null);
            Assert.That(latestVersion.KSP_version, Is.Not.Null);
        }
Example #2
0
 public override object ReadJson(
     JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer
     )
 {
     if (reader.Value != null)
     {
         return(KerbalstuffApi.ExpandPath(reader.Value.ToString()));
     }
     return(null);
 }
Example #3
0
        public void ThrowsWhenModMissing()
        {
            // Arrange
            var sut = new KerbalstuffApi(new CachingHttpService(_cache));

            // Act
            TestDelegate act = () => sut.GetMod(-1);

            // Assert
            Assert.That(act, Throws.Exception.InstanceOf<Kraken>());
        }
Example #4
0
 /// <summary>
 /// Returns the path to the mod's home on KerbalStuff
 /// </summary>
 /// <returns>The home.</returns>
 public Uri GetPageUrl()
 {
     return(KerbalstuffApi.ExpandPath(string.Format("/mod/{0}/{1}", id, name)));
 }