Beispiel #1
0
        public void AddRemotingListener_ToStatelessService_RegisterType()
        {
            HostBuilder builder = new HostBuilder();
            ServiceFabricHostBuilder <OmexStatelessService, StatelessServiceContext> sfBuilder =
                MockServiceFabricHostBuilder.CreateMockBuilder <OmexStatelessService, StatelessServiceContext>(builder);

            sfBuilder.AddRemotingListener <MockRemoteListenerBuilder <OmexStatelessService> >();

            IListenerBuilder <OmexStatelessService> value = builder.Build().Services.GetService <IListenerBuilder <OmexStatelessService> >();

            Assert.IsInstanceOfType(value, typeof(MockRemoteListenerBuilder <OmexStatelessService>));
        }
Beispiel #2
0
        public void AddRemotingListener_ToStatefulServiceUsingIServiceType_RegisterType()
        {
            string expectedName = nameof(AddRemotingListener_ToStatefulServiceUsingIServiceType_RegisterType);
            FabricTransportRemotingListenerSettings settings = new FabricTransportRemotingListenerSettings();
            HostBuilder builder = new HostBuilder();
            ServiceFabricHostBuilder <OmexStatefulService, StatefulServiceContext> sfBuilder =
                MockServiceFabricHostBuilder.CreateMockBuilder <OmexStatefulService, StatefulServiceContext>(builder);

            sfBuilder.AddRemotingListener <MockService>(expectedName, settings);

            IListenerBuilder <OmexStatefulService> value = builder.Build().Services.GetService <IListenerBuilder <OmexStatefulService> >();

            Assert.IsInstanceOfType(value, typeof(GenericRemotingListenerBuilder <OmexStatefulService>));
            Assert.AreEqual(expectedName, value.Name);
            Assert.AreEqual(settings, GetSettings(value));
        }
Beispiel #3
0
        public void AddRemotingListener_UsingFunc_RegisterType()
        {
            string expectedName = nameof(AddRemotingListener_UsingFunc_RegisterType);
            FabricTransportRemotingListenerSettings settings = new FabricTransportRemotingListenerSettings();
            HostBuilder builder = new HostBuilder();
            ServiceFabricHostBuilder <OmexStatelessService, StatelessServiceContext> sfBuilder =
                MockServiceFabricHostBuilder.CreateMockBuilder <OmexStatelessService, StatelessServiceContext>(builder);

            sfBuilder.AddRemotingListener(expectedName, (p, s) => new MockService(), settings);

            IListenerBuilder <OmexStatelessService> value = builder.Build().Services.GetService <IListenerBuilder <OmexStatelessService> >();

            Assert.IsNotNull(value);
            Assert.AreEqual(expectedName, value.Name);
            Assert.AreEqual(settings, GetSettings(value));
        }
Beispiel #4
0
        public void AddRemotingListener_ToStatelessServiceUsingIServiceTypeThatHasUnregisteredDependency_BuildThrowsInvalidOperationException()
        {
            string expectedName = nameof(AddRemotingListener_ToStatelessServiceUsingIServiceType_RegisterType);
            FabricTransportRemotingListenerSettings settings = new FabricTransportRemotingListenerSettings();
            HostBuilder builder = new HostBuilder();
            ServiceFabricHostBuilder <OmexStatelessService, StatelessServiceContext> sfBuilder =
                MockServiceFabricHostBuilder.CreateMockBuilder <OmexStatelessService, StatelessServiceContext>(builder);

            sfBuilder.AddRemotingListener <MockServiceWithDependencies>(expectedName, settings);

            IListenerBuilder <OmexStatelessService> value = builder.Build().Services.GetRequiredService <IListenerBuilder <OmexStatelessService> >();

            InvalidOperationException exception = Assert.ThrowsException <InvalidOperationException>(() => value.Build(MockServiceFabricServices.MockOmexStatelessService));

            StringAssert.Contains(exception.Message, typeof(MockServiceWithDependencies).FullName);
            StringAssert.Contains(exception.Message, typeof(IMockServiceDependency).FullName);
        }
Beispiel #5
0
        public void AddRemotingListener_ToStatelessServiceUsingIServiceTypeThatHasNoDependencies_BuildDoesNotThrow()
        {
            string expectedName = nameof(AddRemotingListener_ToStatelessServiceUsingIServiceType_RegisterType);
            FabricTransportRemotingListenerSettings settings = new FabricTransportRemotingListenerSettings();
            HostBuilder builder = new HostBuilder();
            ServiceFabricHostBuilder <OmexStatelessService, StatelessServiceContext> sfBuilder =
                MockServiceFabricHostBuilder.CreateMockBuilder <OmexStatelessService, StatelessServiceContext>(builder);

            sfBuilder.AddRemotingListener <MockService>(expectedName, settings);

            IListenerBuilder <OmexStatelessService> value = builder.Build().Services.GetRequiredService <IListenerBuilder <OmexStatelessService> >();

            ICommunicationListener service = value.Build(MockServiceFabricServices.MockOmexStatelessService);

            Assert.IsNotNull(service);
            Assert.AreEqual(expectedName, value.Name);
            Assert.AreEqual(settings, GetSettings(value));
        }