Пример #1
0
 public NationalityServiceTest()
 {
     AddNationalityCommandMock     = new Mock <IAddNationalityCommand>();
     UpdateNationalityCommandMock  = new Mock <IUpdateNationalityCommand>();
     ListAllNationalitiesQueryMock = new Mock <IListAllNationalitiesQuery>();
     ServiceUnderTest = new NationalityService(AddNationalityCommandMock.Object,
                                               UpdateNationalityCommandMock.Object,
                                               ListAllNationalitiesQueryMock.Object);
 }
Пример #2
0
        public async Task GetAllTest()
        {
            _repoWrapper.Setup(r => r.Nationality.GetAllAsync(null, null)).ReturnsAsync(new List <Nationality>().AsQueryable());

            var service = new NationalityService(_repoWrapper.Object, _mapper.Object);

            _mapper.Setup(x => x.Map <Nationality, NationalityDTO>(It.IsAny <Nationality>())).Returns(new NationalityDTO());
            // Act
            var result = await service.GetAllAsync();

            // Assert
            Assert.NotNull(result);
            Assert.IsAssignableFrom <IEnumerable <NationalityDTO> >(result);
        }
Пример #3
0
        // DELETE
        public static Task RemoveNationality(NationalityId id)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new BookOrganizer2DbContext(connectionString);
            var repository       = new NationalityRepository(context);

            var nationalityService = new NationalityService(repository);
            var command            = new Commands.Delete
            {
                Id = id,
            };

            return(nationalityService.Handle(command));
        }
Пример #4
0
        public static Task CreateInvalidNationality()
        {
            var connectionString   = ConnectivityService.GetConnectionString("TEMP");
            var context            = new BookOrganizer2DbContext(connectionString);
            var repository         = new NationalityRepository(context);
            var nationalityService = new NationalityService(repository);

            var nationalityId = new NationalityId(SequentialGuid.NewSequentialGuid());
            var command       = new Commands.Create {
                Id = nationalityId
            };

            return(nationalityService.Handle(command));
        }
        public NationalityDetailViewModelTests()
        {
            var eventAggregatorMock          = new Mock <IEventAggregator>();
            var loggerMock                   = new Mock <ILogger>();
            var nationalityLookupServiceMock = new Mock <INationalityLookupDataService>();
            var nationalityRepoMock          = new Mock <IRepository <Nationality> >();
            var domainService                = new NationalityService(nationalityRepoMock.Object);
            var dialogService                = new DialogService();

            viewModel = new NationalityDetailViewModel(eventAggregatorMock.Object,
                                                       loggerMock.Object,
                                                       domainService,
                                                       nationalityLookupServiceMock.Object,
                                                       dialogService);
        }
Пример #6
0
        internal static Task UpdateNationality(Nationality sut)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new BookOrganizer2DbContext(connectionString);
            var repository       = new NationalityRepository(context);

            var nationalityService = new NationalityService(repository);
            var command            = new Commands.Update
            {
                Id   = sut.Id,
                Name = sut.Name
            };

            return(nationalityService.Handle(command));
        }
Пример #7
0
        public static async Task <Nationality> CreateValidNationality()
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new BookOrganizer2DbContext(connectionString);
            var repository       = new NationalityRepository(context);

            var nationalityService = new NationalityService(repository);

            var command = new Commands.Create
            {
                Id   = new NationalityId(SequentialGuid.NewSequentialGuid()),
                Name = "american"
            };

            await nationalityService.Handle(command);

            return(await repository.GetAsync(command.Id));
        }
Пример #8
0
        public ActionResult Search(WebUIClient.ViewModels.Criminal criminalViewModel, string[] emails)
        {
            {
                try
                {
                    if (ModelState.IsValid)
                    {
                        criminalViewModel.Sex = (char)criminalViewModel.gender;
                        CriminalDTO criteria = _mapper.Map <CriminalDTO>(criminalViewModel);
                        if (CriminalService.SearchCriminals(criteria, emails))
                        {
                            return(JavaScript("<script>alert(\"Success! Results are bieng emailed to you.\");</script>"));
                        }
                        else
                        {
                            return(JavaScript("<script>alert(\"Sorry! No Matching Records Found.\");</script>"));
                        }
                    }
                    ViewData["Nationalities"] = new SelectList(NationalityService.GetNationalities(), "Id", "NationalityName");
                    return(View());
                }
                catch (FaultException <WebUIClient.UserServiceReference.ValidationFault> ex)
                {
                    // Extract the Detail node from the Fault Exception.
                    // This details is the
                    // ValidationFault class
                    WebUIClient.UserServiceReference.ValidationFault fault = ex.Detail;
                    string alert = "";
                    foreach (WebUIClient.UserServiceReference.ValidationDetail validationResult in fault.Details)
                    {
                        alert = String.Concat(string.Format("Message={0} Key={1} Tag={2}",
                                                            validationResult.Message, validationResult.Key,
                                                            validationResult.Tag));
                    }

                    return(JavaScript("<script>alert(\"" + alert + "\");</script>"));
                }
            }
        }
Пример #9
0
        public ActionResult Search()
        {
            try
            {
                ViewData["Nationalities"] = new SelectList(NationalityService.GetNationalities(), "Id", "NationalityName");
                return(View());
            }
            catch (FaultException <WebUIClient.NationalityServiceReference.ValidationFault> ex)
            {
                // Extract the Detail node from the Fault Exception.
                // This details is the
                // ValidationFault class
                WebUIClient.NationalityServiceReference.ValidationFault fault = ex.Detail;
                string alert = "";
                foreach (WebUIClient.NationalityServiceReference.ValidationDetail validationResult in fault.Details)
                {
                    alert = String.Concat(string.Format("Message={0} Key={1} Tag={2}",
                                                        validationResult.Message, validationResult.Key,
                                                        validationResult.Tag));
                }

                return(JavaScript("<script>alert(\"" + alert + "\");</script>"));
            }
        }
Пример #10
0
 public NationalitiesController(NationalityService nationalityService)
 {
     _nationalityService = nationalityService;
 }
Пример #11
0
 public NationalityController()
 {
     _nationalityService = new NationalityService();
 }