74 lines
2.0 KiB
C#
74 lines
2.0 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Text;
|
|
using NUnit.Framework;
|
|
|
|
namespace isn.tests
|
|
{
|
|
public class Tests
|
|
{
|
|
private const int V = 0;
|
|
private const int V1 = 1;
|
|
|
|
public interface INeedEngine
|
|
{
|
|
object Parse(string code);
|
|
|
|
}
|
|
|
|
[SetUp]
|
|
public void Setup()
|
|
{
|
|
}
|
|
|
|
[Test]
|
|
public void HAveADefaultDataProtector()
|
|
{
|
|
string pass = "a lame and big pass";
|
|
isn.IDataProtector _protector = new isn.DefaultDataProtector();
|
|
string protectedpass = _protector.Protect(pass);
|
|
string unprotectedpass = _protector.UnProtect(protectedpass);
|
|
Console.WriteLine(protectedpass);
|
|
Assert.AreEqual(pass, unprotectedpass);
|
|
Assert.Pass($"Good jod man! (decoding {protectedpass})");
|
|
}
|
|
|
|
// Not a [Test]
|
|
public void TestParseCplus()
|
|
{
|
|
INeedEngine engine = new Engine();
|
|
IRing c = new Ring();
|
|
Assert.Equals((INeedEngine)engine.Parse("c+"), c.Add(Ring.One));
|
|
}
|
|
|
|
|
|
public void AssertIRingIsABody()
|
|
{
|
|
Ring c = new Ring();
|
|
Ring one = Ring.One;
|
|
Assert.True(c.Mult(one).Equals(c));
|
|
}
|
|
|
|
public void AssertIRingIsARing()
|
|
{
|
|
AssertIRingIsABody();
|
|
Ring c = new Ring();
|
|
IRing zero = Ring.Zero;
|
|
Assert.True(c.Add(zero).Equals(c));
|
|
}
|
|
|
|
[Test]
|
|
public void AssertReadInput()
|
|
{
|
|
var oldOut = Console.Out;
|
|
StringBuilder censoredTxt = new StringBuilder();
|
|
var newOut = new StringWriter(censoredTxt);
|
|
Console.SetOut(newOut);
|
|
Console.WriteLine("~~censored~~");
|
|
Console.SetOut(oldOut);
|
|
Console.Write("Hello ");
|
|
Console.Write(censoredTxt);
|
|
}
|
|
|
|
}
|
|
} |