public
Description:
Homepage: http://www.iserviceoriented.com
Clone URL: git://github.com/jezell/iserviceoriented.git
100644 84 lines (70 sloc) 3.013 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using System;
using System.Collections.ObjectModel;
using System.IO;
using System.Runtime.Serialization;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using IServiceOriented.ServiceBus.Delivery;
using IServiceOriented.ServiceBus.Services;
using IServiceOriented.ServiceBus.Listeners;
using IServiceOriented.ServiceBus.Dispatchers;
 
namespace IServiceOriented.ServiceBus.UnitTests
{
[TestFixture]
    public class TestServiceBusManagement
    {
        public TestServiceBusManagement()
        {
        }
 
[TestFixtureSetUp]
        public void Init()
        {
            
        }
 
[TestFixtureTearDown]
        public void Uninit()
        {
            
        }
 
[Test]
        public void Can_Add_And_Remove_Subscriptions()
        {
            using(ServiceBusRuntime runtime = new ServiceBusRuntime(new DirectDeliveryCore(), new WcfManagementService()))
            {
                ServiceBusTest tester = new ServiceBusTest(runtime);
                tester.StartAndStop(() =>
                {
                    Service.Use<IServiceBusManagementService>(managementService =>
                        {
                            ListenerEndpoint endpoint = new ListenerEndpoint(Guid.NewGuid(), "name of endpoint", "NamedPipeListener", "net.pipe://test/someservice/", typeof(IContract), new WcfServiceHostListener());
                            managementService.AddListener(endpoint);
 
                            ListenerEndpoint added = managementService.ListListeners().First();
                            tester.AssertEqual(endpoint, added);
 
                            managementService.RemoveListener(endpoint.Id);
                            Assert.IsEmpty(managementService.ListListeners());
                        });
                });
            }
        }
 
[Test]
        public void Can_Add_And_Remove_Listeners()
        {
            using (ServiceBusRuntime runtime = new ServiceBusRuntime(new DirectDeliveryCore(), new WcfManagementService()))
            {
                ServiceBusTest tester = new ServiceBusTest(runtime);
                tester.StartAndStop(() =>
                {
                    Service.Use<IServiceBusManagementService>(managementService =>
                    {
                        SubscriptionEndpoint endpoint = new SubscriptionEndpoint(Guid.NewGuid(), "name of endpoint", "NamedPipeClient", "net.pipe://test/someservice/", typeof(IContract), new WcfProxyDispatcher(), null);
                        managementService.Subscribe(endpoint);
 
                        SubscriptionEndpoint added = managementService.ListSubscribers().First();
                        tester.AssertEqual(endpoint, added);
 
                        managementService.Unsubscribe(endpoint.Id);
                        Assert.IsEmpty(managementService.ListSubscribers());
                    });
                });
            }
        }
 
        
    }
}