public void Create()
        {
            TracksController controller = new TracksController();
            ViewResult       result     = controller.Create() as ViewResult;

            Assert.IsNotNull(result);
        }
        public void AddTrack_UnitOfWorkNull_ShouldThrowException()
        {
            TracksController tracksController = new TracksController();
            Guest            guest            = new Guest {
                EmailAddress = "*****@*****.**"
            };
            Party party = new Party
            {
                Guests = new List <Guest> {
                    guest
                },
                EndTime   = DateTime.Now,
                StartTime = DateTime.Now,
                PlayList  = new PlayList()
            };
            PartyGuest partyGuest = new PartyGuest {
                Party = party, Guest = guest, PartyCode = 1
            };
            PlayList playList = new PlayList {
                Party = party
            };
            Track track = new Track {
                Title = "Song1", Interpret = "Interpret", PlayLists = new List <PlayList> {
                    playList
                }, RecommendedByGuest = partyGuest
            };

            tracksController.AddTrack(null, track);
        }
Пример #3
0
        public void TracksControllerDeleteConfirmed()
        {
            var tracksController = new TracksController(null, null);

            var result = tracksController.DeleteConfirmed(1);

            Assert.IsNotNull(result);
        }
Пример #4
0
        public void TracksControllerEdit()
        {
            var tracksController = new TracksController(null, null);

            var result = tracksController.Edit(null);

            Assert.IsNotNull(result);
        }
Пример #5
0
        public void TracksControllerDetails()
        {
            var tracksController = new TracksController(null, null);

            var result = tracksController.Details(null);

            Assert.IsNotNull(result);
        }
Пример #6
0
        public void TracksControllerIndex()
        {
            var tracksController = new TracksController(null, null);

            var result = tracksController.Index("aaa");

            Assert.IsNotNull(result);
        }
Пример #7
0
        public void TracksControllerReturnNull()
        {
            var tracksController = new TracksController(null, null);

            var result = tracksController.HttpContext;

            Assert.IsNull(result);
        }
Пример #8
0
        public void OneTimeSetup()
        {
            var profile       = new TracksProfile();
            var configuration = new MapperConfiguration(cfg => cfg.AddProfile(profile));
            var realMapper    = new Mapper(configuration);

            mockService = new Mock <ITrackService>();
            _sut        = new TracksController(mockService.Object, realMapper);
        }
Пример #9
0
        public async void getGivenNoExistingIDReturnsNotFound()
        {
            var mockRepository = new Mock <ITrackRepository>();

            mockRepository.Setup(a => a.Find(42)).ReturnsAsync(default(TrackDTO));
            var controller = new TracksController(mockRepository.Object);
            var response   = await controller.Get(42);

            Assert.IsType <NotFoundResult>(response);
        }
Пример #10
0
        public void getAllWithNoItemsReturnsNoContent()
        {
            var mockRepository = new Mock <ITrackRepository>();

            mockRepository.Setup(a => a.Read()).Returns(default(IQueryable <TrackDTO>));
            var controller = new TracksController(mockRepository.Object);
            var response   = controller.Get();

            Assert.IsType <NoContentResult>(response);
        }
Пример #11
0
        public async void deleteFailure()
        {
            var mockRepository = new Mock <ITrackRepository>();

            mockRepository.Setup(a => a.Delete(0)).ReturnsAsync(false);
            var controller = new TracksController(mockRepository.Object);
            var response   = await controller.Delete(0);

            Assert.IsType <NotFoundResult>(response);
        }
Пример #12
0
        public async void deleteSuccess()
        {
            var mockRepository = new Mock <ITrackRepository>();

            mockRepository.Setup(a => a.Delete(0)).ReturnsAsync(true);
            var controller = new TracksController(mockRepository.Object);
            var response   = await controller.Delete(0);

            Assert.IsType <OkResult>(response);
        }
Пример #13
0
        public async void postWithBadTrackReturnsBadRequest()
        {
            var track = new TrackCreateDTO()
            {
            };
            var mockRepository = new Mock <ITrackRepository>();
            var controller     = new TracksController(mockRepository.Object);

            controller.ModelState.AddModelError(string.Empty, "Error");

            var response = await controller.Post(track);

            Assert.IsType <BadRequestObjectResult>(response);
        }
