public async void TestForGetPlaysByPlaybookId()
        {
            var options = new DbContextOptionsBuilder <PlaybookContext>()
                          .UseInMemoryDatabase(databaseName: "p3PlaybookService")
                          .Options;

            using (var context = new PlaybookContext(options))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                Repo r    = new Repo(context, new NullLogger <Repo>());
                var  play = new Play
                {
                    PlayID      = Guid.NewGuid(),
                    PlaybookId  = Guid.NewGuid(),
                    Name        = "Tackle",
                    Description = "Tackle other players",
                    DrawnPlay   = new byte[1]
                };

                r.Plays.Add(play);
                await r.CommitSave();

                var listOfPlays = await r.GetPlaysByPlaybookId(play.PlaybookId);

                var castedList = (List <Play>)listOfPlays;
                Assert.True(castedList[0].Equals(play));
            }
        }
        public async void TestForGetPlaybookById()
        {
            var options = new DbContextOptionsBuilder <PlaybookContext>()
                          .UseInMemoryDatabase(databaseName: "p3PlaybookService")
                          .Options;

            using (var context = new PlaybookContext(options))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                Repo r        = new Repo(context, new NullLogger <Repo>());
                var  playbook = new Playbook
                {
                    Playbookid = Guid.NewGuid(),
                    TeamID     = Guid.NewGuid(),
                    Name       = "myplaybook",
                    InDev      = true
                };

                r.Playbooks.Add(playbook);
                await r.CommitSave();

                var listOfPlaybooks = await r.GetPlaybookById(playbook.Playbookid);

                Assert.True(listOfPlaybooks.Equals(playbook));
            }
        }
        public async void TestForDeletePlay()
        {
            var options = new DbContextOptionsBuilder <PlaybookContext>()
                          .UseInMemoryDatabase(databaseName: "p3PlaybookService")
                          .Options;

            using (var context = new PlaybookContext(options))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                Repo               r                  = new Repo(context, new NullLogger <Repo>());
                Mapper             mapper             = new Mapper();
                Logic              logic              = new Logic(r, mapper, new NullLogger <Repo>());
                PlaybookController playbookController = new PlaybookController(logic, new NullLogger <PlaybookController>());
                var play = new Play
                {
                    PlayID      = Guid.NewGuid(),
                    PlaybookId  = Guid.NewGuid(),
                    Name        = "Tackle",
                    Description = "Tackle other players",
                    DrawnPlay   = new byte[1]
                };

                r.Plays.Add(play);
                await r.CommitSave();

                Assert.NotEmpty(context.Plays);
                var deletePlay = await playbookController.DeletePlay(play.PlayID.ToString());

                var getPlay = await logic.GetPlayById(play.PlayID);

                Assert.Null(getPlay);
            }
        }
        public async void TestForCreatePlaybook()
        {
            var options = new DbContextOptionsBuilder <PlaybookContext>()
                          .UseInMemoryDatabase(databaseName: "p3PlaybookService")
                          .Options;

            using (var context = new PlaybookContext(options))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                Repo               r                  = new Repo(context, new NullLogger <Repo>());
                Mapper             mapper             = new Mapper();
                Logic              logic              = new Logic(r, mapper, new NullLogger <Repo>());
                PlaybookController playbookController = new PlaybookController(logic, new NullLogger <PlaybookController>());
                var playbook = new Playbook
                {
                    Playbookid = Guid.NewGuid(),
                    TeamID     = Guid.NewGuid(),
                    Name       = "myplaybook",
                    InDev      = true
                };

                var createPlaybook = await playbookController.CreatePlaybook(playbook.Playbookid.ToString(), playbook.Name);

                Assert.NotEmpty(context.Playbooks);
                Assert.Equal("myplaybook", createPlaybook.Value.Name);
            }
        }
        public async void TestForGetPlaybooks()
        {
            //for coverage
            var dbContext  = new PlaybookContext();
            var logicClass = new Logic();

            var options = new DbContextOptionsBuilder <PlaybookContext>()
                          .UseInMemoryDatabase(databaseName: "p3PlaybookService")
                          .Options;

            using (var context = new PlaybookContext(options))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                Repo   r        = new Repo(context, new NullLogger <Repo>());
                Mapper mapper   = new Mapper();
                Logic  logic    = new Logic(r, mapper, new NullLogger <Repo>());
                var    playbook = new Playbook
                {
                    Playbookid = Guid.NewGuid(),
                    TeamID     = Guid.NewGuid(),
                    Name       = "myplaybook",
                    InDev      = true
                };

                r.Playbooks.Add(playbook);
                await r.CommitSave();

                var listOfPlaybooks = await logic.GetPlaybooks();

                Assert.NotNull(listOfPlaybooks);
            }
        }
        public async void TestForCreatePlay()
        {
            var options = new DbContextOptionsBuilder <PlaybookContext>()
                          .UseInMemoryDatabase(databaseName: "p3PlaybookService")
                          .Options;

            using (var context = new PlaybookContext(options))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                Repo               r                  = new Repo(context, new NullLogger <Repo>());
                Mapper             mapper             = new Mapper();
                Logic              logic              = new Logic(r, mapper, new NullLogger <Repo>());
                PlaybookController playbookController = new PlaybookController(logic, new NullLogger <PlaybookController>());
                var playDto = new PlayDto
                {
                    PlayID      = Guid.NewGuid(),
                    PlaybookID  = Guid.NewGuid(),
                    Name        = "Tackle",
                    Description = "Tackle other players",
                    DrawnPlay   = new byte[1],
                    ImageString = "football,football"
                };

                var createPlay = await playbookController.CreatePlay(playDto);

                Assert.NotEmpty(context.Plays);
                Assert.Equal("Tackle", createPlay.Value.Name);
                Assert.Equal("Tackle other players", createPlay.Value.Description);
            }
        }
        public async void TestForDeletePlaybook()
        {
            var options = new DbContextOptionsBuilder <PlaybookContext>()
                          .UseInMemoryDatabase(databaseName: "p3PlaybookController")
                          .Options;

            using (var context = new PlaybookContext(options))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                Repo               r                  = new Repo(context, new NullLogger <Repo>());
                Mapper             mapper             = new Mapper();
                Logic              logic              = new Logic(r, mapper, new NullLogger <Repo>());
                PlaybookController playbookController = new PlaybookController(logic, new NullLogger <PlaybookController>());
                var playbook = new Playbook
                {
                    Playbookid = Guid.NewGuid(),
                    TeamID     = Guid.NewGuid(),
                    Name       = "myplaybook",
                    InDev      = true
                };
                r.Playbooks.Add(playbook);
                await r.CommitSave();

                Assert.NotEmpty(context.Playbooks);
                var deletePlaybook = await playbookController.DeletePlaybook(playbook.Playbookid.ToString());

                var getPlaybook = await logic.GetPlaybookById(playbook.Playbookid);

                Assert.Null(getPlaybook);
            }
        }
        public async void TestForGetPlays()
        {
            var options = new DbContextOptionsBuilder <PlaybookContext>()
                          .UseInMemoryDatabase(databaseName: "p3PlaybookService")
                          .Options;

            using (var context = new PlaybookContext(options))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                Repo   r      = new Repo(context, new NullLogger <Repo>());
                Mapper mapper = new Mapper();
                Logic  logic  = new Logic(r, mapper, new NullLogger <Repo>());
                var    play   = new Play
                {
                    PlayID      = Guid.NewGuid(),
                    PlaybookId  = Guid.NewGuid(),
                    Name        = "Tackle",
                    Description = "Tackle other players",
                    DrawnPlay   = null
                };

                r.Plays.Add(play);
                await r.CommitSave();

                var listOfPlays = await logic.GetPlays();

                Assert.NotEmpty(listOfPlays);
                Assert.True(listOfPlays.FirstOrDefault(x => x.PlayID == play.PlayID).Name == play.Name);
                //Assert.Contains<PlayDto>(mapper.ConvertToPlayDto(play), listOfPlays);
            }
        }
        public async void TestForCreatePlay()
        {
            var options = new DbContextOptionsBuilder <PlaybookContext>()
                          .UseInMemoryDatabase(databaseName: "p3PlaybookService")
                          .Options;

            using (var context = new PlaybookContext(options))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                Repo    r      = new Repo(context, new NullLogger <Repo>());
                Mapper  mapper = new Mapper();
                Logic   logic  = new Logic(r, mapper, new NullLogger <Repo>());
                PlayDto play   = new PlayDto()
                {
                    PlaybookID  = Guid.NewGuid(),
                    Name        = "Tackle",
                    Description = "Tackle other players",
                    ImageString = "Football,football,football"
                };
                var createPlay = await logic.CreatePlay(play);

                //Assert.Equal(1, context.Plays.CountAsync().Result);
                Assert.Contains <Play>(createPlay, context.Plays);
            }
        }
        public async void TestForCreatePlaybook()
        {
            var options = new DbContextOptionsBuilder <PlaybookContext>()
                          .UseInMemoryDatabase(databaseName: "p3PlaybookService")
                          .Options;

            using (var context = new PlaybookContext(options))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                Repo   r      = new Repo(context, new NullLogger <Repo>());
                Mapper mapper = new Mapper();
                Logic  logic  = new Logic(r, mapper, new NullLogger <Repo>());

                var playbook = new Playbook
                {
                    TeamID = Guid.NewGuid(),
                    Name   = "myplaybook"
                };

                var createPlaybook = await logic.CreatePlaybook(playbook.TeamID, playbook.Name);

                //Assert.Equal(1, context.Playbooks.CountAsync().Result);

                Assert.Contains <Playbook>(createPlaybook, context.Playbooks);
            }
        }
        public async void TestForGetPlaybooksByTeamId()
        {
            var options = new DbContextOptionsBuilder <PlaybookContext>()
                          .UseInMemoryDatabase(databaseName: "p3PlaybookService")
                          .Options;

            using (var context = new PlaybookContext(options))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                Repo   r        = new Repo(context, new NullLogger <Repo>());
                Mapper mapper   = new Mapper();
                Logic  logic    = new Logic(r, mapper, new NullLogger <Repo>());
                var    playbook = new Playbook
                {
                    Playbookid = Guid.NewGuid(),
                    TeamID     = Guid.NewGuid(),
                    Name       = "myplaybook",
                    InDev      = true
                };

                r.Playbooks.Add(playbook);
                await r.CommitSave();

                var listOfPlaybooks = await logic.GetPlaybooksByTeamId(playbook.TeamID);

                var castedList = (List <Playbook>)listOfPlaybooks;
                Assert.True(castedList[0].Equals(playbook));
            }
        }
        public async void TestForGetPlays()
        {
            var options = new DbContextOptionsBuilder <PlaybookContext>()
                          .UseInMemoryDatabase(databaseName: "p3PlaybookService")
                          .Options;

            using (var context = new PlaybookContext(options))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                Repo               r                  = new Repo(context, new NullLogger <Repo>());
                Mapper             mapper             = new Mapper();
                Logic              logic              = new Logic(r, mapper, new NullLogger <Repo>());
                PlaybookController playbookController = new PlaybookController(logic, new NullLogger <PlaybookController>());
                var play = new Play
                {
                    PlayID      = Guid.NewGuid(),
                    PlaybookId  = Guid.NewGuid(),
                    Name        = "Tackle",
                    Description = "Tackle other players",
                    DrawnPlay   = new byte[1]
                };

                r.Plays.Add(play);
                var play2 = new Play
                {
                    PlayID      = Guid.NewGuid(),
                    PlaybookId  = Guid.NewGuid(),
                    Name        = "Run",
                    Description = "Run with ball",
                    DrawnPlay   = new byte[1]
                };

                r.Plays.Add(play2);
                await r.CommitSave();

                var listOfPlays = await playbookController.GetPlays();

                var convertedList = (List <PlayDto>)listOfPlays;
                Assert.NotNull(listOfPlays);
                Assert.Equal("Tackle", convertedList[0].Name);
                Assert.Equal("Tackle other players", convertedList[0].Description);
                Assert.Equal("Run", convertedList[1].Name);
                Assert.Equal("Run with ball", convertedList[1].Description);
            }
        }
        public async void TestForDeletePlay()
        {
            var options = new DbContextOptionsBuilder <PlaybookContext>()
                          .UseInMemoryDatabase(databaseName: "p3PlaybookService")
                          .Options;

            using (var context = new PlaybookContext(options))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                Repo   r      = new Repo(context, new NullLogger <Repo>());
                Mapper mapper = new Mapper();
                Logic  logic  = new Logic(r, mapper, new NullLogger <Repo>());
                var    play   = new Play()
                {
                    PlayID      = Guid.NewGuid(),
                    PlaybookId  = Guid.NewGuid(),
                    Name        = "Run",
                    Description = "Run to endzone",
                    DrawnPlay   = new byte[1]
                };
                r.Plays.Add(play);
                await r.CommitSave();

                var deleteEmpty = await logic.DeletePlay(Guid.NewGuid());

                Assert.Contains <Play>(play, context.Plays);
                var deletePlay = await logic.DeletePlay(play.PlayID);

                var countPlays = from p in context.Plays
                                 where p.Name == play.Name
                                 select p;
                int count = 0;
                foreach (Play plays in countPlays)
                {
                    count++;
                }
                Assert.Equal(0, count);
            }
        }
        public async void TestForDeletePlaybook()
        {
            var options = new DbContextOptionsBuilder <PlaybookContext>()
                          .UseInMemoryDatabase(databaseName: "p3PlaybookService")
                          .Options;

            using (var context = new PlaybookContext(options))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                Repo   r        = new Repo(context, new NullLogger <Repo>());
                Mapper mapper   = new Mapper();
                Logic  logic    = new Logic(r, mapper, new NullLogger <Repo>());
                var    playbook = new Playbook()
                {
                    Playbookid = Guid.NewGuid(),
                    TeamID     = Guid.NewGuid(),
                    Name       = "myplaybook",
                    InDev      = true
                };
                r.Playbooks.Add(playbook);
                await r.CommitSave();

                var deleteEmpty = await logic.DeletePlaybook(Guid.NewGuid());

                Assert.Contains <Playbook>(playbook, context.Playbooks);
                var deletePlaybook = await logic.DeletePlaybook(playbook.Playbookid);

                var countPlaybooks = from p in context.Playbooks
                                     where p.Playbookid == playbook.Playbookid
                                     select p;
                int count = 0;
                foreach (Playbook playbooks in countPlaybooks)
                {
                    count++;
                }
                Assert.Equal(0, count);
            }
        }
        public async void TestForEditPlay()
        {
            var options = new DbContextOptionsBuilder <PlaybookContext>()
                          .UseInMemoryDatabase(databaseName: "p3PlaybookService")
                          .Options;

            using (var context = new PlaybookContext(options))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                Repo   r      = new Repo(context, new NullLogger <Repo>());
                Mapper mapper = new Mapper();
                Logic  logic  = new Logic(r, mapper, new NullLogger <Repo>());
                var    play   = new Play()
                {
                    PlayID      = Guid.NewGuid(),
                    PlaybookId  = Guid.NewGuid(),
                    Name        = "Tackle",
                    Description = "Tackle the player",
                    DrawnPlay   = new byte[1]
                };

                r.Plays.Add(play);
                await r.CommitSave();

                var play2 = new PlayDto()
                {
                    PlaybookID  = Guid.NewGuid(),
                    Name        = "Tackle",
                    Description = "Tackle the quarterback",
                    DrawnPlay   = new byte[1]
                };

                var editedPlay = await logic.EditPlay(play.PlayID, play2);

                Assert.Equal(editedPlay.Description, context.Plays.Find(play.PlayID).Description);
            }
        }