Esempio n. 1
0
        public void ReturnCorrectLobbiesList()
        {
            //arrange
            var options = Utils.GetDbOptions("GetAllPublicOrOnwedLobbiesShould_ReturnCorrectLobbiesList");
            IEnumerable <string> lobbyNamesList;

            using (var context = new ApplicationDbContext(options))
            {
                context.Lobbies.Add(new Lobby()
                {
                    Name = "OurUserPublicLobby", OwnerID = "our_user", Private = false
                });
                context.Lobbies.Add(new Lobby()
                {
                    Name = "OtherUserPublicLobby", OwnerID = "other_user", Private = false
                });
                context.Lobbies.Add(new Lobby()
                {
                    Name = "OurUserPrivateLobby", OwnerID = "our_user", Private = true
                });
                context.Lobbies.Add(new Lobby()
                {
                    Name = "OtherUserPrivateLobby", OwnerID = "other_user", Private = true
                });
                context.SaveChanges();
            }
            //act
            using (var context = new ApplicationDbContext(options))
            {
                var service = new LobbyService(context, null, null);
                lobbyNamesList = from l in service.GetAllPublicOrOwnedLobbies("our_user")
                                 select l.Name;
            }
            //assert
            using (var context = new ApplicationDbContext(options))
            {
                Assert.Contains("OurUserPublicLobby", lobbyNamesList);
                Assert.Contains("OtherUserPublicLobby", lobbyNamesList);
                Assert.Contains("OurUserPrivateLobby", lobbyNamesList);
                Assert.DoesNotContain("OtherUserPrivateLobby", lobbyNamesList);
            }
        }