public void Report_ShouldRenderDefaultView_WhenCalled()
        {
            // Arrange
            var mockedDbContext     = ContextCreator.CreateMockedApllicationDbContext();
            var mockedLiteDbContext = new Mock <IClubContext>();
            var controller          = new TournamentController(mockedDbContext.Object, mockedLiteDbContext.Object);

            // Act & Assert
            Assert.IsInstanceOf <ViewAsPdf>(controller.ReportTournament(3));
        }
        public void Delete_ShouldRenderDefaultView_WhenCalled()
        {
            // Arrange
            var mockedDbContext     = ContextCreator.CreateMockedApllicationDbContext();
            var mockedLiteDbContext = new Mock <IClubContext>();
            var controller          = new TournamentController(mockedDbContext.Object, mockedLiteDbContext.Object);

            // Act & Assert
            controller.WithCallTo(x => x.DeleteTournament(3))
            .ShouldRenderDefaultView();
        }
        public void Delete_ShouldRedirectToTurnament_WhenNullProvided()
        {
            // Arrange
            var mockedDbContext     = ContextCreator.CreateMockedApllicationDbContext();
            var mockedLiteDbContext = new Mock <IClubContext>();
            var controller          = new TournamentController(mockedDbContext.Object, mockedLiteDbContext.Object);

            // Act & Assert
            controller.WithCallTo(x => x.DeleteTournament(33))
            .ShouldRedirectTo(x => x.Tournaments);
        }
        public void AddTournament_ShouldReturn_WhenNullIsPassed()
        {
            // Arrange
            var mockedDbContext     = ContextCreator.CreateMockedApllicationDbContext();
            var mockedLiteDbContext = new Mock <IClubContext>();
            var controller          = new TournamentController(mockedDbContext.Object, mockedLiteDbContext.Object);

            // Act & Assert
            controller.WithCallTo(x => x.AddTournament(null))
            .ShouldRenderDefaultView();
        }
        public void Constructor_ShouldCreateController_WhenValuesArePassed()
        {
            var mockedDbContext     = ContextCreator.CreateMockedApllicationDbContext();
            var mockedLiteDbContext = new Mock <IClubContext>();
            var controller          = new HomeController(mockedDbContext.Object, mockedLiteDbContext.Object);

            // Act & Assert
            Assert.IsInstanceOf <HomeController>(controller);
            Assert.AreSame(controller.Db, mockedDbContext.Object);
            Assert.AreSame(controller.LiteDb, mockedLiteDbContext.Object);
        }
Beispiel #6
0
        public void Tournament_ShouldReturnUpcomingPassedTournamentsViewModel_WhenCalled()
        {
            // Arrange
            var mockedDbContext     = ContextCreator.CreateMockedApllicationDbContext();
            var mockedLiteDbContext = new Mock <IClubContext>();
            var controller          = new TournamentController(mockedDbContext.Object, mockedLiteDbContext.Object);

            // Act & Assert
            controller.WithCallTo(x => x.Tournaments())
            .ShouldRenderDefaultView()
            .WithModel <UpcomingPassedTournamentsViewModel>();
        }
        public void Players_ShouldReturnViewResult_WhenCalled()
        {
            // Arrange
            var mockedDbContext     = ContextCreator.CreateMockedApllicationDbContext();
            var mockedLiteDbContext = new Mock <IClubContext>();
            var controller          = new PlayerController(mockedDbContext.Object, mockedLiteDbContext.Object);

            // Act & Assert
            controller.WithCallTo(x => x.Players())
            .ShouldRenderDefaultView()
            .WithModel <PlayersViewModel>();
        }
        public void DeleteTournamentConfirmed_ShouldRedirectWithCallingSaveChanges_WhenCalled()
        {
            // Arrange
            var mockedDbContext     = ContextCreator.CreateMockedApllicationDbContext();
            var mockedLiteDbContext = new Mock <IClubContext>();
            var controller          = new TournamentController(mockedDbContext.Object, mockedLiteDbContext.Object);

            // Act & Assert
            controller.WithCallTo(x => x.DeleteTournamentConfirmed(3))
            .ShouldRedirectTo(x => x.Tournaments);


            mockedDbContext.Verify(x => x.SaveChanges(), Times.Exactly(1));
        }
        public void AddTournament_ShouldRedirect_WhenTournamentIsPassed()
        {
            // Arrange
            var mockedDbContext     = ContextCreator.CreateMockedApllicationDbContext();
            var mockedLiteDbContext = new Mock <IClubContext>();
            var controller          = new TournamentController(mockedDbContext.Object, mockedLiteDbContext.Object);

            var model = new TournamentInputModel()
            {
                Name        = "testTest",
                StartDate   = new DateTime(2015, 1, 18),
                EndDate     = new DateTime(2020, 1, 18),
                Rounds      = 3,
                Country     = "Bulgariikata2",
                Description = "TestTestTest"
            };

            // Act & Assert
            controller.WithCallTo(x => x.AddTournament(model))
            .ShouldRedirectTo(x => x.Tournaments);
        }