Esempio n. 1
0
        public void Delete_API()
        {
            //Arrange
            Activity item = new Activity()
            {
                ID           = id,
                IdentityGUID = "1",
                CheckpointIP = "192.168.0.1",
                Date         = DateTime.Now,
                ModeID       = 1,
                Status       = true
            };

            activityServiceMock.Setup(x => x.Get(id)).Returns(item);

            //Act
            var actionResult  = controllerAPI.Delete(id);
            var contentResult = actionResult as OkNegotiatedContentResult <Activity>;

            //Assert
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.IsInstanceOfType(contentResult.Content, typeof(Activity));
            Assert.AreEqual(item, contentResult.Content);
        }
Esempio n. 2
0
        public async Task CanDeleteValidActivityAndUpdateBudget()
        {
            // Arrange - create the mock repository
            TestTrekStoriesContext tc = new TestTrekStoriesContext();
            Trip trip = new Trip {
                TripId = 1, Title = "Trip Name", TotalCost = 20, TripOwner = "ABC123"
            };

            tc.Trips.Add(trip);
            Step step = new Step {
                StepId = 123, TripId = 1
            };

            tc.Steps.Add(step);
            tc.Activities.Add(new LeisureActivity()
            {
                ID = 1, Name = "Aquapark", StepId = 123
            });
            LeisureActivity l2 = new LeisureActivity()
            {
                ID = 2, Name = "Test", StepId = 123, Price = 15
            };

            tc.Activities.Add(l2);
            // Arrange - create the controller
            ActivitiesController controller = new ActivitiesController(tc).WithAuthenticatedUser("ABC123");
            // Act - delete an activity
            var result = await controller.Delete(2);

            // Assert - ensure that the activity is deleted from repository
            Assert.IsNull(tc.Activities.FirstOrDefault(l => l.ID == l2.ID));
            // Assert - ensure that the trip budget was updated
            Assert.AreEqual(5, trip.TotalCost);
        }
        public async Task ActivityController_Delete()
        {
            using (var uow = ObjectFactory.GetInstance <IUnitOfWork>())
            {
                var activityMock = new Mock <IActivity>();

                activityMock.Setup(a => a.Delete(It.IsAny <Guid>())).Returns(Task.FromResult(0));

                ActivityDO activityDO = new FixtureData(uow).TestActivity3();
                var        controller = new ActivitiesController(activityMock.Object, ObjectFactory.GetInstance <IActivityTemplate>(), ObjectFactory.GetInstance <IPlan>(), ObjectFactory.GetInstance <IUnitOfWorkFactory>());
                await controller.Delete(activityDO.Id);

                activityMock.Verify(a => a.Delete(activityDO.Id));
            }
        }