// Copyright (c) Microsoft Corporation // The Microsoft Corporation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using Microsoft.VisualStudio.TestTools.UnitTesting; using SvgPreviewHandler.Utilities; using System.Text; namespace UnitTests_SvgPreviewHandler { [TestClass] public class SvgPreviewHandlerHelperTests { [TestMethod] public void CheckBlockedElements_ShouldReturnTrue_IfABlockedElementIsPresent() { // Arrange var svgBuilder = new StringBuilder(); svgBuilder.AppendLine(""); svgBuilder.AppendLine("\t"); svgBuilder.AppendLine(""); bool foundFilteredElement; // Act foundFilteredElement = SvgPreviewHandlerHelper.CheckBlockedElements(svgBuilder.ToString()); // Assert Assert.IsTrue(foundFilteredElement); } [TestMethod] public void CheckBlockedElements_ShouldReturnTrue_IfBlockedElementsIsPresentInNestedLevel() { // Arrange var svgBuilder = new StringBuilder(); svgBuilder.AppendLine(""); svgBuilder.AppendLine("\t"); svgBuilder.AppendLine("\t\t"); svgBuilder.AppendLine("\t"); svgBuilder.AppendLine(""); bool foundFilteredElement; // Act foundFilteredElement = SvgPreviewHandlerHelper.CheckBlockedElements(svgBuilder.ToString()); // Assert Assert.IsTrue(foundFilteredElement); } [TestMethod] public void CheckBlockedElements_ShouldReturnTrue_IfMultipleBlockedElementsArePresent() { // Arrange var svgBuilder = new StringBuilder(); svgBuilder.AppendLine(""); svgBuilder.AppendLine("\t"); svgBuilder.AppendLine("\t"); svgBuilder.AppendLine(""); bool foundFilteredElement; // Act foundFilteredElement = SvgPreviewHandlerHelper.CheckBlockedElements(svgBuilder.ToString()); // Assert Assert.IsTrue(foundFilteredElement); } [TestMethod] public void CheckBlockedElements_ShouldReturnFalse_IfNoBlockedElementsArePresent() { // Arrange var svgBuilder = new StringBuilder(); svgBuilder.AppendLine(""); svgBuilder.AppendLine("\t"); svgBuilder.AppendLine("\t"); svgBuilder.AppendLine(""); bool foundFilteredElement; // Act foundFilteredElement = SvgPreviewHandlerHelper.CheckBlockedElements(svgBuilder.ToString()); // Assert Assert.IsFalse(foundFilteredElement); } [DataTestMethod] [DataRow("")] [DataRow(" ")] [DataRow(null)] public void CheckBlockedElements_ShouldReturnFalse_IfSvgDataIsNullOrWhiteSpaces(string svgData) { // Arrange bool foundFilteredElement; // Act foundFilteredElement = SvgPreviewHandlerHelper.CheckBlockedElements(svgData); // Assert Assert.IsFalse(foundFilteredElement); } } }