/// <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 CreateUser_Valid_Test() { //Arrange _adapterMock.Setup(r => r.Create(_user)).Returns(Task.FromResult(_user.Id)); var userHandler = new UserHandler(_adapterMock.Object); //Act var returnedId = await userHandler.Create(_user); //Assert Assert.IsTrue(returnedId == _user.Id); }
public async void CreateUser_Invalid_userInformationEmptyString_Test() { //Arrange var user = new User {Name = "", MetaData = ""}; _adapterMock.Setup(r => r.Create(user)); var userHandler = new UserHandler(_adapterMock.Object); //Act var result = await userHandler.Create(user); //Assert //Exception must be thrown }
public void ReadAllTeams_Valid_CorrectNumberOfTeams_Test() { //Arrange var team1 = new User {Id = 0, Name = "User1", MetaData = "Meta1"}; var team2 = new User {Id = 1, Name = "User2", MetaData = "Meta2"}; var users = new List<User> {team1, team2}; _adapterMock.Setup(r => r.Read()).Returns(users.AsQueryable()); var userHandler = new UserHandler(_adapterMock.Object); //Act var actualUsers = userHandler.GetAll(); var counter = actualUsers.Count(); //Assert Assert.IsTrue(counter == users.Count); }
public async void ReadUser_Valid_CorrectInformation_Test() { //Arrange _adapterMock.Setup(r => r.Read(_user.Id)).Returns(Task.FromResult(_user)); var userHandler = new UserHandler(_adapterMock.Object); //Act var actualUser = await userHandler.Read(_user.Id); //Assert Assert.IsTrue(actualUser.Id == _user.Id); Assert.IsTrue(actualUser.Name == _user.Name); Assert.IsTrue(actualUser.MetaData == _user.MetaData); }
public async void ReadUser_Valid_TypeOfUser_Test() { //Arrange _adapterMock.Setup(r => r.Read(_user.Id)).Returns(Task.FromResult(_user)); var userHandler = new UserHandler(_adapterMock.Object); //Act var user = await userHandler.Read(_user.Id); //Assert Assert.IsInstanceOfType(user, typeof (User)); }
public void ReadUser_Valid_IsNotNull_Test() { //Arrange _adapterMock.Setup(r => r.Read(_user.Id)).Returns(Task.FromResult(_user)); var userHandler = new UserHandler(_adapterMock.Object); //Act var user = userHandler.Read(_user.Id); //Assert Assert.IsNotNull(user); }
public async void DeleteUser_Invalid_InvalidId_Test() { //Arrange var userHandler = new UserHandler(_adapterMock.Object); var invalidId = -1; //Act var result = await userHandler.Delete(invalidId); //Assert //Exception must be thrown }
public async void DeleteUser_Invalid_NoExistingUser_Test() { //Arrange _adapterMock.Setup(a => a.DeleteIfExists(_user.Id)).Throws(new NullReferenceException()); var userHandler = new UserHandler(_adapterMock.Object); //Act var result = await userHandler.Delete(_user.Id); //Assert //Exception must be thrown }
public async void DeleteUser_Valid_Test() { //Arrange const int idToDelete = 0; _adapterMock.Setup(a => a.DeleteIfExists(idToDelete)).Returns(Task.FromResult(true)); var userHandler = new UserHandler(_adapterMock.Object); //Act var result = await userHandler.Delete(idToDelete); //Assert Assert.IsTrue(result); }
public async void CreateUser_Invalid_userIsNull_Test() { //Arrange _adapterMock.Setup(r => r.Create(null)); var userHandler = new UserHandler(_adapterMock.Object); //Act var result = await userHandler.Create(null); //Assert //Exception must be thrown }