public async Task GetPackageHashAsync_ReturnsPackageHashForSuccess() { var hashAlgorithm = "a"; var response = new GetPackageHashResponse(MessageResponseCode.Success, hash: "b"); var connection = new Mock <IConnection>(MockBehavior.Strict); connection.Setup(x => x.SendRequestAndReceiveResponseAsync <GetPackageHashRequest, GetPackageHashResponse>( It.Is <MessageMethod>(m => m == MessageMethod.GetPackageHash), It.Is <GetPackageHashRequest>(c => c.PackageId == _packageIdentity.Id && c.PackageVersion == _packageIdentity.Version.ToNormalizedString() && c.PackageSourceRepository == _packageSourceRepository && c.HashAlgorithm == hashAlgorithm), It.IsAny <CancellationToken>())) .ReturnsAsync(response); using (var test = PluginPackageDownloaderTest.Create()) { test.Plugin.SetupGet(x => x.Connection) .Returns(connection.Object); var packageHash = await test.Downloader.GetPackageHashAsync( hashAlgorithm, CancellationToken.None); Assert.Equal(response.Hash, packageHash); } }
public void Constructor_InitializesProperties() { var response = new GetPackageHashResponse(MessageResponseCode.Success, hash: "a"); Assert.Equal(MessageResponseCode.Success, response.ResponseCode); Assert.Equal("a", response.Hash); }
public void JsonSerialization_ReturnsCorrectJson( MessageResponseCode responseCode, string hash, string expectedJson) { var response = new GetPackageHashResponse(responseCode, hash); var actualJson = TestUtilities.Serialize(response); Assert.Equal(expectedJson, actualJson); }