Example #1
0
        public void CanDeleteRetroFamily()
        {
            //Arrange
            IRetroRespectiveRepository repo = _mockRetrospectiveRepo.Object;
            var controller = new RetroFamiliesController(repo, _hubContext.Object);

            IList <RetroFamily> retroFamilies = new List <RetroFamily>();

            RetroFamily f = new RetroFamily {
                Content  = "Okay",
                Id       = 0,
                Position = 0,
            };

            retroFamilies.Add(f);

            void Action(RetroFamily retroFamily)
            {
                RetroFamily y = retroFamilies.FirstOrDefault(x => x.Id == retroFamily.Id);

                retroFamilies.Remove(y);
            }

            _mockRetrospectiveRepo.Setup(m => m.RetroFamilies).Returns(retroFamilies.AsQueryable());

            _mockRetrospectiveRepo.Setup(m => m.RemoveRetroFamily(It.IsAny <RetroFamily>()))
            .Callback((Action <RetroFamily>)Action);

            //Act
            controller.Delete(0);

            //Assert
            Assert.False(retroFamilies.Any());
            Assert.True(retroFamilies.IsNullOrEmpty());
        }
Example #2
0
        public void CanAddPostRetroFamily()
        {
            //Arrange
            IRetroRespectiveRepository repo = _mockRetrospectiveRepo.Object;
            var controller = new RetroFamiliesController(repo, _hubContext.Object);

            IList <RetroFamily> retroFamilies = new List <RetroFamily>();

            void Action(RetroFamily retroFamily)
            {
                retroFamilies.Add(retroFamily);
            }

            _mockRetrospectiveRepo.Setup(m => m.SaveRetroFamily(It.IsAny <RetroFamily>()))
            .Callback((Action <RetroFamily>)Action);

            //Act
            controller.Post(new RetroFamily()
            {
                Id      = 5,
                Content = "RetroFamily 1"
            });

            //Assert
            Assert.True(retroFamilies.Any());
            RetroFamily createdRetroCard =
                retroFamilies.FirstOrDefault(r => r.Content.Equals("RetroFamily 1") && r.Id == 5);

            Assert.NotNull(createdRetroCard);
        }
Example #3
0
        public void CanGetRetroFamily()
        {
            //Arrange
            IRetroRespectiveRepository repo = _mockRetrospectiveRepo.Object;
            var controller = new RetroFamiliesController(repo, _hubContext.Object);

            IList <RetroFamily> retroFamilies = new List <RetroFamily>();

            RetroFamily f = new RetroFamily {
                Content  = "Okay",
                Id       = 0,
                Position = 0,
            };

            retroFamilies.Add(f);

            _mockRetrospectiveRepo.Setup(r => r.RetroFamilies).Returns(retroFamilies.AsQueryable());

            //Act
            RetroFamily family = controller.Get(0).Value;

            //Assert
            Assert.NotNull(family);
            Assert.Equal("Okay", family.Content);
            Assert.Equal(0, family.Position);
        }
Example #4
0
 public RetroUsersController(UserManager <RetroUser> userMgr,
                             SignInManager <RetroUser> signInMgr,
                             IRetroRespectiveRepository repo,
                             IDecoder decoder)
 {
     userManager   = userMgr;
     signInManager = signInMgr;
     _repo         = repo;
     this.decoder  = decoder;
 }
        public void DeletionOfAColumn()
        {
            //Arrange
            IList <Retrospective> r = new List <Retrospective> {
                new Retrospective
                {
                    Id          = 0,
                    RetroUserId = 1
                }
            };

            _mockRetrospectiveRepo.Setup(x => x.Retrospectives).Returns(r.AsQueryable());

            RetroColumn column = new RetroColumn
            {
                Id              = 0,
                Title           = "Column 1",
                RetrospectiveId = 0
            };

            IList <RetroColumn> columns = new List <RetroColumn> {
                column
            };

            void Action(RetroColumn retroColumn)
            {
                columns.Remove(retroColumn);
            }

            decoderMock.Setup(x => x.DecodeToken(It.IsAny <string>())).Returns("1");


            _mockRetrospectiveRepo.Setup(m => m.RetroColumns).Returns(columns.AsQueryable());
            _mockRetrospectiveRepo.Setup(m => m.RemoveRetroColumn(It.IsAny <RetroColumn>())).Callback((Action <RetroColumn>)Action);

            IRetroRespectiveRepository repo = _mockRetrospectiveRepo.Object;
            var controller = new RetroColumnsController(repo, _hubContext.Object, decoderMock.Object);

            //Act
            controller.DeleteRetroColumn(0);

            //Assert
            Assert.True(!columns.Any());
        }
        public void AdditionOfAColumn()
        {
            //Arrange
            IList <Retrospective> r = new List <Retrospective> {
                new Retrospective
                {
                    Id          = 0,
                    RetroUserId = 1
                }
            };

            _mockRetrospectiveRepo.Setup(x => x.Retrospectives).Returns(r.AsQueryable());

            IRetroRespectiveRepository repo = _mockRetrospectiveRepo.Object;
            var controller = new RetroColumnsController(repo, _hubContext.Object, decoderMock.Object);

            IList <RetroColumn> columns = new List <RetroColumn>();

            void Action(RetroColumn retroColumn)
            {
                columns.Add(retroColumn);
            }

            decoderMock.Setup(x => x.DecodeToken(It.IsAny <string>())).Returns("1");

            _mockRetrospectiveRepo.Setup(m => m.SaveRetroColumn(It.IsAny <RetroColumn>())).Callback((Action <RetroColumn>)Action);

            //Act
            controller.PostRetroColumn(new RetroColumn
            {
                Id              = 2,
                Title           = "Column 3",
                RetrospectiveId = 0
            });

            //Assert
            Assert.True(columns.Any());

            RetroColumn createdColumn = columns.FirstOrDefault(r => r.Title.Equals("Column 3"));

            Assert.NotNull(createdColumn);
        }
