public void Format_EmptyResourceChanges_ReturnsNoChangeInfo() { // Arrange. var psWhatIfOperationResult = new PSWhatIfOperationResult(new WhatIfOperationResult()); string noChangeInfo = new ColoredStringBuilder() .AppendLine() .Append("Resource changes: no change.") .ToString(); // Act. string result = WhatIfOperationResultFormatter.Format(psWhatIfOperationResult); // Assert. Assert.Contains(noChangeInfo, result); }
public void Format_OnSuccess_FormatPreviewNotice() { // Arrange. var psWhatIfOperationResult = new PSWhatIfOperationResult(new WhatIfOperationResult()); string previewNotice = new ColoredStringBuilder() .AppendLine("Note: As What-If is currently in preview, the result may contain false positive predictions (noise).") .AppendLine("You can help us improve the accuracy of the result by opening an issue here: https://aka.ms/WhatIfIssues.") .ToString(); // Act. string result = WhatIfOperationResultFormatter.Format(psWhatIfOperationResult); // Assert. Assert.StartsWith(previewNotice, result); }
public void Format_NonEmptyResourceChanges_AddsStatsAtTheEnd() { // Arrange. var whatIfChanges = new List <WhatIfChange> { new WhatIfChange { ResourceId = "", ChangeType = ChangeType.Create }, new WhatIfChange { ResourceId = "", ChangeType = ChangeType.Create }, new WhatIfChange { ResourceId = "", ChangeType = ChangeType.Modify }, new WhatIfChange { ResourceId = "", ChangeType = ChangeType.Delete } }; string stats = new ColoredStringBuilder() .AppendLine() .Append("Resource changes: 1 to delete, 2 to create, 1 to modify.") .ToString(); // Act. string result = WhatIfOperationResultFormatter.Format( new PSWhatIfOperationResult(new WhatIfOperationResult(changes: whatIfChanges))); // Assert. Assert.EndsWith(stats, result); }