コード例 #1
0
        /// <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());
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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));
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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
        }
コード例 #9
0
        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
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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
        }