Example #7
0
        public async void CanGetAllRetroFamilies()
        {
            //Arrange
            IRetroRespectiveRepository repo = _mockRetrospectiveRepo.Object;
            var controller = new RetroFamiliesController(repo, _hubContext.Object);

            IList <RetroFamily> retroFamilies = new List <RetroFamily>();

            {
                RetroFamily f = new RetroFamily
                {
                    Content  = "Okay",
                    Id       = 0,
                    Position = 0,
                };

                retroFamilies.Add(f);
            }
            {
                RetroFamily f = new RetroFamily {
                    Content  = "Okay2",
                    Id       = 1,
                    Position = 1,
                };

                retroFamilies.Add(f);
            }

            _mockRetrospectiveRepo.Setup(r => r.RetroFamilies).Returns(retroFamilies.AsQueryable());

            //Act
            var entries = await controller.Get();

            //Arrange
            var test = entries.Value;

            Assert.Equal(2, test.Count());
        }
Example #8
0
        public void CanUpdateRetroFamily()
        {
            //Arrange
            IRetroRespectiveRepository repo = _mockRetrospectiveRepo.Object;
            var controller = new RetroFamiliesController(repo, _hubContext.Object);

            IList <RetroFamily> retroFamilies = new List <RetroFamily>();

            RetroFamily f = new RetroFamily
            {
                Content  = "Okay",
                Id       = 0,
                Position = 0,
            };

            retroFamilies.Add(f);

            void Action(RetroFamily retroFamily)
            {
                RetroFamily entry = retroFamilies.FirstOrDefault(x => x.Id == retroFamily.Id);

                entry.Content = retroFamily.Content;
            }

            _mockRetrospectiveRepo.Setup(m => m.SaveRetroFamily(It.IsAny <RetroFamily>()))
            .Callback((Action <RetroFamily>)Action);

            //Act
            f.Content = "Wow!";

            controller.Put(f);

            //Assert
            Assert.True(retroFamilies.Any());
            Assert.True(retroFamilies.Count == 1);
            Assert.True(retroFamilies.ElementAt(0).Content.Equals("Wow!"));
        }
Example #9
0
        public void AdditionOfARetroCard()
        {
            //Arrange
            IRetroRespectiveRepository repo = _mockRetrospectiveRepo.Object;
            var controller = new RetroCardsController(repo, _hubContext.Object);

            IList <RetroColumn> retroColumns = new List <RetroColumn>();

            retroColumns.Add(new RetroColumn {
                Id = 0
            });

            this._mockRetrospectiveRepo.Setup(r => r.RetroColumns).Returns(retroColumns.AsQueryable);

            IList <RetroCard> retroCards = new List <RetroCard>();

            void Action(RetroCard retroCard)
            {
                retroCards.Add(retroCard);
            }

            _mockRetrospectiveRepo.Setup(m => m.SaveRetroCard(It.IsAny <RetroCard>())).Callback((Action <RetroCard>)Action);

            //Act
            controller.PostRetroCard(new RetroCard
            {
                Id      = 5,
                Content = "RetroCard 1"
            });

            //Assert
            Assert.True(retroCards.Any());
            RetroCard createdRetroCard = retroCards.FirstOrDefault(r => r.Content.Equals("RetroCard 1"));

            Assert.NotNull(createdRetroCard);
        }
 public RetrospectivesController(IRetroRespectiveRepository context, IDecoder decoder, IHubContext <NotifyHub, ITypedHubClient> signlar)
 {
     _context     = context;
     this.decoder = decoder;
     hubContext   = signlar;
 }
Example #11
0
 public RetroColumnsController(IRetroRespectiveRepository context, IHubContext <NotifyHub, ITypedHubClient> hubContext, IDecoder decoder)
 {
     _context     = context;
     _hubContext  = hubContext;
     this.decoder = decoder;
 }
Example #12
0
 public RetroCardsController(IRetroRespectiveRepository context, IHubContext <NotifyHub, ITypedHubClient> hubContext)
 {
     _context    = context;
     _hubContext = hubContext;
 }
Example #13
0
 public RetroFamiliesController(IRetroRespectiveRepository repo, IHubContext <NotifyHub, ITypedHubClient> context)
 {
     this._repo       = repo;
     this._hubContext = context;
 }