예제 #1
0
        public async void PostAmenityAsyncTest()
        {
            var _complexRepo = new Mock <IRepository>();
            var _logger      = new Mock <ILogger <AmenityController> >();
            var amenity      = new Amenity
            {
                AmenityId   = Guid.NewGuid(),
                AmenityType = "test1",
                Description = "describe"
            };
            var apiAmenity = new ApiAmenity
            {
                AmenityId   = amenity.AmenityId,
                AmenityType = "test1",
                Description = "describe"
            };
            var res = true;

            _complexRepo.Setup(r => r.CreateAmenityAsync(amenity))
            .Returns(Task.FromResult(res));

            //act
            var controller = new AmenityController(_complexRepo.Object, _logger.Object);
            var model      = Assert.IsAssignableFrom <ActionResult>(await controller.PostAmenityAsync(apiAmenity));

            //assert
            Assert.IsAssignableFrom <ActionResult>(model);
        }
예제 #2
0
        public async void GetComplexAmenitiesAsyncTest()
        {
            var cId          = Guid.NewGuid();
            var _complexRepo = new Mock <IRepository>();
            var _logger      = new Mock <ILogger <AmenityController> >();
            var res          = new List <Amenity>();

            _complexRepo.Setup(r => r.ReadAmenityListByComplexIdAsync(cId))
            .Returns(Task.FromResult(res));

            //act
            var controller = new AmenityController(_complexRepo.Object, _logger.Object);
            var model      = Assert.IsAssignableFrom <ActionResult <IEnumerable <Amenity> > >(await controller.GetComplexAmenitiesAsync(cId));

            //assert
            Assert.IsAssignableFrom <ActionResult <IEnumerable <Amenity> > >(model);
        }