public async Task UpdateStandings_3WayTieBrokenWithWin_2TiedUsersHaveCorrectTieBreakScores() { var season = CreateSeason((1, 5, 1000), (2, 5, 100), (3, 5, 10), (4, 2, 0)); var player1 = season.Participants[0]; var player2 = season.Participants[1]; var player3 = season.Participants[2]; var player4 = season.Participants[3]; MockTieBreak(arg => { arg.First(p => p.Key.ID == player1.ID).Key.TieBreakerPoints = 100; arg.First(p => p.Key.ID == player3.ID).Key.TieBreakerPoints = 10; }); pointCalculator.CalculatePointDeltas(player2, player4).Returns((2, 1)); var set = SetUtility.Create(dbContext, player2, player4, season.LeagueID); DbContextUtility.UpdateAndSave(dbContext, set, () => { set.Player1Score = 1; set.Player2Score = 0; }); await testObj.UpdateStandings(set.ID); Assert.Greater(player1.TieBreakerPoints, 0); Assert.Greater(player3.TieBreakerPoints, 0); Assert.AreEqual(0, player2.TieBreakerPoints); }
public void SetUp() { dbContext = DbContextUtility.CreateMockDb(); pointService = Substitute.For <IPointService>(); testObj = new LeagueService(dbContext, pointService); }
public void SetUp() { dbContext = DbContextUtility.CreateMockDb(); seasonService = Substitute.For <ISeasonService>(); testObj = new SetService(dbContext, seasonService); }
public void AddLeague_NotOwner_NotAuthorizedException() { var league = CreateLeagueWithAdmin(); var organization = DbContextUtility.AddNew <Organization>(dbContext); Assert.ThrowsAsync <NotAuthorizedException>(() => testObj.AddLeague(organization.ID, league.ID, userID)); }
public void SetUp() { dbContext = DbContextUtility.CreateMockDb(); cdnService = Substitute.For <ICdnService>(); testObj = new GameService(dbContext, cdnService); }
public void SetUp() { dbContext = DbContextUtility.CreateMockDb(); testObj = new OrganizationService(dbContext); userID = DbContextUtility.AddNew <ApplicationUser>(dbContext).Id; }
public async Task Get_Valid_Ok() { var user = DbContextUtility.AddNew <ApplicationUser>(dbContext, u => u.Email = "*****@*****.**"); var result = await testObj.Get(user.Id); ControllerUtility.AssertStatusCode(result, HttpStatusCode.OK); }
private void AddUser() { DbContextUtility.AddNew <ApplicationUser>(dbContext, u => { u.Id = ID; u.Email = Email; }); }
public void SetUp() { dbContext = DbContextUtility.CreateMockDb(); var logger = Substitute.For <ILogger <GameApi> >(); var cdnService = Substitute.For <ICdnService>(); testObj = new GameApi(logger, dbContext, cdnService); }
public void SetUp() { var logger = Substitute.For <ILogger <FakeBaseController> >(); var userManager = Substitute.For <IUserManager>(); var dbContext = DbContextUtility.CreateMockDb(); testObj = new FakeBaseController(logger, userManager, dbContext); }
public void SetUp() { setService = Substitute.For <ISetService>(); dbContext = DbContextUtility.CreateMockDb(); var logger = Substitute.For <ILogger <SetApi> >(); testObj = new SetApi(logger, dbContext, setService); }
public async Task ListForLeague_Valid_ReturnOk() { var league = DbContextUtility.AddNew <League>(dbContext, l => l.GameID = gameID); var result = await testObj.ListForLeague(league.ID); ControllerUtility.AssertStatusCode(result, HttpStatusCode.OK); }
public void SetUp() { dbContext = DbContextUtility.CreateMockDb(); applicationUserService = Substitute.For <IApplicationUserService>(); var logger = Substitute.For <ILogger <UserApi> >(); var cdnService = Substitute.For <ICdnService>(); testObj = new UserApi(logger, dbContext, cdnService, applicationUserService); }
public async Task UploadImage_Valid_SetsUserProfilePicKey() { var user = DbContextUtility.AddNew <ApplicationUser>(dbContext); var file = PrepareCdnService(); await testObj.UploadProfilePic(user.Id, file); Assert.AreEqual(ImageKey, user.ProfilePicKey); }
public async Task UploadImage_Valid_ReturnImageUrl() { var user = DbContextUtility.AddNew <ApplicationUser>(dbContext); var file = PrepareCdnService(); var imageUrl = await testObj.UploadProfilePic(user.Id, file); Assert.AreEqual(ImageUrl, imageUrl); }
public async Task Create_Valid_ReturnOk() { var league = DbContextUtility.AddNew <League>(dbContext, l => l.GameID = gameID); var request = new CreateRequest(league.ID, DateTime.Now.AddMinutes(1), DateTime.Now.AddMinutes(2)); var result = await testObj.Create(request); ControllerUtility.AssertStatusCode(result, HttpStatusCode.Created); }
public void SetUp() { leagueService = Substitute.For <ILeagueService>(); dbContext = DbContextUtility.CreateMockDb(); var logger = Substitute.For <ILogger <LeagueApi> >(); var configuration = Substitute.For <IConfiguration>(); testObj = new LeagueApi(logger, dbContext, leagueService, configuration); }
public async Task Create_Valid_ReturnLeague() { var admin = DbContextUtility.AddNew <ApplicationUser>(dbContext); var game = DbContextUtility.AddNew <Game>(dbContext); var league = await testObj.Create("", game.ID, admin.Id); Assert.IsNotNull(league); }
public async Task Create_Valid_AdminAdded() { var admin = DbContextUtility.AddNew <ApplicationUser>(dbContext); var game = DbContextUtility.AddNew <Game>(dbContext); var league = await testObj.Create("", game.ID, admin.Id); Assert.AreEqual(admin.Id, league.Members[0].UserID); }
public void SetUp() { seasonService = Substitute.For <ISeasonService>(); dbContext = DbContextUtility.CreateMockDb(); var logger = Substitute.For <ILogger <SeasonController> >(); var userManager = Substitute.For <IUserManager>(); testObj = new SeasonController(seasonService, dbContext, logger, userManager); }
public async Task Join_NewUser_UpdateDisplayName() { var league = LeagueUtility.CreateLeague(dbContext); var user = DbContextUtility.AddNew <ApplicationUser>(dbContext, u => u.UserName = "******"); var leagueUser = await testObj.Join(league.ID, user.Id); Assert.AreEqual(user.UserName, leagueUser.DisplayName); }
public async Task UploadProfilePic_Valid_Created() { var user = DbContextUtility.AddNew <ApplicationUser>(dbContext); var file = Substitute.For <IFormFile>(); var result = await testObj.UploadProfilePic(user.Id, file); ControllerUtility.AssertStatusCode(result, HttpStatusCode.Created); }
public async Task UpdateSettings_NoProfilePic_DontUpdatePicture() { var user = DbContextUtility.AddNew <ApplicationUser>(dbContext); await testObj.UpdateSettings(user.Id, "bob", "", null); #pragma warning disable 4014 cdnService.DidNotReceiveWithAnyArgs().UploadImageAsync(null, null); #pragma warning restore 4014 }
public async Task Get_Valid_ReturnUser() { var user = DbContextUtility.AddNew <ApplicationUser>(dbContext, u => u.Email = "*****@*****.**"); var result = await testObj.Get(user.Id); var resultObj = result.GetObject <UserDto>(); Assert.AreEqual(user.Email, resultObj.Email); }
public async Task ForgotPassword_SignedIn_RedirectToUserHome() { var user = DbContextUtility.AddNew <ApplicationUser>(dbContext); userManager.GetUserAsync(null).ReturnsForAnyArgs(user); var result = await testObj.ForgotPassword(); Assert.IsInstanceOf <RedirectToActionResult>(result); }
public void Add <TEntity>(TEntity entity) where TEntity : class, IKeyIdentity <TKey> { ICollection <TEntity> entityCollection = (ICollection <TEntity>)GetCollection(typeof(TEntity)); if (GenerateId) { entity.Id = DbContextUtility.GenerateNewKey(); } entityCollection.Add(entity); }
public async Task UpdateSettings_ProfilePic_UpdatePicture() { var user = DbContextUtility.AddNew <ApplicationUser>(dbContext); var file = Substitute.For <IFormFile>(); await testObj.UpdateSettings(user.Id, "bob", "", file); #pragma warning disable 4014 cdnService.Received(1).ReplaceImageAsync(Arg.Any <string>(), file, ClimbImageRules.ProfilePic); #pragma warning restore 4014 }
public async Task Join_Valid_Created() { var league = LeagueUtility.CreateLeague(dbContext); var user = DbContextUtility.AddNew <ApplicationUser>(dbContext); var request = new JoinRequest(league.ID, user.Id); var result = await testObj.Join(request); ControllerUtility.AssertStatusCode(result, HttpStatusCode.Created); }
public async Task Join_OldUser_HasLeftFalse() { var league = LeagueUtility.CreateLeague(dbContext); var user = DbContextUtility.AddNew <ApplicationUser>(dbContext); LeagueUser oldLeagueUser = CreateOldLeagueUser(league, user); var leagueUser = await testObj.Join(league.ID, user.Id); Assert.IsFalse(leagueUser.HasLeft); Assert.AreEqual(oldLeagueUser.ID, leagueUser.ID); }
public void SetUp() { dbContext = DbContextUtility.CreateMockDb(); var game = DbContextUtility.AddNew <Game>(dbContext); gameID = game.ID; seasonService = Substitute.For <ISeasonService>(); var logger = Substitute.For <ILogger <SeasonApi> >(); testObj = new SeasonApi(logger, dbContext, seasonService); }