public void UpdateNameTest() { //Arrange var mock = new Mock <ILogger <ServiceClientCollection> >(); mock.Setup(m => m.Log <object>(It.IsAny <LogLevel>(), It.IsAny <EventId>(), It.IsAny <object>(), It.IsAny <Exception>(), It.IsAny <Func <object, Exception, string> >())) .Callback <LogLevel, EventId, object, Exception, Func <object, Exception, string> >((logLevel, eventId, obj, exception, func) => { string msg = func.Invoke(obj, exception); Console.WriteLine(msg); }); ServiceClientCollection serviceClients = new ServiceClientCollection(mock.Object) { new Models.ServiceClient { Client = null, Name = "Service1", ServiceName = "Teste1" } }; //Act serviceClients.UpdateName(serviceClients.GetClientByName("Service1"), "Service2"); var srv = serviceClients.GetClientByName("Service2"); //Assert Assert.IsTrue(srv.Name.Equals("Service2")); }
public void AddMesmoNomeTest() { //Arrange //Act //Assert Assert.ThrowsException <ArgumentException>(() => { var mock = new Mock <ILogger <ServiceClientCollection> >(); mock.Setup(m => m.Log <object>(It.IsAny <LogLevel>(), It.IsAny <EventId>(), It.IsAny <object>(), It.IsAny <Exception>(), It.IsAny <Func <object, Exception, string> >())) .Callback <LogLevel, EventId, object, Exception, Func <object, Exception, string> >((logLevel, eventId, obj, exception, func) => { string msg = func.Invoke(obj, exception); Console.WriteLine(msg); }); ServiceClientCollection serviceClients = new ServiceClientCollection(mock.Object) { new Models.ServiceClient { Client = null, Name = "Service1", ServiceName = "Teste1" }, new Models.ServiceClient { Client = null, Name = "Service1", ServiceName = "Teste2" } }; }); }
public TCPServer(ILogger <TCPServer> logger, ServiceClientCollection clients, IOptions <TCPServerOptions> options, Processor processor) { Logger = logger; TcpServerOptions = options.Value; Collection = clients; _processor = processor; Tasks = new List <Task>(); cts = new CancellationTokenSource(); IPAddress address = IPAddress.Parse(TcpServerOptions.IP); Listener = new TcpListener(address, TcpServerOptions.Port); Logger.LogInformation($"Iniciando abertura de ip:porta tcp: {TcpServerOptions.IP}:{TcpServerOptions.Port}"); Listener.Start(); }
public Processor(ILogger <Processor> logger, ServiceClientCollection collection, ICacheService cacheService) { _logger = logger; _collection = collection; _cacheService = cacheService; }