public void Can_Dispose_Mutiple_Times_Without_Exception() { var sigGen = new Hmac256SignatureGenerator("dy33vQhksVsv"); var writer = new SignedRequestWriter(sigGen); writer.Dispose(); writer.Dispose(); writer.Dispose(); writer.Dispose(); }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> /// <remarks> /// <para>Once disposed, calls to most methods on this object with throw <see cref="ObjectDisposedException"/>.</para> /// <para>This method is safe to call multiple times in series. It is not guarateed to call in parallel, though no known issues exist.</para> /// </remarks> public void Dispose() { if (_IsDisposed) { return; } _IsDisposed = true; _Client?.Dispose(); _RequestWriter?.Dispose(); _SignatureGenerator?.Dispose(); }
public void Throws_On_WriteRequest_When_Disposed() { var sigGen = new Hmac256SignatureGenerator("dy33vQhksVsv"); var writer = new SignedRequestWriter(sigGen); writer.Dispose(); var request = new ProcessSalesAdjustmentReversalRequest() { MerchantId = "30299999", DeviceId = "d555", OperatorId = "test_operator", PosVersion = "123", ClientTransactionReference = "tnx-rev1", AdjustmentSignature = "ce20e2f1a9fe0d92b3d021ba7f1b372b006778cfab5fc4c09efa60a6d910c471" }; _ = writer.WriteRequest(request); }