public void GivenAId_WhenASubDocTypeIsRequested_ThenASubDocTypeIsReturned() { _subDocTypeRepository.Setup(a => a.GetSubDocType(It.IsAny <int>())).Returns(new SubDocType()); SubDocType subDocType = _subDocTypeService.GetSubDocType(It.IsAny <int>()); subDocType.Should().NotBeNull(); }
public void WhenIUpdateASubDocType_AndTheSubDocTypeDoesNotExist_ThenAnExceptionIsThrown() { _subDocTypeRepository.Create(_subDocType1); SubDocType docType = _subDocTypeRepository.Entities.Where(p => p.Code == "code 1").FirstOrDefault(); Assert.Throws <UnityException>(() => _subDocTypeRepository.Update(docType.Id + 1001, "code 1", "description name 1")); }
public void GivenSubDocTypeCode_WhenASubDocTypeIsRequested_ThenASubDocTypeIsReturned() { _subDocTypeRepository.Setup(a => a.GetSubDocType(It.IsAny <string>())).Returns(new SubDocType()); SubDocType subDocType = _subDocTypeService.GetSubDocType(It.IsAny <string>()); _subDocTypeRepository.Verify(a => a.GetSubDocType(It.IsAny <string>()), Times.Once()); subDocType.Should().NotBeNull(); }
public void WhenIUpdateASubDocType_ThenTheSubDocTypeIsUpdated() { _subDocTypeRepository.Create(_subDocType1); SubDocType subDocType = _subDocTypeRepository.Entities.Where(p => p.Code == "code 1").FirstOrDefault(); _subDocTypeRepository.Update(subDocType.Id, "new code", "description 1"); subDocType = _subDocTypeRepository.Entities.Where(p => p.Code == "new code").FirstOrDefault(); subDocType.Should().NotBeNull(); }
public virtual ActionResult Edit(int subDocTypeId) { SubDocType subDocType = _subDocTypeService.GetSubDocType(subDocTypeId); var docTypes = _docTypeService.GetDocTypes(); var model = new EditSubDocTypeViewModel() { Code = subDocType.Code, Description = subDocType.Description, SubDocTypeId = subDocType.Id }; model.AddDocTypes(docTypes); return(View(model)); }
public void Setup() { _transactionScope = new TransactionScope(); _autoApprovalRepository = new AutoApprovalRepository(ConfigurationManager.ConnectionStrings["Unity"].ConnectionString); _docTypeRepository = new DocTypeRepository(ConfigurationManager.ConnectionStrings["Unity"].ConnectionString); _subDocTypeRepository = new SubDocTypeRepository(ConfigurationManager.ConnectionStrings["Unity"].ConnectionString); _manCoRepository = new ManCoRepository(ConfigurationManager.ConnectionStrings["Unity"].ConnectionString); _docType = BuildMeA.DocType("code", "description"); _manCo1 = BuildMeA.ManCo("code1", "description1"); _manCo2 = BuildMeA.ManCo("code2", "description2"); _subDocType1 = BuildMeA.SubDocType("code 1", "description 1").WithDocType(_docType); _subDocType2 = BuildMeA.SubDocType("code 2", "description 3").WithDocType(_docType); _autoApproval = BuildMeA.AutoApproval().WithDocType(_docType).WithSubDocType(_subDocType1).WithManCo(_manCo1); _autoApproval2 = BuildMeA.AutoApproval().WithDocType(_docType).WithSubDocType(_subDocType2).WithManCo(_manCo2); _autoApproval3 = BuildMeA.AutoApproval().WithDocType(_docType).WithSubDocType(_subDocType2).WithManCo(_manCo1); }
private void SetUpVariables() { _manCo1 = new ManCo { Id = 1 }; _manCo2 = new ManCo { Id = 2 }; _manCo3 = new ManCo { Id = 3 }; this._manCos = new List <ManCo>(); this._manCos.Add(_manCo1); this._manCos.Add(_manCo2); this._manCos.Add(_manCo3); _docType1 = new DocType { Id = 1, Code = "Code1" }; _docType2 = new DocType { Id = 2, Code = "Code2" }; _docType3 = new DocType { Id = 3, Code = "Code3" }; this._docTypes = new List <DocType>(); this._docTypes.Add(_docType1); this._docTypes.Add(_docType2); this._docTypes.Add(_docType3); this._subDocType1 = new SubDocType { Id = 1, DocType = _docType1, Code = "SubCode1" }; this._subDocType2 = new SubDocType { Id = 2, DocType = _docType1, Code = "subCode2" }; this._subDocType3 = new SubDocType { Id = 3, DocType = _docType1, Code = "SubCode3" }; this._subDocType4 = new SubDocType { Id = 4, DocType = _docType2, Code = "SubCode4" }; this._subDocType5 = new SubDocType { Id = 5, DocType = _docType2, Code = "SubCode5" }; this._subDocType6 = new SubDocType { Id = 6, DocType = _docType3, Code = "SubCode6" }; this._subDocType7 = new SubDocType { Id = 7, DocType = _docType3, Code = "SubCode7" }; this._subDocType8 = new SubDocType { Id = 8, DocType = _docType3, Code = "SubCode8" }; this._subDocTypes = new List <SubDocType>(); this._subDocTypes.Add(_subDocType1); this._subDocTypes.Add(_subDocType2); this._subDocTypes.Add(_subDocType3); this._subDocTypes.Add(_subDocType4); this._subDocTypes.Add(_subDocType5); this._subDocTypes.Add(_subDocType6); this._subDocTypes.Add(_subDocType7); this._subDocTypes.Add(_subDocType8); this._approval1 = new AutoApproval { Id = 1, DocType = _docType1, SubDocType = _subDocType1, Manco = _manCo1 }; this._approval2 = new AutoApproval { Id = 2, DocType = _docType1, SubDocType = _subDocType2, Manco = _manCo1 }; this._approval3 = new AutoApproval { Id = 3, DocType = _docType1, SubDocType = _subDocType3, Manco = _manCo1 }; this._approval4 = new AutoApproval { Id = 4, DocType = _docType2, SubDocType = _subDocType4, Manco = _manCo1 }; this._approval5 = new AutoApproval { Id = 5, DocType = _docType3, SubDocType = _subDocType7, Manco = _manCo1 }; this._approvals = new List <AutoApproval>(); this._approvals.Add(_approval1); this._approvals.Add(_approval2); this._approvals.Add(_approval3); this._approvals.Add(_approval4); this._approvals.Add(_approval5); }
public AutoApprovalBuilder WithSubDocType(SubDocType subDocType) { Instance.SubDocType = subDocType; return(this); }
public DocumentBuilder WithSubDocType(SubDocType subDocType) { Instance.SubDocType = subDocType; return(this); }