Exemplo n.º 1
0
        public void GetTeamSeasonScheduleProfile()
        {
            // Arrange
            var repository = new StoredProcedureRepository();

            var dbContext = A.Fake <ProFootballEntities>();
            var teamName  = "Team";
            var seasonID  = 2017;

            A.CallTo(() => dbContext.GetTeamSeasonScheduleProfile(A <string> .Ignored, A <int> .Ignored))
            .Returns(A.Fake <ObjectResult <GetTeamSeasonScheduleProfile_Result> >());

            // Act
            var result = repository.GetTeamSeasonScheduleProfile(dbContext, teamName, seasonID);

            // Assert
            A.CallTo(() => dbContext.GetTeamSeasonScheduleProfile(teamName, seasonID))
            .MustHaveHappenedOnceExactly();
            Assert.IsInstanceOf <ObjectResult <GetTeamSeasonScheduleProfile_Result> >(result);
        }
        public void GetTeamSeasonScheduleProfile_GenericExceptionCaught_LogsAndRethrowsException()
        {
            // Arrange
            var dbContext  = A.Fake <ProFootballEntities>();
            var repository = new StoredProcedureRepository(dbContext);

            var teamName = "Team";
            var seasonID = 2017;

            A.CallTo(() => dbContext.GetTeamSeasonScheduleProfile(A <string> .Ignored, A <int> .Ignored))
            .Throws <Exception>();

            // Act
            ObjectResult <GetTeamSeasonScheduleProfile_Result> result = null;

            Assert.Throws <Exception>(
                () => { result = repository.GetTeamSeasonScheduleProfile(teamName, seasonID); });

            // Assert
            Assert.IsNull(result);
        }