예제 #1
0
        public void When_Delete_Then_get_responsibility_from_repo()
        {
            // Given
            _target = GetTarget();

            // When
            _target.Delete(_responsibilityId, _companyId, _actioningUserId);

            // Then
            _responsibilityRepo.Verify(x => x.GetByIdAndCompanyId(_responsibilityId, _companyId));
        }
예제 #2
0
        public void Given_responsibility_found_When_Delete_Then_tell_it_to_delete_itself()
        {
            // Given
            _target = GetTarget();

            // When
            _target.Delete(_responsibilityId, _companyId, _actioningUserId);

            // Then
            _responsibility.Verify(x => x.MarkForDelete(_actioningUser));
        }
예제 #3
0
        public void Given_responsibility_found_When_Undelete_Then_tell_it_to_Undelete_itself()
        {
            // Given
            _target = GetTarget();

            // When
            _target.Undelete(_responsibilityId, _companyId, _actioningUserId);

            // Then
            _responsibility.Verify(x => x.ReinstateFromDelete(_actioningUser));
        }
        public void Given_responsibility_can_be_deleted_When_CanBeDeleted_Then_return_true()
        {
            // Given
            _target = GetTarget();

            // When
            var result = _target.HasUndeletedTasks(_responsibilityId, _companyId);

            // Then
            Assert.IsTrue(result);
        }
        public void Given_responsibility_not_found_When_CanBeDeleted_Then_log_and_throw_exception()
        {
            // Given
            _responsibilityRepo
                .Setup(x => x.GetByIdAndCompanyId(_responsibilityId, _companyId));

            _target = GetTarget();

            // When
            // Then
            var e = Assert.Throws<ResponsibilityNotFoundException>(() => _target.GetResponsibility(_responsibilityId, _companyId));
            _log.Verify(x => x.Add(e));
        }
        public void Given_responsibility_When_GetResponsibility_Then_responsibilityDto()
        {
            // Given
            _target = GetTarget();

            // When
            var result = _target.GetResponsibility(_responsibilityId, _companyId);

            // Then
            Assert.IsInstanceOf<ResponsibilityDto>(result);
            Assert.That(result.Id, Is.EqualTo(_responsibility.Id));
            Assert.That(result.CompanyId, Is.EqualTo(_companyId));
        }
        public void Given_responsibility_can_not_be_deleted_When_CanBeDeleted_Then_return_false()
        {
            // Given
            _responsibility
                .Setup(x => x.HasUndeletedTasks())
                .Returns(false);

            _target = GetTarget();

            // When
            var result = _target.HasUndeletedTasks(_responsibilityId, _companyId);

            // Then
            Assert.IsFalse(result);
        }
        public void Given_Previous_ResponsibilityId_Not_Found_When_Copy_Responsibility_Then_Return_Not_Found_Exception()
        {
            // Given
            _target = GetTarget();

            _responsibilityRepo.Setup(x => x.GetByIdAndCompanyId(It.IsAny<long>(), It.IsAny<long>())).Throws(new ResponsibilityNotFoundException(_originalResponsibilityId, _companyId));

            var request = new CopyResponsibilityRequest()
            {
                OriginalResponsibilityId = 1,
                Title = "Title"
            };

            // When
            Assert.Throws<ResponsibilityNotFoundException>(() => _target.CopyResponsibility(request));

            // Then
        }
        public void Given_ResponsibilityId_Found_When_Copy_Responsibility_Then_Check_New_Responsibility_Created_With_Originals_Parameters()
        {
            // Given
            _target = GetTarget();
            
            _responsibilityRepo.Setup(x => x.GetByIdAndCompanyId(It.IsAny<long>(), It.IsAny<long>()))
                .Returns(_originalResponibility);

            var request = new CopyResponsibilityRequest()
            {
                CompanyId = _companyId,
                OriginalResponsibilityId = _originalResponsibilityId,
                Title = "new Title"
            };

            Responsibility newResponsibility = null;

            _responsibilityRepo.Setup(x => x.Save(It.IsAny<Responsibility>()))
                .Callback<Responsibility>(r => newResponsibility = r);

            // When
            _target.CopyResponsibility(request);
            
            // Then
            Assert.True(newResponsibility.CompanyId.Equals(_originalResponibility.CompanyId));
            Assert.True(newResponsibility.ResponsibilityCategory.Equals(_originalResponibility.ResponsibilityCategory));
            Assert.False(newResponsibility.Title.Equals(_originalResponibility.Title));
            Assert.True(newResponsibility.Description.Equals(_originalResponibility.Description));
            Assert.IsNull(newResponsibility.Site);
            Assert.IsNull(newResponsibility.Owner);
            Assert.True(newResponsibility.InitialTaskReoccurringType.Equals(_originalResponibility.InitialTaskReoccurringType));
            Assert.True(newResponsibility.ResponsibilityTasks.Count.Equals(_originalResponibility.ResponsibilityTasks.Count));
            Assert.False(newResponsibility.CreatedOn.Equals(_originalResponibility.CreatedOn));
            Assert.True(newResponsibility.StatutoryResponsibilityTemplateCreatedFrom.Equals(_originalResponibility.StatutoryResponsibilityTemplateCreatedFrom));
            Assert.False(newResponsibility.Id.Equals(_originalResponibility.Id));
        }
        public void Given_ResponsibilityId_Found_For_Responsibility_With_Tasks_When_Copy_Responsibility_Then_Check_New_Responsibility_Created_With_Originals_Tasks()
        {
            // Given
            _target = GetTarget();

            _responsibilityRepo.Setup(x => x.GetByIdAndCompanyId(It.IsAny<long>(), It.IsAny<long>()))
               .Returns(_originalResponibility);

            var request = new CopyResponsibilityRequest()
            {
                CompanyId = _companyId,
                OriginalResponsibilityId = _originalResponsibilityId,
                Title = "new Title"
            };

            Responsibility newResponsibility = null;

            _responsibilityRepo.Setup(x => x.Save(It.IsAny<Responsibility>()))
                .Callback<Responsibility>(r => newResponsibility = r);

            // When
            _target.CopyResponsibility(request);

            Assert.True(newResponsibility.ResponsibilityTasks.Count.Equals(_originalResponibility.ResponsibilityTasks.Count));

        }