예제 #1
0
        public async Task <IActionResult> Create([Bind("Id,Name,Religion,Sect,Members,FoundedDate,NumServices,Address1,Address2,City,StateProvince,Zip,Image,Missions,CommunityGroups,MarriageCounseling,ChildCare,YouthMinistry,YoungAdultMinistry,OnlineService")] Location location, IFormFile image)
        {
            if (image != null && image.Length > 0)
            {
                UploadImage(location, image);
            }
            if (ModelState.IsValid)
            {
                await _service.CreateAsync(location);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(location));
        }
        public async void CreateAsync_LocNotNull_returnTrue()
        {
            //arrange
            var mock = new Mock <IUnitOfWork>();

            var service     = new LocationService(mock.Object);
            var newLocation = new Location {
                Loc = "Test"
            };

            mock.Setup(uow => uow.Locations.Insert(It.IsAny <Location>()));

            //act
            var result = await service.CreateAsync(newLocation);

            //assert
            Assert.True(result.Succedeed);
        }