Пример #14
0
        public async void getGivenExistingIDReturnsTrack()
        {
            var TrackDTO = new TrackDTO()
            {
                Id = 42
            };
            var mockRepository = new Mock <ITrackRepository>();

            mockRepository.Setup(a => a.Find(42)).ReturnsAsync(TrackDTO);
            var controller = new TracksController(mockRepository.Object);
            var response   = await controller.Get(42) as OkObjectResult;

            Assert.Equal(TrackDTO, response.Value);
        }
Пример #15
0
        public async void putSucces()
        {
            var track = new TrackUpdateDTO()
            {
                Id = 12121
            };
            var mockRepository = new Mock <ITrackRepository>();

            mockRepository.Setup(a => a.Update(track)).ReturnsAsync(true);
            var controller = new TracksController(mockRepository.Object);
            var response   = await controller.Put(12121, track) as OkObjectResult;

            Assert.Equal(track, response.Value);
        }
Пример #16
0
        public async void putWithNotFound()
        {
            var track = new TrackUpdateDTO()
            {
                Id = 12121
            };
            var mockRepository = new Mock <ITrackRepository>();

            mockRepository.Setup(a => a.Update(track)).ReturnsAsync(false);
            var controller = new TracksController(mockRepository.Object);
            var response   = await controller.Put(12121, track);

            Assert.IsType <NotFoundResult>(response);
        }
Пример #17
0
        public async void postWithGoodTrackReturnsOK()
        {
            var track = new TrackCreateDTO()
            {
                Name = "eat", LengthInMeters = 100, MaxCars = 50
            };
            var mockRepository = new Mock <ITrackRepository>();

            mockRepository.Setup(a => a.Create(track)).ReturnsAsync(1231);
            var controller = new TracksController(mockRepository.Object);
            var response   = await controller.Post(track) as CreatedAtActionResult;

            Assert.Equal("Get", response.ActionName);
            Assert.Equal(1231, response.RouteValues["id"]);
        }
Пример #18
0
        public async Task Get_given_id_returns_track()
        {
            var expected = new TrackDTO {
                Id = 5, Name = "Awesome Track"
            };

            var mock = new Mock <ITrackRepository>();

            mock.Setup(m => m.Find(5)).ReturnsAsync(expected);

            var controller = new TracksController(mock.Object);

            var actual = await controller.Get(5) as OkObjectResult;

            Assert.Equal(expected, actual.Value);
        }
Пример #19
0
        public async Task Create_given_track_creates_track()
        {
            var expected = new TrackCreateDTO {
                Name = "Awesome Track"
            };

            var mock = new Mock <ITrackRepository>();

            mock.Setup(m => m.Create(expected)).ReturnsAsync(5);

            var controller = new TracksController(mock.Object);

            var actual = await controller.Post(expected) as CreatedAtActionResult;

            Assert.Equal("Get", actual.ActionName);
            Assert.Equal(5, actual.RouteValues["id"]);
        }
Пример #20
0
        public async Task Delete_given_id_deletes_track()
        {
            var track = new TrackCreateDTO()
            {
                Name = "Awesome Track", MaxCars = 12, LengthInMeters = 5000
            };

            var repo = new TrackRepository(context);
            await repo.Create(track);

            var controller = new TracksController(repo);

            var response = await controller.Delete(1);

            Assert.IsType <OkResult>(response);
            Assert.Null(context.Tracks.Find(1));
        }
Пример #21
0
        public void getAllWithItemsReturnsOk()
        {
            var list = new List <TrackDTO>()
            {
                new TrackDTO()
                {
                    Id = 1221
                }
            }.AsQueryable();
            var mockRepository = new Mock <ITrackRepository>();

            mockRepository.Setup(a => a.Read()).Returns(list);
            var controller = new TracksController(mockRepository.Object);
            var response   = controller.Get() as OkObjectResult;

            Assert.Equal(list, response.Value);
        }
