Beispiel #1
0
        static void Main(string[] args)
        {
            var connectionString = "Endpoint=sb://yukistest.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=vEpNyi3CYNhiLz7a6m7s10GMJnjZc2wsgPBFrLSDLcs=";
            var topic            = "chat";
            var subscription     = "MyFirstChat";
            var queueName        = "myfirstqueue";

            for (var i = 0; i < args.Length; i++)
            {
                switch (args[i])
                {
                case "-ConnectionString":
                    Console.WriteLine($"ConnectionString: {args[i + 1]}");
                    connectionString = args[i + 1];     // Alternatively enter your connection string here.
                    break;

                case "-Topic":
                    Console.WriteLine($"Topic: {args[i + 1]}");
                    topic = args[i + 1];     // Alternatively enter your queue name here.
                    break;

                case "-Subscription":
                    Console.WriteLine($"Subscption: {args[i + 1]}");
                    subscription = args[i + 1];     // Alternatively enther your queue name here.
                    break;

                case "-Queue":
                    Console.WriteLine($"Queue: {args[i + 1]}");
                    queueName = args[i + 1];     // Alternatively enter your queue name here.
                    break;
                }
            }

            _handler = new ServiceBusTopicHandler(connectionString, topic, subscription);
            //_handler = new ServiceBusQueueHandler(connectionString, queueName);

            while (true)
            {
                readInput();
            }
        }
        public void ExampleTest()
        {
            // Arrange
            IServiceBusHandler <DomainObject> mockedServiceBusHandler =
                Substitute.For <IServiceBusHandler <DomainObject> >();

            mockedServiceBusHandler
            .Get()
            .Returns(
                new List <KeyValuePair <Int64, DomainObject> >()
            {
                new KeyValuePair <Int64, DomainObject>(1, new DomainObject()
                {
                    Id = 1, GroupingKey = 1
                }),
                new KeyValuePair <Int64, DomainObject>(2, new DomainObject()
                {
                    Id = 2, GroupingKey = 1
                }),
                new KeyValuePair <Int64, DomainObject>(2, new DomainObject()
                {
                    Id = 3, GroupingKey = 2
                })
            });                                                       // Mock up the get end point for the service bus handler

            List <KeyValuePair <Int64, DomainObject> > result = null; // Invalid results set to start

            BusinessLogic <DomainObject> businessLogic =
                new BusinessLogic <DomainObject>(mockedServiceBusHandler); // Create the business logic fed from the service bus handler

            // Act
            result = mockedServiceBusHandler.Get(); // Execute the get to get the mocked up service bus items

            // Assert
            Assert.NotNull(result);        // The result set was populated at least
            Assert.Equal(2, result.Count); // Correct amount of rows?
        }
 public StoreModel(IServiceBusHandler serviceBus)
 {
     _serviceBus = serviceBus;
 }
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="serviceBusHandler">The service bus that feeds the logic</param>
 public BusinessLogic(IServiceBusHandler <T> serviceBusHandler)
 {
     this.serviceBusHandler = serviceBusHandler; // Assign the service bus
 }