public void Build_PutsAllPathHashesIntoAlternatePathHashes_ExceptLatest() { var metadata = new TransactionMetadata(); metadata.SetCrossApplicationPathHash("pathHash1"); metadata.SetCrossApplicationPathHash("pathHash2"); metadata.SetCrossApplicationPathHash("pathHash3"); var immutableMetadata = metadata.ConvertToImmutableMetadata(); NrAssert.Multiple( () => Assert.AreEqual("pathHash3", immutableMetadata.CrossApplicationPathHash), () => Assert.AreEqual(2, immutableMetadata.CrossApplicationAlternatePathHashes.Count()), () => Assert.IsTrue(immutableMetadata.CrossApplicationAlternatePathHashes.Contains("pathHash1")), () => Assert.IsTrue(immutableMetadata.CrossApplicationAlternatePathHashes.Contains("pathHash2")) ); }
public void Build_HasZeroAlternatePathHashesIfSetOnce() { var metadata = new TransactionMetadata(); metadata.SetCrossApplicationPathHash("pathHash1"); var immutableMetadata = metadata.ConvertToImmutableMetadata(); NrAssert.Multiple( () => Assert.AreEqual("pathHash1", immutableMetadata.CrossApplicationPathHash), () => Assert.AreEqual(0, immutableMetadata.CrossApplicationAlternatePathHashes.Count()) ); }
public void Build_OnlyRetainsACertainNumberOfAlternatePathHashes() { var maxPathHashes = PathHashMaker.AlternatePathHashMaxSize; var transactionMetadata = new TransactionMetadata(); Enumerable.Range(0, maxPathHashes + 2).ForEach(number => transactionMetadata.SetCrossApplicationPathHash($"pathHash{number}")); var immutableMetadata = transactionMetadata.ConvertToImmutableMetadata(); NrAssert.Multiple( () => Assert.AreEqual($"pathHash{PathHashMaker.AlternatePathHashMaxSize + 1}", immutableMetadata.CrossApplicationPathHash), () => Assert.AreEqual(PathHashMaker.AlternatePathHashMaxSize, immutableMetadata.CrossApplicationAlternatePathHashes.Count()), () => Assert.IsFalse(immutableMetadata.CrossApplicationAlternatePathHashes.Contains($"pathHash{PathHashMaker.AlternatePathHashMaxSize + 1}")) ); }