/// <summary> /// Initialize Facades buy utilzing a dependency injection container /// </summary> /// <param name="injector"></param> private void InitializeHandlers(AdapterInjectionContainer injector) { _userHandler = new UserHandler(injector.GetUserAdapter()); _studyHandler = new StudyHandler(injector.GetStudyAdapter()); _fileHandler = new FileHandler(new BibtexParser()); _exportHandler = new ExportHandler(); _teamHandler = new TeamHandler(injector.GetTeamAdapter()); _taskHandler = new TaskHandler(injector.GetTaskAdapter()); }
public async void CreateTeam_Valid_Test() { //Arrange _adapterMock.Setup(r => r.Create(_team)).Returns(Task.FromResult(_team.Id)); var teamHandler = new TeamHandler(_adapterMock.Object); //Act var returnedId = await teamHandler.Create(_team); //Assert Assert.IsTrue(returnedId == _team.Id); }
public async void CreateTeam_Invalid_TeamInformationEmptyString_Test() { //Arrange _team.Name = ""; _team.MetaData = ""; _adapterMock.Setup(r => r.Create(_team)); var teamHandler = new TeamHandler(_adapterMock.Object); //Act var result = await teamHandler.Create(_team); //Assert //Exception must be thrown }
public async void CreateTeam_Invalid_NoTeamMember_Test() { //Arrange _team.UserIDs = new int[0]; _adapterMock.Setup(r => r.Create(_team)); var teamHandler = new TeamHandler(_adapterMock.Object); //Act var result = await teamHandler.Create(_team); //Assert //Exception must be thrown }
public void ReadAllTeams_Valid_CorrectNumberOfTeams_Test() { //Arrange var team1 = new Team {Id = 0, Name = "Team1", MetaData = "Meta1", UserIDs = new[] {1}}; var team2 = new Team {Id = 1, Name = "Team2", MetaData = "Meta2", UserIDs = new[] {2}}; var teamList = new List<Team> {team1, team2}; _adapterMock.Setup(r => r.Read()).Returns(teamList.AsQueryable()); var teamHandler = new TeamHandler(_adapterMock.Object); //Act var actualTeams = teamHandler.GetAll(); var counter = actualTeams.Count(); //Assert Assert.IsTrue(counter == teamList.Count); }
public async void ReadTeam_Valid_CorrectInformation_Test() { //Arrange _adapterMock.Setup(r => r.Read(_team.Id)).Returns(Task.FromResult(_team)); var teamHandler = new TeamHandler(_adapterMock.Object); //Act var actualTeam = await teamHandler.Read(_team.Id); //Assert Assert.IsTrue(actualTeam.Id == _team.Id); Assert.IsTrue(actualTeam.Name == _team.Name); Assert.IsTrue(actualTeam.MetaData == _team.MetaData); Assert.IsTrue(actualTeam.UserIDs.Length == _team.UserIDs.Length); }
public async void DeleteUser_Invalid_InvalidId_Test() { //Arrange var teamHandler = new TeamHandler(_adapterMock.Object); var invalidId = -1; //Act var result = await teamHandler.Delete(invalidId); //Assert //Exception must be thrown }
public async void DeleteTeam_Invalid_NoExistingTeam_Test() { //Arrange _adapterMock.Setup(r => r.DeleteIfExists(_team.Id)).Throws(new NullReferenceException()); var teamHandler = new TeamHandler(_adapterMock.Object); //Act await teamHandler.Delete(_team.Id); //Assert //Exception must be thrown }
public async void DeleteTeam_Valid_Test() { //Arrange var adapter = new Mock<IAdapter<Team, StoredTeam>>(); const int idToDelete = 0; adapter.Setup(r => r.DeleteIfExists(idToDelete)).Returns(Task.FromResult(true)); var teamHandler = new TeamHandler(adapter.Object); //Act var result = await teamHandler.Delete(idToDelete); //Assert Assert.IsTrue(result); }