private void Assert_ProcessedBranches(CircuitProcessingResult result, int expectedBranchCount) { if (result.ProcessedBranchCount != expectedBranchCount) { throw new AssertException(string.Format( "The circuit processed {0} branches, but {1} were expected instead.", result.ProcessedBranchCount, expectedBranchCount )); } }
private void Assert_Cancelled( CircuitProcessingResult result, CircuitCancellationReason expectedReason, BlockType expectedComponentType = BlockType.Invalid ) { if (result.CancellationReason != expectedReason) { if (expectedReason == CircuitCancellationReason.None) { throw new AssertException(string.Format( "It was expected that the circuit is not cancelled, but it was. Reason: {0}, Component: {1}.", result.CancellationReason, TerrariaUtils.Tiles.GetBlockTypeName(result.CancellationRelatedComponentType) )); } else if (result.CancellationReason == CircuitCancellationReason.None) { throw new AssertException(string.Format("The circuit was expected to be cancelled, but it was not.")); } else { throw new AssertException(string.Format( "The circuit was cancelled with the reason {0}, but {1} was expected instead.", result.CancellationReason, expectedReason )); } } if (result.CancellationRelatedComponentType != expectedComponentType) { if (expectedComponentType == BlockType.Invalid) { throw new AssertException(string.Format( "The circuit was cancelled with the expected reason, but there is a related component \"{0}\" which was not expected.", TerrariaUtils.Tiles.GetBlockTypeName(result.CancellationRelatedComponentType) )); } else if (result.CancellationRelatedComponentType == BlockType.Invalid) { throw new AssertException(string.Format( "The circuit was cancelled with the expected reason but no related component, \"{0}\" where was expected.", TerrariaUtils.Tiles.GetBlockTypeName(expectedComponentType) )); } else { throw new AssertException(string.Format( "The circuit was cancelled with the expected reason, but the related component is \"{0}\" instead of \"{1}\".", TerrariaUtils.Tiles.GetBlockTypeName(result.CancellationRelatedComponentType), TerrariaUtils.Tiles.GetBlockTypeName(expectedComponentType) )); } } }
private void Assert_SignaledPortDefiningComponents(CircuitProcessingResult result, int expectedComponentCount) { if (result.SignaledPortDefiningComponentsCounter != expectedComponentCount) { throw new AssertException(string.Format( "The circuit signaled {0} port defining components, but {1} were expected instead.", result.SignaledPortDefiningComponentsCounter, expectedComponentCount )); } }