public void ValidityWithValidSamplesTest() { // Arrange byte[] inputBytes1 = File.ReadAllBytes(validSample1Filename); byte[] inputBytes2 = File.ReadAllBytes(validSample2Filename); byte[] inputBytes3 = File.ReadAllBytes(validSample3Filename); byte[] inputBytes4 = File.ReadAllBytes(validSample4Filename); // Act bool wasTest1Valid = false; string test1PossibleError = ""; using (MemoryStream ms1 = new MemoryStream(inputBytes1)) { (wasTest1Valid, test1PossibleError) = KtxLoader.CheckIfInputIsValid(ms1); } bool wasTest2Valid = false; string test2PossibleError = ""; using (MemoryStream ms2 = new MemoryStream(inputBytes2)) { (wasTest2Valid, test2PossibleError) = KtxLoader.CheckIfInputIsValid(ms2); } bool wasTest3Valid = false; string test3PossibleError = ""; using (MemoryStream ms3 = new MemoryStream(inputBytes3)) { (wasTest3Valid, test3PossibleError) = KtxLoader.CheckIfInputIsValid(ms3); } bool wasTest4Valid = false; string test4PossibleError = ""; using (MemoryStream ms4 = new MemoryStream(inputBytes4)) { (wasTest4Valid, test4PossibleError) = KtxLoader.CheckIfInputIsValid(ms4); } // Assert CollectionAssert.AreNotEqual(inputBytes1, inputBytes2, "Input files should NOT have equal content"); CollectionAssert.AreNotEqual(inputBytes1, inputBytes3, "Input files should NOT have equal content"); CollectionAssert.AreNotEqual(inputBytes1, inputBytes4, "Input files should NOT have equal content"); Assert.IsTrue(wasTest1Valid); Assert.IsTrue(wasTest2Valid); Assert.IsTrue(wasTest3Valid); Assert.IsTrue(wasTest4Valid); Assert.AreEqual("", test1PossibleError, "There should NOT be any errors"); Assert.AreEqual("", test2PossibleError, "There should NOT be any errors"); Assert.AreEqual("", test3PossibleError, "There should NOT be any errors"); Assert.AreEqual("", test4PossibleError, "There should NOT be any errors"); }
public void ValidityWithInvalidSamplesTest() { // Arrange byte[] inputBytes4 = File.ReadAllBytes(CommonFiles.validSample4Filename); // Act inputBytes4[73] = 0xC0; // Make string invalid UTF-8 inputBytes4[74] = 0xB1; bool wasTest4Valid = false; string test4PossibleError = ""; using (MemoryStream ms4 = new MemoryStream(inputBytes4)) { (wasTest4Valid, test4PossibleError) = KtxLoader.CheckIfInputIsValid(ms4); } // Assert Assert.IsFalse(wasTest4Valid); Assert.IsTrue(test4PossibleError.Contains("Byte array to UTF-8 failed")); }