Add MD5, SHA1 information to ConanComponent (#733)
This commit is contained in:
Родитель
2b86e05499
Коммит
168315b7a1
|
@ -9,16 +9,24 @@ public class ConanComponent : TypedComponent
|
|||
// reserved for deserialization
|
||||
}
|
||||
|
||||
public ConanComponent(string name, string version)
|
||||
public ConanComponent(string name, string version, string previous, string packageId)
|
||||
{
|
||||
this.Name = this.ValidateRequiredInput(name, nameof(this.Name), nameof(ComponentType.Conan));
|
||||
this.Version = this.ValidateRequiredInput(version, nameof(this.Version), nameof(ComponentType.Conan));
|
||||
this.Md5Hash = this.ValidateRequiredInput(previous, nameof(this.Md5Hash), nameof(ComponentType.Conan));
|
||||
this.Sha1Hash = this.ValidateRequiredInput(packageId, nameof(this.Sha1Hash), nameof(ComponentType.Conan));
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Version { get; set; }
|
||||
|
||||
public string Md5Hash { get; set; }
|
||||
|
||||
public string Sha1Hash { get; set; }
|
||||
|
||||
public string PackageSourceURL => $"https://conan.io/center/recipes/{this.Name}?version={this.Version}";
|
||||
|
||||
public override ComponentType Type => ComponentType.Conan;
|
||||
|
||||
public override string Id => $"{this.Name} {this.Version} - {this.Type}";
|
||||
|
|
|
@ -36,7 +36,7 @@ public class ConanLockNode
|
|||
|
||||
internal string Name() => this.Reference == null ? string.Empty : this.Reference.Split('/', 2, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).FirstOrDefault("Unknown");
|
||||
|
||||
internal TypedComponent ToComponent() => new ConanComponent(this.Name(), this.Version());
|
||||
internal TypedComponent ToComponent() => new ConanComponent(this.Name(), this.Version(), this.Previous, this.PackageId);
|
||||
|
||||
internal string Version() => this.Reference == null ? string.Empty : this.Reference.Split('/', 2, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Skip(1).FirstOrDefault("None");
|
||||
}
|
||||
|
|
|
@ -125,13 +125,18 @@ public class TypedComponentSerializationTests
|
|||
[TestMethod]
|
||||
public void TypedComponent_Serialization_Conan()
|
||||
{
|
||||
TypedComponent tc = new ConanComponent("SomeConanPackage", "1.2.3");
|
||||
var md5 = Guid.NewGuid().ToString();
|
||||
var sha1Hash = Guid.NewGuid().ToString();
|
||||
TypedComponent tc = new ConanComponent("SomeConanPackage", "1.2.3", md5, sha1Hash);
|
||||
var result = JsonConvert.SerializeObject(tc);
|
||||
var deserializedTC = JsonConvert.DeserializeObject<TypedComponent>(result);
|
||||
deserializedTC.Should().BeOfType(typeof(ConanComponent));
|
||||
var conanComponent = (ConanComponent)deserializedTC;
|
||||
conanComponent.Name.Should().Be("SomeConanPackage");
|
||||
conanComponent.Version.Should().Be("1.2.3");
|
||||
conanComponent.Md5Hash.Should().Be(md5);
|
||||
conanComponent.Sha1Hash.Should().Be(sha1Hash);
|
||||
conanComponent.PackageSourceURL.Should().Be("https://conan.io/center/recipes/SomeConanPackage?version=1.2.3");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
|
Загрузка…
Ссылка в новой задаче