Beispiel #1
0
        public void ActorOrganisation_Returns_ValidViewModel()
        {
            var orgs = MongoActorOrganisations.ActorOrganisations;

            var orgViewModel = orgs.Select(ActorOrganisation.ToViewModel).First();

            var expectedViewModel = new ActorOrganisationViewModel
            {
                Id       = "5a82f9ffcb969daa58d33377",
                Type     = ActorType.Consumer,
                Name     = "Ambulance Service",
                ImageUrl = "....",
                Context  = new List <ContentView>()
                {
                    new ContentView
                    {
                        Title   = "Title Text",
                        Content = new List <string> {
                            "Content Text"
                        },
                        CssClass = "CssClass Text",
                        Order    = 1
                    }
                },
                OrgCode  = "AMSR01",
                Benefits = new List <string> {
                    "benefitid"
                },
                PersonnelLinkId = "testlink"
            };

            Assert.Equal(expectedViewModel, orgViewModel, Comparers.ModelComparer <ActorOrganisationViewModel>());
        }
Beispiel #2
0
        public ActorOrganisationsControllerTests()
        {
            var model = new ActorOrganisationViewModel
            {
                Id       = "5a82f9ffcb969daa58d33377",
                Type     = ActorType.Consumer,
                Name     = "Ambulance Service",
                ImageUrl = "....",
                Context  = new List <ContentView>()
                {
                    new ContentView
                    {
                        Title   = "Title Text",
                        Content = new List <string> {
                            "Content Text"
                        },
                        CssClass = "CssClass Text",
                        Order    = 1
                    }
                },
                OrgCode  = "AMSR01",
                Benefits = new List <string> {
                    "benefitid"
                },
                PersonnelLinkId = "testlink"
            };

            var actorOrganisationService = new Mock <IActorOrganisationService>();

            actorOrganisationService.Setup(x => x.GetById(It.Is <string>(y => y == "5a82f9ffcb969daa58d33377"))).Returns(Task.Run(() => model));
            actorOrganisationService.Setup(x => x.GetById(It.Is <string>(y => y == "5a82f9ffcb969daa58d33378"))).Returns(Task.Run(() => (ActorOrganisationViewModel)null));
            _actorOrganisationService = actorOrganisationService.Object;
        }
        public static ActorOrganisationViewModel ToViewModel(ActorOrganisation model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model), "Cannot map null ActorOrganisation");
            }

            var viewModel = new ActorOrganisationViewModel
            {
                Id              = model.Id.ToString(),
                Context         = model.Context.OrderBy(x => x.Order).ToList(),
                ImageUrl        = model.ImageUrl,
                Name            = model.Name,
                OrgCode         = model.OrgCode,
                Type            = EnumHelpers.GetEnum <ActorType>(model.Type),
                Benefits        = model.Benefits,
                PersonnelLinkId = model.PersonnelLinkId
            };

            return(viewModel);
        }