Ejemplo n.º 1
0
        public async Task PutUserAddress()
        {
            var         _userAddressService = new Mock <IUserAddressService>();
            UserAddress mockedUserAddress   = new UserAddress(); //new User() { Email = "*****@*****.**", Name = "Test", Surname = "TestSurname", UserId = 1 };

            _userAddressService.Setup(p => p.InsertUser(mockedUserAddress.User)).Returns(mockedUserAddress.User);
            _userAddressService.Setup(p => p.InsertAddress(mockedUserAddress.Address)).Returns(mockedUserAddress.Address);

            UserAddressController userAddressController = new UserAddressController(_userAddressService.Object);
            var okResult = Assert.IsType <OkObjectResult>(userAddressController.Put(1, mockedUserAddress).Result);

            Assert.True(okResult.StatusCode == 200);
        }
Ejemplo n.º 2
0
        public async Task PutUserAddressUserFail()
        {
            var         _userAddressService = new Mock <IUserAddressService>();
            UserAddress mockedUserAddress   = new UserAddress();

            mockedUserAddress.User.Errors.Add("Error");
            _userAddressService.Setup(p => p.InsertUser(mockedUserAddress.User)).Returns(mockedUserAddress.User);
            _userAddressService.Setup(p => p.InsertAddress(mockedUserAddress.Address)).Returns(mockedUserAddress.Address);

            UserAddressController userAddressController = new UserAddressController(_userAddressService.Object);
            var okResult = Assert.IsType <NotFoundResult>(userAddressController.Put(1, mockedUserAddress).Result);

            Assert.True(okResult.StatusCode == 404);
        }
Ejemplo n.º 3
0
        public async Task InsertUserAddress()
        {
            UserAddress address = new UserAddress()
            {
                UserAddressID = 1,
                UserID        = 1,
                StreetAddress = "123 Any Street",
                City          = "Sacramento",
                State         = "CA",
                Zip           = 95746,
                Latitude      = 123.45,
                Longitude     = 45.67
            };
            //Arrange
            var controller = new UserAddressController(_dao, _authService);

            //Act success
            var result = await controller.Put(address);

            //Assert success
            var failureResult = Assert.IsType <JsonResult>(result);
        }