Пример #1
0
 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 }));
 }
Пример #2
0
        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);
        }
Пример #3
0
        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>();
        }
Пример #4
0
        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);
            }
        }
Пример #5
0
 public void NullableParamsAndReturnValue(int?left, int?right, int?expected)
 {
     Assert.AreEqual(expected, TestContract.AddNullables(left, right));
 }
Пример #6
0
 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()));
 }
Пример #7
0
 public void ParamsAndReturnValue(int left, int right, int expected)
 {
     Assert.AreEqual(expected, TestContract.Add(left, right));
 }