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); }
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); }