public void Overload() { Assert.AreEqual(8, TestContract.Sum(new int?[] { 1, 0, 2, 5 })); Assert.AreEqual(100, TestContract.Sum(new int?[] { 10, 15, 20, 55 })); Assert.AreEqual(52000, TestContract.Sum(new int?[] { 2000, 50000 })); Assert.AreEqual(50000, TestContract.Sum(new int?[] { null, 50000 })); Assert.AreEqual(0, TestContract.Sum(new int?[] { null, null })); }
public async Task ConnectionId() { // The connection Id is global, so we don't have a reliable way to check if the value is correct // as the connection counter is shared between Server instances. Assert.IsNull(TestContractInstance.LatestConnectionId); TestContract.SimpleMethod(); await Task.Delay(1000); Assert.IsNotNull(TestContractInstance.LatestConnectionId); }
public void Setup() { Server = new LinkServer(); TestContractInstance = new TestContract(); Server.RegisterContractImplementation <ITestContract, TestContract>(TestContractInstance); Server.Start(8080); // Give the server a second to fire up. Thread.Sleep(1000); Client = new LinkClient(); Client.Setup("127.0.0.1", 8080); TestContract = Client.GetContract <ITestContract>(); }
public async Task ConnectionIdMultipleClients() { // The connection Id is global, so we don't have a reliable way to check if the value is correct // as the connection counter is shared between Server instances. Assert.IsNull(TestContractInstance.LatestConnectionId); TestContract.SimpleMethod(); var connId = TestContractInstance.LatestConnectionId; Assert.IsNotNull(connId); using (var client = new LinkClient()) { client.Setup("127.0.0.1", 8080); await Task.Delay(1000); client.GetContract <ITestContract>().SimpleMethod(); await Task.Delay(1000); Assert.AreNotEqual(connId, TestContractInstance.LatestConnectionId); } }
public void NullableParamsAndReturnValue(int?left, int?right, int?expected) { Assert.AreEqual(expected, TestContract.AddNullables(left, right)); }
public void CollectionParam(IEnumerable <int> numbers, int expected) { Assert.AreEqual(expected, TestContract.Sum(numbers.ToArray())); Assert.AreEqual(expected, TestContract.Sum(numbers.ToList())); Assert.AreEqual(expected, TestContract.Sum(numbers.ToHashSet())); }
public void ParamsAndReturnValue(int left, int right, int expected) { Assert.AreEqual(expected, TestContract.Add(left, right)); }