示例#1
0
        public IHttpActionResult Post(LeagueCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            LeagueService service = CreateLeagueService();

            if (service.CreateLeague(model))
            {
                return(Ok());
            }

            return(InternalServerError());
        }
        public void CreateLeague_IfLeagueIsReturned_ReturnLeague()
        {
            var teamService = new Mock <ITeamService>();
            var handler     = new Mock <IMatchHandler>();

            using (var arrangeContext = new FMDbContext(TestUtils.GetOptions(nameof(CreateLeague_IfLeagueIsReturned_ReturnLeague))))
            {
                arrangeContext.Leagues.Add(new League()
                {
                    Name = "League"
                });
                arrangeContext.SaveChanges();
            }

            using (var assertContext = new FMDbContext(TestUtils.GetOptions(nameof(CreateLeague_IfLeagueIsReturned_ReturnLeague))))
            {
                var sut    = new LeagueService(assertContext, teamService.Object, handler.Object);
                var ex     = sut.CreateLeague("League1");
                var league = assertContext.Leagues.FirstOrDefault(l => l.Name == "League1");

                //Assert.IsInstanceOfType(ex, typeof(League));
                Assert.IsNotNull(league);
            }
        }