public void GetChannelById_NonExistingChannel_ShouldReturn404NotFound()
        {
            // Arrange -> create a few channels
            var dataLayerMock = new MessagesDataMock();
            var channelsMock = dataLayerMock.Channels;
            channelsMock.Add(new Channel() { Id = 1, Name = "Channel #1" });
            channelsMock.Add(new Channel() { Id = 2, Name = "Channel #2" });
            channelsMock.Add(new Channel() { Id = 3, Name = "Channel #3" });

            // Act -> Get channel by ID
            var channelsController = new ChannelsController(dataLayerMock);
            this.SetupControllerForTesting(channelsController, "channels");
            var httpResponse = channelsController.GetChannelById(20)
                .ExecuteAsync(new CancellationToken()).Result;

            // Assert -> HTTP status code 404 (Not Found)
            Assert.AreEqual(HttpStatusCode.NotFound, httpResponse.StatusCode);
        }
        public void GetChannelById_ExistingChannel_ShouldReturn200OK_CorrectChannelData()
        {
            // Arrange -> create a few channels
            var dataLayerMock = new MessagesDataMock();
            var channelsMock = dataLayerMock.Channels;
            channelsMock.Add(new Channel() { Id = 1, Name = "Channel #1" });
            channelsMock.Add(new Channel() { Id = 2, Name = "Channel #2" });
            channelsMock.Add(new Channel() { Id = 3, Name = "Channel #3" });

            // Act -> Get channel by ID
            var channelsController = new ChannelsController(dataLayerMock);
            this.SetupControllerForTesting(channelsController, "channels");
            var httpResponse = channelsController.GetChannelById(2)
                .ExecuteAsync(new CancellationToken()).Result;

            // Assert -> HTTP status code 200 (OK) + correct channel data
            Assert.AreEqual(HttpStatusCode.OK, httpResponse.StatusCode);
            var channel2 = httpResponse.Content.ReadAsAsync<ChannelModel>().Result;
            Assert.AreEqual(2, channel2.Id);
            Assert.AreEqual("Channel #2", channel2.Name);
        }
        //
        // This test will not run corectly, because we cannot mock the "POST /api/token" acion
        //
        // [TestMethod]
        public void Login_ValidUser_ShouldReturn200OkSessionToken()
        {

            // Arrange -> mock the data layer
            var dataLayerMock = new MessagesDataMock();
            var userStoreMock = dataLayerMock.UserStore;
            var userManagerMock = new ApplicationUserManager(userStoreMock);
            string username = "******";
            string password = "******";
            userManagerMock.CreateAsync(new User() { UserName = username }, password);

            var accountController = new AccountController(dataLayerMock);
            this.SetupControllerForTesting(accountController, "user");

            // Act -> Get channel by ID
            var userModel = new UserAccountBindingModel()
            {
                Username = username,
                Password = password
            };
            var httpResponse = accountController.LoginUser(userModel)
                .Result.ExecuteAsync(new CancellationToken()).Result;

            // Assert -> HTTP status code 200 (OK) + correct user data
            Assert.AreEqual(HttpStatusCode.OK, httpResponse.StatusCode);
            var userSession = httpResponse.Content.ReadAsAsync<UserSessionModel>().Result;
            Assert.AreEqual(username, userSession.UserName);
            Assert.IsNotNull(userSession.Access_Token);
        }