public void Create_WithoutLapCode_Valid() { var subject = "FOO"; var inModel = new HelpDeskModel { Subject = subject }; var request = MappingEngine.Map <InsHelpDeskNotificationRequest>(inModel); var response = new InsHelpDeskNotificationResponse { requestID = 123, ExecutionResult = new ExecutionResult { Status = ExecuteStatus.Success } }; var sinf = new List <RelatedCodeModel> { new RelatedCodeModel { Dominant = true, SubordinateCode = subject } }; var sula = new RelatedCodeModel { Dominant = true, SubordinateCode = subject, SubordinateDescription = string.Empty }; mockAdwService.Setup(m => m.GetRelatedCodes("SINF", inModel.Subject)).Returns(sinf); mockAdwService.Setup(m => m.GetRelatedCode("SULA", request.subjectArea, "TODO")).Returns(sula); mockMappingEngine.Setup(m => m.Map <InsHelpDeskNotificationRequest>(inModel)).Returns(request); mockHelpDeskWcf.Setup(m => m.Insert(request)).Returns(response); var result = SystemUnderTest().Create(inModel); Assert.IsTrue(result == response.requestID); mockMappingEngine.Verify(m => m.Map <InsHelpDeskNotificationRequest>(inModel), Times.Once()); mockHelpDeskWcf.Verify(m => m.Insert(request), Times.Once()); }
public void Create_WcfThrowsFaultException_ThrowsServiceValidationException() { var exception = new FaultException(new FaultReason("reason"), new FaultCode("code")); var subject = "FOO"; var inModel = new HelpDeskModel { Subject = subject }; var request = MappingEngine.Map <InsHelpDeskNotificationRequest>(inModel); var sinf = new List <RelatedCodeModel> { new RelatedCodeModel { Dominant = true, SubordinateCode = subject } }; var sula = new RelatedCodeModel { Dominant = true, SubordinateCode = subject, SubordinateDescription = "LAPCODE" }; mockAdwService.Setup(m => m.GetRelatedCodes("SINF", inModel.Subject)).Returns(sinf); mockAdwService.Setup(m => m.GetRelatedCode("SULA", request.subjectArea, string.Empty)).Returns(sula); mockMappingEngine.Setup(m => m.Map <InsHelpDeskNotificationRequest>(inModel)).Returns(request); mockHelpDeskWcf.Setup(m => m.Insert(request)).Throws(exception); SystemUnderTest().Create(inModel); }
public void ListRelatedCode_PostRedirectedToGet() { // Arrange var controller = SystemUnderTest(); var viewModel = new ListRelatedCodeViewModel() { StartFromTableType = "A", ListType = "A", MaxRows = 1, ExactLookup = true }; var codeModel = new RelatedCodeModel { RelatedCode = "ABCD", DominantDescription = "dominant Description", SubordinateDescription = "Sub Description" }; IList <RelatedCodeModel> models = new List <RelatedCodeModel>() { codeModel }; mockAdwAdminService.Setup(m => m.GetRelatedCodes(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <int>())).Returns(models); // Act var result = controller.ListRelatedCode(viewModel) as RedirectToRouteResult; // Assert Assert.IsNotNull(result, "Redirect To Route Result must not be null."); if (result != null) { Assert.AreEqual("ListRelatedCode", result.RouteValues["action"]); } }
public void AllRelatedCodeModelTest() { var target = new RelatedCodeModel(); Assert.IsNotNull(target); target.Dominant = true; target.DominantCode = "DomCode"; target.DominantDescription = "DomDesc"; target.DominantShortDescription = "DomShortDesc"; target.EndDate = new DateTime(2012, 1, 10); target.Position = 101; target.RelatedCode = "RelCode"; target.StartDate = new DateTime(2012, 1, 1); target.SubordinateCode = "Subcode"; target.SubordinateDescription = "subdesc"; target.SubordinateShortDescription = "subshortdesc"; Assert.AreEqual(true, target.Dominant); Assert.AreEqual("DomCode", target.DominantCode); Assert.AreEqual("DomDesc", target.DominantDescription); Assert.AreEqual("DomShortDesc", target.DominantShortDescription); Assert.AreEqual(new DateTime(2012, 1, 10), target.EndDate); Assert.AreEqual(101, target.Position); Assert.AreEqual("RelCode", target.RelatedCode); Assert.AreEqual(new DateTime(2012, 1, 1), target.StartDate); Assert.AreEqual("Subcode", target.SubordinateCode); Assert.AreEqual("subdesc", target.SubordinateDescription); Assert.AreEqual("subshortdesc", target.SubordinateShortDescription); }
public void ListRelatedCode_GetWithoutPostRedirect() { // Arrange var controller = SystemUnderTest(); var codeModel = new RelatedCodeModel { RelatedCode = "ABCD", DominantDescription = "dominant Description", SubordinateDescription = "Sub Description" }; IList <RelatedCodeModel> models = new List <RelatedCodeModel>() { codeModel }; mockAdwAdminService.Setup(m => m.GetRelatedCodes(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <int>())).Returns(models); // Act var result = controller.ListRelatedCode(null, null, null, null) as ViewResult; // Assert Assert.IsNotNull(result, "View Result must not be null."); if (result != null) { var model = result.Model as ListRelatedCodeViewModel; Assert.IsNotNull(model, "Model must not be null."); } }
public void ListRelatedCode_GetPostRedirect() { // Arrange var controller = SystemUnderTest(); var codeModel = new RelatedCodeModel { RelatedCode = "ABCD", DominantDescription = "dominant Description", SubordinateDescription = "Sub Description" }; IList <RelatedCodeModel> models = new List <RelatedCodeModel>() { codeModel }; mockAdwAdminService.Setup(m => m.GetRelatedCodes(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <int>())).Returns(models); // Act var result = controller.ListRelatedCode(relatedtable: "Related", startcode: "A", listtype: "A", searchtable: "search") as ViewResult; // Assert Assert.IsNotNull(result, "View Result must not be null."); if (result != null) { var model = result.Model as ListRelatedCodeViewModel; Assert.IsNotNull(model, "Model must not be null."); Assert.AreEqual(model.StartFromTableType, "A"); Assert.IsTrue(model.Results.ToList().Count == 1); } }
//private static IMappingEngine MappingEngine //{ // get // { // var containerProvider = DependencyResolver.Current as IContainerProvider; // if (containerProvider != null) // { // return containerProvider.GetService<IMappingEngine>(); // } // return null; // } //} /// <summary> /// Converts the current instance of <see cref="RelatedCodeModel" /> to a <see cref="CodeModel" />. /// </summary> /// <returns>The current instance of <see cref="RelatedCodeModel" /> as a <see cref="CodeModel" />.</returns> public static CodeModel ToCodeModel(this RelatedCodeModel model) { var codeModel = new CodeModel(); codeModel.Code = (model.Dominant ? model.SubordinateCode : model.DominantCode); codeModel.Description = (model.Dominant ? model.SubordinateDescription : model.DominantDescription); codeModel.ShortDescription = (model.Dominant ? model.SubordinateShortDescription : model.DominantShortDescription); return(codeModel); }
/// <summary> /// Extension method for mapping <see cref="RelatedCodeModel"/> to <see cref="RelatedCodeViewModel"/>. /// </summary> /// <param name="relatedCodeModel"><see cref="RelatedCodeModel"/> instance.</param> /// <returns>Instance of <see cref="RelatedCodeViewModel"/>.</returns> public static RelatedCodeViewModel ToRelatedCodeViewModel(this RelatedCodeModel relatedCodeModel) { if (relatedCodeModel == null) { return(null); } return(new RelatedCodeViewModel { CurrencyEnd = relatedCodeModel.EndDate, CurrencyStart = relatedCodeModel.StartDate, DominantCode = relatedCodeModel.DominantCode, DominantLongDescription = relatedCodeModel.DominantDescription, DominantShortDescription = relatedCodeModel.DominantShortDescription, //HasCurrencyEnd = relatedCodeModel. RelationshipTypeCode = relatedCodeModel.RelatedCode, RowPosition = relatedCodeModel.Position, SubCode = relatedCodeModel.SubordinateCode, SubLongDescription = relatedCodeModel.SubordinateDescription, SubShortDescription = relatedCodeModel.SubordinateShortDescription }); }
public void RelatedCodeModelConstructorTest() { var target = new RelatedCodeModel(); Assert.IsNotNull(target); }
//private static IMappingEngine MappingEngine //{ // get // { // var containerProvider = DependencyResolver.Current as IContainerProvider; // if ( containerProvider != null ) // { // return containerProvider.GetService<IMappingEngine>(); // } // return null; // } //} /// <summary> /// Converts the current instance of <see cref="RelatedCodeModel" /> to a <see cref="CodeModel" />. /// </summary> /// <returns>The current instance of <see cref="RelatedCodeModel" /> as a <see cref="CodeModel" />.</returns> public static CodeModel ToCodeModel(this RelatedCodeModel model) { //return MappingEngine.Map<CodeModel>( model ); return(null); }