Example #1
0
        public IActionResult Update([FromBody] Place place)
        {
            var result = new UpdatePlace(Repository, place).Execute();

            if (result == -1)
            {
                return(Conflict());
            }
            return(Ok(result));
        }
Example #2
0
        public void ShouldDeletePlace()
        {
            var place         = new domain.Place("test", true, true, true, 1, 2, 3);
            var mockPlaceRepo = new Mock <IPlaceRepository>();

            mockPlaceRepo.Setup(m => m.Update(place)).Returns(0);
            var res = new UpdatePlace(mockPlaceRepo.Object, place).Execute();

            Assert.AreEqual(0, res);
        }
Example #3
0
        public void ShouldFailDeletingPlace()
        {
            var place         = new domain.Place("test", true, true, true, 1, 2, 3);
            var mockPlaceRepo = new Mock <IPlaceRepository>();

            mockPlaceRepo.Setup(m => m.Update(It.IsAny <domain.Place>())).Returns(-1);
            var res = new UpdatePlace(mockPlaceRepo.Object, place).Execute();

            Assert.AreEqual(-1, res);
        }
Example #4
0
 public UpdatePlaceViewModel(UpdatePlace window, Place place)
 {
     placeWindow = window;
     _place      = place;
 }
Example #5
0
        public void Place_CRUD_Positive()
        {
            // create
            Place       place         = null;
            Func <Task> asyncFunction = async() => place = await CreatePlace(Client);

            asyncFunction.ShouldNotThrow();
            place.Should().NotBeNull();

            // read
            asyncFunction = async() => place = await Client.ReadPlace(place.Id);

            asyncFunction.ShouldNotThrow();
            place.Should().NotBeNull();

            // real list
            IEnumerable <Place> places = null;

            asyncFunction = async() => places = await Client.ReadPlaces();

            asyncFunction.ShouldNotThrow();
            places.Should().NotBeNullOrEmpty();
            places.Any(x => x.Id == place.Id).Should().BeTrue();

            // update
            var updated = new UpdatePlace(place)
            {
                Name = place.Name + " Updated",
            };

            asyncFunction = async() => place = await Client.UpdatePlace(place.Id, updated);

            asyncFunction.ShouldNotThrow();
            place.Should().NotBeNull();
            place.Name.Should().Be(updated.Name);

            // link unlink
            User user = null;

            asyncFunction = async() =>
            {
                user = await CreateUser(Client);

                await Client.LinkPlace(place.Id, user.Id);

                await Client.UnlinkPlace(place.Id, user.Id);

                await Client.DeleteUser(user.Id);
            };
            asyncFunction.ShouldNotThrow();

            // delete
            asyncFunction = async() => await Client.DeletePlace(place.Id);

            asyncFunction.ShouldNotThrow();

            // real list
            asyncFunction = async() => places = await Client.ReadPlaces();

            asyncFunction.ShouldNotThrow();
            places.Any(x => x.Id == place.Id).Should().BeFalse();
        }
Example #6
0
        private void UpdatePlaceExecute()
        {
            UpdatePlace update = new UpdatePlace(Place);

            update.ShowDialog();
        }