예제 #1
0
        public void EditTrack_ShouldSaveEditedTrack()
        {
            var options = GetDbOptions("EditTrack_Database");

            var dummyTrack = new Track();

            using (var context = new RiderDBContext(options))
            {
                context.Tracks.Add(dummyTrack);
                context.SaveChanges();
            }

            dummyTrack.Name        = "Edited";
            dummyTrack.Description = "Edited";
            dummyTrack.Distance    = 10;
            dummyTrack.Elevation   = 100;

            Track actual;

            using (var context = new RiderDBContext(options))
            {
                var tracksService = new TracksService(context);
                actual = tracksService.EditTrack(dummyTrack);
            }

            Assert.Equal("Edited", actual.Name);
            Assert.Equal("Edited", actual.Description);
            Assert.Equal(10, dummyTrack.Distance);
            Assert.Equal(100, dummyTrack.Elevation);
        }
예제 #2
0
        public void EditTrack_SuccessfulTrackEditing()
        {
            // arrange
            var tracksService = new TracksService(_trackRepository, _eventRepository);
            var trackDto      = new TrackToEditDto(_testTrackUpdated.Id, _testTrackUpdated.Name, _testTrackUpdated.AllowedCustomizations);

            // act
            var result = tracksService.EditTrack(_testUserId, trackDto);

            // assert
            Assert.AreEqual(result.Id, _testTrackUpdated.Id);
            Assert.AreEqual(result.Name, _testTrackUpdated.Name);
            Assert.AreEqual(result.AllowedCustomizations, _testTrackUpdated.AllowedCustomizations);
            Assert.AreEqual(result.CreatedAt, _testTrackUpdated.CreatedAt);
            Assert.AreEqual(result.CreatorId, _testTrackUpdated.CreatorId);
        }
예제 #3
0
        public void EditTrack_AccessDeny()
        {
            // arrange
            var             tracksService = new TracksService(_trackRepository, _eventRepository);
            var             trackDto      = new TrackToEditDto(_testTrack.Id, _testTrack.Name, _testTrack.AllowedCustomizations);
            DomainException exception     = null;

            // act
            try
            {
                var result = tracksService.EditTrack(_testInvalidUserId, trackDto);
            }
            catch (DomainException e)
            {
                exception = e;
            }

            // assert
            Assert.AreEqual(DomainExceptionType.TrackAccessDenied, exception.Type);
        }