public CreateContactViewModel(UpdateContactQueryResult createContact, IValidationService validationService)
 {
     this.command = createContact.Command;
     this.Counties = createContact.Counties;
     this.Countries = createContact.Countries;
     this.validationService = validationService;
 }
예제 #2
0
        public WhenUserRequestsUpdateContactForm()
        {
            var contactRepository = Mock.Of<IContactRepository>();

            Mock.Get(contactRepository)
                .Setup(q => q.GetById(1))
                .Returns(new Contact(new CreateContactCommand
                {
                    FirstName = "Bob",
                    Surname = "Holness",
                    Address1 = "1 Blockbuster way",
                    Address2 = "ITV Town",
                })
                {
                    County = new County(1, "Some County"),
                    Country = new Country(2, "UK"),
                });

            var countyRepository = Mock.Of<ICountyRepository>();
            var countryRepository = Mock.Of<ICountryRepository>();

            var queryInvoker = new QueryInvoker(new ContactService(countyRepository,
                countryRepository,
                contactRepository,
                new ValidationService(),
                new ContactAdministrationService(countyRepository,
                    countryRepository,
                    contactRepository)));

            Mock.Get(countyRepository).Setup(q => q.GetAll()).Returns(_counties);
            Mock.Get(countryRepository).Setup(q => q.GetAll()).Returns(_countries);

            _queryResult =
                queryInvoker.Query<UpdateContactQuery, UpdateContactQueryResult>(new UpdateContactQuery {Id = 1});
        }
예제 #3
0
        public WhenUserRequestsToUpdateAnExistingContactWithInvalidContact()
        {
            _contactRepository = Mock.Of<IContactRepository>();
            var countyRepository = Mock.Of<ICountyRepository>();
            Mock.Get(countyRepository)
                .Setup(q => q.GetById(1))
                .Returns(new County(1, "Merseyside"));

            var countryRepository = Mock.Of<ICountryRepository>();
            Mock.Get(countryRepository)
                .Setup(q => q.GetById(1))
                .Returns(new Country(1, "UK"));

            var commandInvoker = new CommandInvoker(new ContactService(countyRepository,
                countryRepository,
                _contactRepository,
                new ValidationService(),
                new ContactAdministrationService(countyRepository,
                    countryRepository,
                    _contactRepository)));

            Mock.Get(countyRepository).Setup(q => q.GetAll()).Returns(_counties);
            Mock.Get(countryRepository).Setup(q => q.GetAll()).Returns(_countries);

            _updateCommand = new UpdateContactCommand
            {
                Id = 1,
                FirstName = "",
                Surname = "",
                Address1 = "Address 1",
                Address2 = "Address 2",
                CountyId = 1,
                CountryId = 1,
            };
            _result = commandInvoker.Execute<UpdateContactCommand, UpdateContactQueryResult>(_updateCommand);
        }