Пример #22
0
        void Preview()
        {
            tcPreview = new GameObject("PreView Track").AddComponent <TracksController>();


            #region 获取编辑顶点坐标
            tcPreview.transform.position += new Vector3(Points[0].transform.position.x, 0, 0) + vehicleTrackData.TrackCenterOffSet;//到履带位置
            List <Transform> ConvertG2T = new List <Transform>();
            for (int i = 0; i < Points.Count; i++)
            {
                ConvertG2T.Add(Points[i].transform);
                Points[i].transform.SetParent(tcPreview.transform); //修正尝试-01
            }
            Transform[] TrackPoints = ConvertG2T.ToArray();
            #endregion

            #region 设置曲线
            tcPreview.trackSpline = new AnimationSpline(WrapMode.Loop);
            tcPreview.trackSpline.InitSpline(TrackPoints);
            float length = tcPreview.trackSpline.CreateSpline(TrackPoints, false, vehicleTrackData.TrackDistance);
            #endregion

            #region 生成履带
            int         count  = Mathf.RoundToInt(length / vehicleTrackData.TrackDistance) + 2;
            Transform[] tracks = new Transform[count];
            for (int i = 0; i < count; i++)
            {
                tracks[i]        = Instantiate(vehicleTrackData.TrackMesh).transform;
                tracks[i].parent = tcPreview.transform;
            }
            tcPreview.trackSpline.AnimateTracks(TrackPoints, tracks, vehicleTrackData.TrackDistance, false, 1, 1 * Random.Range(1, 10), length);
            #endregion

            #region 生成坐标数据
            Transform TankTransform = EditorTarget.transform.GetChild(0).Find("VehicleDynamics");
            tcPreview.transform.SetParent(TankTransform);
            vehicleTrackData.RightTrackCenter = tcPreview.transform.localPosition;
            vehicleTrackData.LeftTrackCenter  = new Vector3(-vehicleTrackData.RightTrackCenter.x, vehicleTrackData.RightTrackCenter.y, vehicleTrackData.RightTrackCenter.z);
            vehicleTrackData.RelativeBones    = new Vector3[vehicleTrackData.AdvanceLeftBones.Length];

            for (int i = 0; i < vehicleTrackData.AdvanceLeftBones.Length; i++)
            {
                vehicleTrackData.RelativeBones[i] = Points[i].transform.localPosition;
            }
            #endregion
        }
        public void AddTrack_NewCorrectTrack_ShouldAddInDatabase()
        {
            IUnitOfWork      unitOfWork       = new MockUnitOfWork();
            TracksController tracksController = new TracksController();
            Guest            guest            = new Guest {
                EmailAddress = "*****@*****.**"
            };
            Party party = new Party
            {
                Guests = new List <Guest> {
                    guest
                },
                EndTime   = DateTime.Now,
                StartTime = DateTime.Now,
                PlayList  = new PlayList()
            };
            PartyGuest partyGuest = new PartyGuest {
                Party = party, Guest = guest, PartyCode = 1
            };
            PlayList playList = new PlayList {
                Party = party
            };
            Track track = new Track {
                Title = "Song1", Interpret = "Interpret", PlayLists = new List <PlayList> {
                    playList
                }, RecommendedByGuest = partyGuest
            };

            unitOfWork.Parties.Insert(party);
            unitOfWork.PlayLists.Insert(playList);
            unitOfWork.PartyGuests.Insert(partyGuest);
            bool ok = tracksController.AddTrack(unitOfWork, track);

            Assert.IsTrue(ok);
            var tracks = unitOfWork.Tracks.Get();

            Assert.IsTrue(tracks.Any(t => t.Title == track.Title &&
                                     t.Interpret == track.Interpret &&
                                     t.Url == track.Url &&
                                     t.PlayLists.Equals(track.PlayLists) &&
                                     t.RecommendedByGuest == track.RecommendedByGuest));
        }
Пример #24
0
        public async Task Update_given_id_updates_track()
        {
            var track = new TrackCreateDTO()
            {
                Name = "Awesome Track"
            };
            var updatedTrack = new TrackUpdateDTO()
            {
                Name = "Awesome Track", MaxCars = 12, LengthInMeters = 5000
            };

            var repo = new TrackRepository(context);
            await repo.Create(track);

            var controller = new TracksController(repo);
            var put        = await controller.Put(1, updatedTrack) as OkObjectResult;

            var actual = await repo.Find(1);

            Assert.Equal(updatedTrack.MaxCars, actual.MaxCars);
            Assert.Equal(updatedTrack.LengthInMeters, actual.LengthInMeters);
        }
Пример #25
0
 void Awake()
 {
     _Controller = Controller;
     _tracksController = tracksController;
 }
Пример #26
0
 void Awake()
 {
     _transform = transform;
     _parent = transform.parent;
     _tracksController = tracksController;
 }