상속: IGroupModel
예제 #1
0
 public void CreateGroup_InValidModel_InvalidGroupException()
 {
     IGroupModel group = new Group();
     A.CallTo(() => _entityValidator.ValidateEntity(group)).Returns(new EntityValidationResult(false));
     Assert.Throws<InvalidGroupException>(() => _groupService.CreateGroupAsync(group));
     A.CallTo(() => _groupRepository.CreateGroup(A<IGroupDto>.Ignored)).MustNotHaveHappened();
 }
예제 #2
0
        public void ToUser_CreateUserViewModel_CorrectlyMapped()
        {
            const string FirstName = "FirstName";
            const string LastName = "LastName";
            const string Email = "Email";
            Group Group = new Group { GroupId = 5, GroupNumber = 2, Year = 2009 };

            var user = new UserViewModel
                       {
                           FirstName = FirstName,
                           Email = Email,
                           LastName = LastName,
                           //GroupId = Group.GroupId
                       };

            var userModel = user.ToUser();

            Assert.NotNull(userModel);
            Assert.Equal(FirstName, userModel.FirstName);
            Assert.Equal(LastName, userModel.LastName);
            Assert.Equal(Email, userModel.Email);
            Assert.Equal(Group.GroupNumber, userModel.Group.GroupNumber);
            Assert.Equal(Group.Year, userModel.Group.Year);
            Assert.Equal(default(int), userModel.UserId);
        }
예제 #3
0
        public void CreateGroup_ValidModel_CreateGroupCalled()
        {
            IGroupModel group = new Group();
            A.CallTo(() => _entityValidator.ValidateEntity(group)).Returns(new EntityValidationResult(true));
            A.CallTo(() => _groupRepository.GetGroups()).Returns(Enumerable.Empty<IGroupDto>().AsQueryable());
            A.CallTo(() => _groupDtoMapper.Map(group)).Returns(A.Dummy<IGroupDto>());

            _groupService.CreateGroupAsync(group);

            A.CallTo(() => _groupRepository.CreateGroup(A<IGroupDto>.Ignored)).MustHaveHappened();
        }