コード例 #1
0
        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
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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));

        }