예제 #1
0
        public void OnGetSingleTest()
        {
            var locationRequest = new AdventureLocation { Id = "existingId" };

            IList<AdventureLocation> locationList = new List<AdventureLocation>();
            locationList.Add(locationRequest);

            var mock = new Mock<IAdventureLocationRepository>();
            mock.Setup(a => a.GetAdventureLocation(locationRequest.Id)).Returns(locationRequest);

            var target = new AdventureLocationService { AdventureLocationRepository = mock.Object };

            var expected = new AdventureLocationGetResponse(locationRequest);
            expected.AdventureLocations.Add(locationRequest);

            // check get single
            var actual = target.OnGet(locationRequest) as AdventureLocationGetResponse;
            Assert.AreEqual(expected, actual);
        }
예제 #2
0
        public void OnGetListTest()
        {
            var adventureLocation = new AdventureLocation { Id = "existingId" };
            var locationListRequest = new AdventureLocation();

            IList<AdventureLocation> locationList = new List<AdventureLocation>();
            locationList.Add(adventureLocation);

            var mock = new Mock<IAdventureLocationRepository>();
            mock.Setup(a => a.GetAdventureLocations()).Returns(locationList);

            var target = new AdventureLocationService { AdventureLocationRepository = mock.Object };

            var expectedList = new AdventureLocationGetResponse(locationListRequest)
            {
                AdventureLocations = locationList
            };

            // check get list
            var actual = target.OnGet(locationListRequest) as AdventureLocationGetResponse;
            Assert.AreEqual(expectedList, actual);
        }
예제 #3
0
        public void OnPostNewTest()
        {
            var geoPoint = new GeoPoint { Lat = 0, Lon = 0 };
            const string name = "Name";
            var newLocationRequest = new AdventureLocation(geoPoint, name);
            var newLocationResponse = new AdventureLocation(geoPoint, name) { Id = "newId" };
            var expectedNewResponse = new AdventureLocationSaveResponse(newLocationRequest) { AdventureLocation = newLocationResponse };

            var mock = new Mock<IAdventureLocationRepository>();
            mock.Setup(a => a.SaveAdventureLocation(newLocationRequest)).Returns(newLocationResponse);

            var target = new AdventureLocationService { AdventureLocationRepository = mock.Object };

            var actual = target.OnPost(newLocationRequest) as AdventureLocationSaveResponse;
            Assert.AreEqual(expectedNewResponse, actual);
        }