public void MapsSuffix()
            {
                const string value = "test";
                var model = new GenerateDisplayNameForm { Suffix = value };

                var query = Mapper.Map<GenerateDisplayNameQuery>(model);

                query.ShouldNotBeNull();
                query.Suffix.ShouldNotBeNull();
                query.Suffix.ShouldEqual(model.Suffix);
            }
            public void MapsLastName()
            {
                const string value = "test";
                var model = new GenerateDisplayNameForm { LastName = value };

                var query = Mapper.Map<GenerateDisplayNameQuery>(model);

                query.ShouldNotBeNull();
                query.LastName.ShouldNotBeNull();
                query.LastName.ShouldEqual(model.LastName);
            }
Example #3
0
            public void MapsSuffix()
            {
                const string value = "test";
                var          model = new GenerateDisplayNameForm {
                    Suffix = value
                };

                var query = Mapper.Map <GenerateDisplayNameQuery>(model);

                query.ShouldNotBeNull();
                query.Suffix.ShouldNotBeNull();
                query.Suffix.ShouldEqual(model.Suffix);
            }
Example #4
0
            public void MapsLastName()
            {
                const string value = "test";
                var          model = new GenerateDisplayNameForm {
                    LastName = value
                };

                var query = Mapper.Map <GenerateDisplayNameQuery>(model);

                query.ShouldNotBeNull();
                query.LastName.ShouldNotBeNull();
                query.LastName.ShouldEqual(model.LastName);
            }
            public void ExecutesQuery_ToGenerateDisplayName()
            {
                var model = new GenerateDisplayNameForm
                {
                    Salutation = "Mr",
                    FirstName = "Adam",
                    MiddleName = "B",
                    LastName = "West",
                    Suffix = "Sr.",
                };
                var scenarioOptions = new ScenarioOptions();
                var controller = CreateController(scenarioOptions);
                scenarioOptions.MockQueryProcessor.Setup(m => m.Execute(
                    It.Is(GenerateDisplayNameQueryBasedOn(model))))
                    .Returns("derived display name");

                controller.GenerateDisplayName(model);

                scenarioOptions.MockQueryProcessor.Verify(m => m.Execute(
                    It.Is(GenerateDisplayNameQueryBasedOn(model))),
                        Times.Once());
            }
 public virtual JsonResult GenerateDisplayName(GenerateDisplayNameForm model)
 {
     var query = Mapper.Map<GenerateDisplayNameQuery>(model);
     var displayName = _services.QueryProcessor.Execute(query);
     return Json(displayName);
 }
            public void ReturnsJson_WithGeneratedDisplayName()
            {
                const string generatedDisplayName = "generated display name";
                var model = new GenerateDisplayNameForm
                {
                    Salutation = "Mr",
                    FirstName = "Adam",
                    MiddleName = "B",
                    LastName = "West",
                    Suffix = "Sr.",
                };
                var scenarioOptions = new ScenarioOptions();
                var controller = CreateController(scenarioOptions);
                scenarioOptions.MockQueryProcessor.Setup(m => m.Execute(
                    It.Is(GenerateDisplayNameQueryBasedOn(model))))
                    .Returns(generatedDisplayName);

                var result = controller.GenerateDisplayName(model);

                result.ShouldNotBeNull();
                result.ShouldBeType<JsonResult>();
                result.Data.ShouldEqual(generatedDisplayName);
            }
 private static Expression<Func<GenerateDisplayNameQuery, bool>> GenerateDisplayNameQueryBasedOn(GenerateDisplayNameForm model)
 {
     Expression<Func<GenerateDisplayNameQuery, bool>> generateDisplayNameQueryBasedOn = q =>
         q.Salutation == model.Salutation &&
         q.FirstName == model.FirstName &&
         q.MiddleName == model.MiddleName &&
         q.LastName == model.LastName &&
         q.Suffix == model.Suffix
     ;
     return generateDisplayNameQueryBasedOn;
 }