public void TestTheBasics() { ISimple class1 = GoInterface <ISimple, SimpleClass> .From(new SimpleClass()); ISimple iface1 = GoInterface <ISimple, IDifferentName> .From(new SimpleClass()); ISimple struct1 = GoInterface <ISimple, SimpleStruct> .From(new SimpleStruct(10)); Assert.AreEqual(25, class1.Mutate(5)); Assert.AreEqual(25, iface1.Mutate(5)); Assert.AreEqual(70, struct1.Mutate(7)); SimpleBase class2 = GoInterface <SimpleBase, SimpleClass> .From(new SimpleClass()); SimpleBase iface2 = GoInterface <SimpleBase, IDifferentName> .From(new SimpleClass()); SimpleBase struct2 = GoInterface <SimpleBase, SimpleStruct> .From(new SimpleStruct(10)); for (int i = 0; i < 10; i++) { Assert.AreEqual(class1.Mutate(i), class2.Mutate(i)); Assert.AreEqual(iface1.Mutate(i), iface2.Mutate(i)); Assert.AreEqual(struct1.Mutate(i), struct2.Mutate(i)); } Assert.AreEqual("forwarded!", struct1.ToString()); Assert.AreEqual("forwarded!", struct2.ToString()); Assert.AreEqual(struct1.GetHashCode(), struct2.GetHashCode()); // Note that struct1.Equals(struct2) returns FALSE because struct2 is // not "really" a SimpleStruct. We must "unwrap" the right-hand side: Assert.That(struct1.Equals(GoInterface.Unwrap(struct2))); Assert.That(struct2.Equals(GoInterface.Unwrap(struct1))); }
public IActionResult GetSimple() => Content(_simple.ToString() + " " + _simple.GetHashCode());