public void GetTest()
        {
            // Arrange
            var httpContextAccessor = new Mock <IHttpContextAccessor>();

            httpContextAccessor.Setup(repo => repo.HttpContext.Request.Host)
            .Returns(new HostString("localhost:44351"));
            var serverManagerMock = new Mock <IServerManager>();

            serverManagerMock.Setup(repo => repo.GetServers())
            .Returns(GetServerTest());
            var serverController = new ServersController(serverManagerMock.Object, httpContextAccessor.Object);

            //act
            var result = serverController.Get();

            //assert
            Assert.Equal(2, result.Count);
        }
        public void Get_SingleServer_ReturnsServerAsJson()
        {
            // Arrange
            var           serversManagerStub = new Mock <IServersManager>();
            List <Server> servers            = new List <Server>()
            {
                new Server {
                    ServerId = "srv-4996", ServerURL = "http://rony6.atwebpages.com"
                }
            };
            var expected          = "[{\"ServerId\":\"srv-4996\",\"ServerURL\":\"http://rony6.atwebpages.com\"}]";
            var serversController = new ServersController(serversManagerStub.Object);

            serversManagerStub.Setup(sm => sm.GetAllServers()).Returns(servers);

            // Act
            var actual = serversController.Get();

            // Assert
            Assert.AreEqual(expected, actual);
        }
        public void GetServersTest()
        {
            // Arrange.
            IDataAccess       demoDataAccess    = new DemoDataAccess();
            IServersManager   serversManager    = new ServersManager(demoDataAccess);
            ServersController serversController = new ServersController(serversManager);

            // Act.
            ActionResult <List <Server> > actionResult = serversController.Get();
            ObjectResult  result        = actionResult.Result as ObjectResult;
            List <Server> actualServers = result.Value as List <Server>;

            // Assert.
            List <Server> expectedServers = demoDataAccess.GetServers();
            // Get the minimum length.
            int size = actualServers.Count <= expectedServers.Count ? actualServers.Count : expectedServers.Count;
            int i    = 0;

            for (i = 0; i < size; i++)
            {
                Assert.AreEqual <Server>(expectedServers[i], actualServers[i]);
            }
        }