Ejemplo n.º 1
0
        private static void Main()
        {
            try
            {
                // The ServiceManifest.XML file defines one or more service type names.
                // Registering a service maps a service type name to a .NET type.
                // When Service Fabric creates an instance of this service type,
                // an instance of the class is created in this host process.

                var agent      = new LicentieAgent();
                var controller = new LicentieController(agent);
                ServiceRuntime.RegisterServiceAsync("LicentieServiceType",
                                                    context => new LicentieServiceEndpoint(context, controller)).GetAwaiter().GetResult();

                ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(LicentieServiceEndpoint).Name);

                // Prevents this host process from terminating so services keep running.
                Thread.Sleep(Timeout.Infinite);
            }
            catch (Exception e)
            {
                ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString());
                throw;
            }
        }
        public void Initialize()
        {
            _agentMock = new Mock <ILicentieAgent>(MockBehavior.Strict);

            _agentMock.Setup(f => f.RetrieveToken("test", "123"))
            .Returns("Token")
            .Verifiable();

            _agentMock.Setup(f => f.RetrieveToken("throw", "123"))
            .Throws(new InvalidUserException("User not found"))
            .Verifiable();

            _sut = new LicentieController(_agentMock.Object);
        }