示例#1
0
文件: AsyncTests.cs 项目: zplus/csnng
        private void Given_two_connected_sockets(ConnectedSocketsCallback callback)
        {
            var addr = TestAddr;

            Section($"given two connected sockets", () =>
            {
                LatestPairSocket s1 = null;
                LatestPairSocket s2 = null;

                try
                {
                    s1 = CreateOne <LatestPairSocket>();
                    s2 = CreateOne <LatestPairSocket>();

                    s1.Listen(addr);
                    s2.Dial(addr);

                    callback(s1, s2);
                }
                finally
                {
                    DisposeAll(s1, s2);
                }
            });
        }
示例#2
0
文件: AsyncTests.cs 项目: zplus/csnng
        private void Failure_mode_assumptions(FailureModeDelegate callback)
        {
            Section("failure modes work", () =>
            {
                LatestPairSocket s = null;

                // We will leverage the Fixtured Done field.
                BasicAsyncServiceFixture svc = null;

                try
                {
                    s = CreateOne <LatestPairSocket>();

                    // TODO: TBD: ditto CreateAsyncService...
                    svc = CreateAsyncService <BasicAsyncServiceFixture>();
                    svc.Start(() => ++ svc.Done);

                    Assert.Equal(0, svc.Done);

                    callback(s, svc);
                }
                finally
                {
                    DisposeAll(s, svc);
                }
            });
        }